Skip to content

Commit

Permalink
Migration file, invite_event_host perm req
Browse files Browse the repository at this point in the history
  • Loading branch information
mscanlan-git committed Nov 27, 2023
1 parent a108095 commit cc00a57
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
15 changes: 10 additions & 5 deletions physionet-django/console/templates/console/user_management.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@

{% load static %}

{% load user_templatetags %}

{% block title %}User management{% endblock %}

{% block content %}

<div class="col-md-9 no-pd">
<form action="{% url 'event_invite_host' subject.username %}" method="post" class="form-signin" onsubmit="return confirm('Are you sure you would like to add this user as an event host?')">
{% csrf_token %}
<button class="btn btn-success btn-fixed" type="submit">Invite event host</button>
</form>
{% if perms.self.invite_event_host%}
{% if user|has_group:'Event Host' %}
<form action="{% url 'event_invite_host' subject.username %}" method="post" class="form-signin" onsubmit="return confirm('Are you sure you would like to add this user as an event host?')">
{% csrf_token %}
<button class="btn btn-success btn-fixed" id="invite_host_button">Invite event host</button>
</form>
{% endif %}
{% endif %}
<h1>{{ subject.get_full_name }} ({{ subject.username }})</h1>
<br />
<h3>Profile</h3>
Expand Down Expand Up @@ -211,6 +217,5 @@ <h3>Credentialing history</h3>
<li>No applications found.</li>
{% endfor %}
</ul>

</div>
{% endblock %}
2 changes: 1 addition & 1 deletion physionet-django/console/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3116,7 +3116,7 @@ def event_agreement_delete(request, pk):
return redirect("event_agreement_list")


@permission_required('user.view_all_events', raise_exception=True)
@permission_required('user.invite_event_host', raise_exception=True)
def event_invite_host(request, username):
"""
Gives the user permissions to be an event host
Expand Down
17 changes: 17 additions & 0 deletions physionet-django/events/migrations/0009_alter_event_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.1.9 on 2023-11-17 20:27

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('events', '0008_alter_event_description'),
]

operations = [
migrations.AlterModelOptions(
name='event',
options={'permissions': [('view_all_events', 'Can view all events in the console'), ('invite_event_host', 'Can grant event host status to a user'), ('view_event_menu', 'Can view event menu in the navbar')]},
),
]
1 change: 1 addition & 0 deletions physionet-django/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Event(models.Model):
class Meta:
unique_together = ('title', 'host')
permissions = [('view_all_events', 'Can view all events in the console'),
('invite_event_host', 'Can grant event host status to a user'),
('view_event_menu', 'Can view event menu in the navbar')]

def save(self, *args, **kwargs):
Expand Down

0 comments on commit cc00a57

Please sign in to comment.