diff --git a/adminsec/templates/adminsec/overview.html b/adminsec/templates/adminsec/overview.html index 43d0ff2..0e95ee5 100644 --- a/adminsec/templates/adminsec/overview.html +++ b/adminsec/templates/adminsec/overview.html @@ -4,16 +4,13 @@

- Welcome {% if user.first_name or user.last_name %} {{ user.first_name }} {{ user.last_name }}{% else %}{{ user.username }}{% endif %} - — + Welcome {% if user.first_name or user.last_name %} {{ user.first_name }} {{ user.last_name }}{% else %}{{ user.username }}{% endif %}! - Open Requests - Terms & Conditions

- {% include "usersec/modules/request_grid.html" %} + {% include "adminsec/requests.html" %} {% endblock content %} diff --git a/adminsec/templates/adminsec/requests.html b/adminsec/templates/adminsec/requests.html new file mode 100644 index 0000000..ce28360 --- /dev/null +++ b/adminsec/templates/adminsec/requests.html @@ -0,0 +1,35 @@ +{% load common %} + + + + + + + + + + + + {% for obj in pending_requests %} + + + + + + + {% empty %} + + + + {% endfor %} + +
Request TypeRequesterCreatedModified
+ + + {{ obj.get_request_type }} + + {{ obj.requester.name }}{{ obj.date_created|date:"Y-m-d H:i" }}{{ obj.date_modified|date:"Y-m-d H:i" }}
+ No pending requests. +
+ + diff --git a/adminsec/views.py b/adminsec/views.py index 7bb139f..0566010 100644 --- a/adminsec/views.py +++ b/adminsec/views.py @@ -1,5 +1,6 @@ import unicodedata from datetime import datetime +from itertools import chain from django.conf import settings from django.contrib import messages @@ -174,32 +175,16 @@ def get_context_data(self, **kwargs): # Used as switch in template context["admin"] = True - # Add open HpcGroupCreateRequest - context["hpcgroupcreaterequests"] = HpcGroupCreateRequest.objects.active() - - # Add open HpcUserCreateRequest - context["hpcusercreaterequests"] = HpcUserCreateRequest.objects.active() - - # Add open HpcProjectCreateRequest - context["hpcprojectcreaterequests"] = HpcProjectCreateRequest.objects.active() - - # Add open HpcUserChangeRequest - context["hpcuserchangerequests"] = HpcUserChangeRequest.objects.active() - - # Add open HpcGroupChangeRequest - context["hpcgroupchangerequests"] = HpcGroupChangeRequest.objects.active() - - # Add open HpcProjectChangeRequest - context["hpcprojectchangerequests"] = HpcProjectChangeRequest.objects.active() - - # Add open HpcGroupDeleteRequest - context["hpcgroupdeleterequests"] = None - - # Add open HpcUserDeleteRequest - context["hpcuserdeleterequests"] = None - - # Add open HpcProjectDeleteRequest - context["hpcprojectdeleterequests"] = None + context["pending_requests"] = list( + chain( + HpcGroupCreateRequest.objects.active(), + HpcGroupChangeRequest.objects.active(), + HpcProjectCreateRequest.objects.active(), + HpcProjectChangeRequest.objects.active(), + HpcUserCreateRequest.objects.active(), + HpcUserChangeRequest.objects.active(), + ) + ) return context @@ -240,6 +225,7 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() context["hpc_group_name_suggestion"] = obj.name if obj.name else name tier1_work = folders.get("tier1_work") tier1_scratch = folders.get("tier1_scratch") @@ -490,6 +476,7 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() context["admin"] = True return context @@ -659,6 +646,7 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() context["admin"] = True return context @@ -822,6 +810,7 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() context["hpc_project_name_suggestion"] = name tier1_work = folders.get("tier1_work") tier1_scratch = folders.get("tier1_scratch") @@ -970,12 +959,14 @@ def post(self, request, *args, **kwargs): creator=self.request.user, status=OBJECT_STATUS_ACTIVE, expiration=obj.expiration, + delegate=obj.delegate, ) - project.members.add(obj.group.owner) - project.version_history.last().members.add(obj.group.owner) + members = list(obj.members.all()) + project.members.add(*members) + project.get_latest_version().members.add(*members) # Create invitations for users - for member in obj.members.all(): + for member in members: if member == obj.group.owner: continue @@ -1084,6 +1075,7 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() context["admin"] = True return context @@ -1237,6 +1229,7 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() context["admin"] = True return context @@ -1244,7 +1237,7 @@ def get_context_data(self, **kwargs): class HpcProjectChangeRequestRevisionView(HpcPermissionMixin, UpdateView): """HPC project change request revision view.""" - template_name = "usersec/hpcprojectchangerequest_form.html" + template_name = "usersec/hpcprojectcreaterequest_form.html" model = HpcProjectChangeRequest form_class = HpcProjectChangeRequestForm slug_field = "uuid" diff --git a/hpcaccess/static/js/project.js b/hpcaccess/static/js/project.js index 999c904..7f8c9c2 100644 --- a/hpcaccess/static/js/project.js +++ b/hpcaccess/static/js/project.js @@ -4,7 +4,7 @@ function mergeToJson() { var content = [] $(".mergeToJson").each(function () { - content.push('"' + $(this).attr("name") + '": "' + $(this).val() + '"'); + content.push('"' + $(this).attr("name") + '": ' + $(this).val()); }); $("#id_resources_requested").val("{" + content.join(", ") + "}") } diff --git a/hpcaccess/templates/pages/login.html b/hpcaccess/templates/pages/login.html index 894ec28..11dc229 100644 --- a/hpcaccess/templates/pages/login.html +++ b/hpcaccess/templates/pages/login.html @@ -4,11 +4,10 @@ {% block content %}
- -

- Welcome to HPC Access. -

-

+

+ Welcome to HPC Access! +

+

This website allows users of the BIH HPC cluster to

-
-

+


+

Please log in using your Charité or MDC account.

@@ -40,7 +39,6 @@
{% if not admin %} -
-
- {% if object.status == "ACTIVE" %} - You've requested a change for your group. - We are working on your request and you will receive an email once we approve it. - {% elif object.status == "RETRACTED" %} - You have retracted your request to change your group. Click Re-activate to activate the request. - {% elif object.status == "REVISION" %} - We have asked for you to revise your request to change your group. See our comment and please answer any question. - {% endif %} -
-
+ {% include "usersec/modules/request_status_card.html" %} {% endif %}
-
+
{% include "usersec/modules/resources_requested.html" with object=object %} @@ -47,7 +36,7 @@

{{ object.expiration|date:"Y-m-d" }}

-
+
{% include "usersec/modules/comments.html" %}
diff --git a/usersec/templates/usersec/hpcgroupchangerequest_form.html b/usersec/templates/usersec/hpcgroupchangerequest_form.html index 4a87e9a..e979a66 100644 --- a/usersec/templates/usersec/hpcgroupchangerequest_form.html +++ b/usersec/templates/usersec/hpcgroupchangerequest_form.html @@ -7,36 +7,32 @@

{% if update %} - Update group change request + {% if admin %} + Request Revision + {% else %} + Update Group Request + {% endif %} {% else %} - Request group change + Change Group Request {% endif %}

{% include "usersec/modules/comments.html" %} -
+ {% csrf_token %} {% if admin %}
-
Resource Quotas
-
-
- {% for key, value in object.resources_requested.items %} -
{{ key }}
-
{{ value }}
- {% endfor %} -
-
- -
Requester
-
{{ object.requester.username }}
- -
Description
-
{{ object.description }}
- -
Expiration
-
{{ object.expiration|date:"Y-m-d" }}
+ {% include "usersec/modules/resources_requested.html" with object=object %} + +
Requester
+
{{ object.requester.username }}
+ +
Description
+
{{ object.description }}
+ +
Expiration
+
{{ object.expiration|date:"Y-m-d" }}
{% endif %} @@ -44,46 +40,52 @@

{{ field }} {% endfor %} - {% for field in form.visible_fields %} -
- {% if field.errors %} - - {% endif %} -
- - {% if field.field.required %} - {{ field.label }}* - {% else %} - {{ field.label }} - {% endif %} - - {{ field }} -
- {% if field.help_text %} -

{{ field.help_text|safe }}

- {% endif %} + {% if admin %} +
+ {% endif %} + + {% include "usersec/form_field.html" with field=form.description %} + {% include "usersec/form_field.html" with field=form.delegate %} + {% include "usersec/form_field.html" with field=form.expiration %} + +

Resources

+ +
+
+
Tier 1
+ {% include "usersec/form_field.html" with field=form.tier1_scratch %}
- {% endfor %} +
+
Tier 2
+ {% include "usersec/form_field.html" with field=form.tier2_unmirrored %} +
+
+
+
+ {% include "usersec/form_field.html" with field=form.tier1_work %} +
+
+ {% include "usersec/form_field.html" with field=form.tier2_mirrored %} +
+
+ + {% if admin %} +
+ {% endif %} + + {% include "usersec/form_field.html" with field=form.comment %} - - + Cancel diff --git a/usersec/templates/usersec/hpcgroupcreaterequest_detail.html b/usersec/templates/usersec/hpcgroupcreaterequest_detail.html index 57c80a7..dddd18a 100644 --- a/usersec/templates/usersec/hpcgroupcreaterequest_detail.html +++ b/usersec/templates/usersec/hpcgroupcreaterequest_detail.html @@ -5,10 +5,7 @@ {% block content %}

- HPC Group Request - - {{ object.display_status }} - + Group Request {% if admin %} {% include "usersec/modules/request_buttons_admin.html" %} @@ -16,32 +13,11 @@

{% include "usersec/modules/request_buttons_user.html" with omit_home_button=1 %} {% endif %} +

-{% if object.status == "ACTIVE" %} -
-
- We are working on your request and you will receive an email once we approve it. - Once your request has been approved, you can adjust the amount of resources that you applied for. -
-
-{% elif object.status == "RETRACTED" %} -
-
- You have retracted your group creation request. - Click "Re-activate" to re-apply for group creation. -
-
-{% elif object.status == "REVISION" %} -
-
- We have asked for you to revise your group request. - See our comment and please answer any question and/or update the resource requests. -
-
-{% endif %} {% if admin %} -
+
Note that you explicitly need to set the POSIX group name and the folder path for the group before approval.
    @@ -50,113 +26,115 @@

+{% else %} + {% include "usersec/modules/request_status_card.html" %} {% endif %} -
-
-
- {% include "usersec/modules/resources_requested.html" with object=object %} +
+ {% if admin %} +
+
+ {% include "usersec/modules/resources_requested.html" with object=object %} -
Requester
-
{{ object.requester.first_name }} {{ object.requester.last_name }} ({{ object.requester.username }})
+
Requester
+
{{ object.requester.first_name }} {{ object.requester.last_name }} ({{ object.requester.username }})
- {% if admin %} -
- POSIX Name - - - -
-
-
- -
-
-
+
+ POSIX Name + + + +
+
+
+ +
+
+
-
- Folders - - - -
-
-
Tier 1
-
- Work - -
-
-
- Scratch - -
-
-
Tier 2
-
- Unmirrored - -
-
-
- Mirrored - -
-
-
- -
-
- {% endif %} +
+ Folders + + + +
+
+
Tier 1
+
+ Work + +
+
+
+ Scratch + +
+
+
Tier 2
+
+ Unmirrored + +
+
+
+ Mirrored + +
+
+
+ +
+
-
Description
-
{{ object.description }}
+
Description
+
{{ object.description }}
-
Expiration
-
{{ object.expiration|date:"Y-m-d" }}
-
-
-
+
Expiration
+
{{ object.expiration|date:"Y-m-d" }}
+
+
+ {% endif %} +
{% include "usersec/modules/comments.html" %}
diff --git a/usersec/templates/usersec/hpcgroupcreaterequest_form.html b/usersec/templates/usersec/hpcgroupcreaterequest_form.html index b40efe3..d1d098d 100644 --- a/usersec/templates/usersec/hpcgroupcreaterequest_form.html +++ b/usersec/templates/usersec/hpcgroupcreaterequest_form.html @@ -4,146 +4,128 @@ {% block content %} -

+

{% if update %} - Update group request + {% if admin %} + Request Revision + {% else %} + Update Group Request + {% endif %} {% else %} - Request group + Create Group Request {% endif %} -

+

+ {% if not admin %} -

- As the first step is for principal investigators and group leaders to create a group on the cluster which gives their group/lab members a primary entity on the cluster. -

-

- Only "group leaders" can do this. - Example of group leaders are principal investigators, leaders of scientific or technical units, and junior group leaders. +

+ The first step for principal investigators and group leaders is to create a + group on the cluster. + Only "group leaders" can do this! + Example of group leaders are principal investigators, leaders of scientific or technical units, + and junior group leaders. As a group leader, you take responsibility for the action of your users on the cluster. Please provide a link to your group at Charite/MDC in the comment field for verification. -

-

You can add members to your groups and designate a delegate later on in the process.

{% endif %} - {% include "usersec/modules/comments.html" %} +{% include "usersec/modules/comments.html" %} -
- - {% csrf_token %} - {% if admin %} -
- {% include "usersec/modules/resources_requested.html" with object=object %} + + {% csrf_token %} + {% if admin %} +
+ {% include "usersec/modules/resources_requested.html" with object=object %} -
Requester
-
{{ object.requester.username }}
+
Requester
+
{{ object.requester.username }}
-
Description
-
{{ object.description }}
+
Description
+
{{ object.description }}
-
Expiration
-
{{ object.expiration|date:"Y-m-d" }}
-
- {% endif %} +
Expiration
+
{{ object.expiration|date:"Y-m-d" }}
+
+ {% endif %} - {% for field in form.hidden_fields %} - {{ field }} - {% endfor %} + {% for field in form.hidden_fields %} + {{ field }} + {% endfor %} - {% for field in form.visible_fields %} -
- {% if field.errors %} - - {% endif %} -
- - {% if field.field.required %} - {{ field.label }}* - {% else %} - {{ field.label }} - {% endif %} + {% if admin %} +
+ {% endif %} + + {% include "usersec/form_field.html" with field=form.description %} + + {% if not admin %} +
+
+ + + + +
+

+ You must confirm that you are a group leader before you can submit the form. +

+
+ {% if terms_list %} +

Terms & Conditions

+ {% for obj in terms_list %} +

{{ obj.title }}

+

{{ obj.text }}

+
+ + + +
- {% if field.help_text %} -

{{ field.help_text|safe }}

- {% endif %} +
{% endfor %} + {% endif %} + {% endif %} + {% if admin %} +
+ {% endif %} + + {% include "usersec/form_field.html" with field=form.comment %} - {% if not admin %} -
-
- - - - -
-

- You must confirm that you are a group leader before you can submit the form. -

-
-

Terms & Conditions

- {% for obj in terms_list %} -

{{ obj.title }}

-

{{ obj.text }}

-
- - - - -
- {% endfor %} - {% endif %} - {% if update %} - - - Cancel - + {% if admin or update %} + - - Cancel - + href="{% url 'usersec:hpcgroupcreaterequest-detail' hpcgroupcreaterequest=object.uuid %}" {% endif %} - - -
+ > + Cancel + + {% endif %} + + {% endblock content %} {% block inline_javascript %} + {% if not admin %} {{ block.super }} + {% endif %} {% endblock inline_javascript %} diff --git a/usersec/templates/usersec/hpcprojectchangerequest_detail.html b/usersec/templates/usersec/hpcprojectchangerequest_detail.html index e2f26d9..2bb6f12 100644 --- a/usersec/templates/usersec/hpcprojectchangerequest_detail.html +++ b/usersec/templates/usersec/hpcprojectchangerequest_detail.html @@ -4,63 +4,65 @@ {% block content %} -
-
-

- HPC Project Change Request - - {{ object.display_status }} - - - {% if admin %} - {% include "usersec/modules/request_buttons_admin.html" %} - {% else %} - {% include "usersec/modules/request_buttons_user.html" %} - {% endif %} - -

-
-
-
-
-
- {% include "usersec/modules/resources_requested.html" with object=object %} +

+ Request Project + + {% if admin %} + {% include "usersec/modules/request_buttons_admin.html" %} + {% else %} + {% include "usersec/modules/request_buttons_user.html" %} + {% endif %} + +

-
Requester
-
- {{ object.requester.name }} - {{ object.requester.hpcuser_user.first.username }} -
+
+
+
+ {% include "usersec/modules/resources_requested.html" with object=object %} -
Delegate
-
- {% if object.delegate %} - {{ object.delegate.user.name }} {{ object.delegate.username }} - {% else %} - No delegate. - {% endif %} -
+ {% if admin %} +
Requester
+
+ {{ object.requester.name }} + ({{ object.requester.hpcuser_user.first.username }}) +
-
Members
-
-
    - {% for member in object.members.all %} -
  • - {{ member.user.name }} {{ member.username }} -
  • - {% endfor %} -
-
+
Associated Group
+
+ AG {{ object.project.group.name.capitalize }} + — {{ object.project.group.owner.user.name }} + ({{ object.project.group.owner.username }}) +
+ {% endif %} -
Expiration
-
{{ object.expiration|date:"Y-m-d" }}
-
-
-
- {% include "usersec/modules/comments.html" %} -
-
-
+
Delegate
+
+ {% if object.delegate %} + {{ object.delegate.user.name }} + ({{ object.delegate.username }}, AG {{ object.delegate.primary_group.name }}) + {% else %} + No delegate. + {% endif %} +
+ +
Members
+
+
    + {% for member in object.members.all %} +
  • + {{ member.user.name }} ({{ member.username }}, AG {{ member.primary_group.name }}) +
  • + {% endfor %} +
+
+ +
Expiration
+
{{ object.expiration|date:"Y-m-d" }}
+ +
+
+ {% include "usersec/modules/comments.html" %}
+
{% endblock content %} diff --git a/usersec/templates/usersec/hpcprojectchangerequest_form.html b/usersec/templates/usersec/hpcprojectchangerequest_form.html deleted file mode 100644 index 02142bb..0000000 --- a/usersec/templates/usersec/hpcprojectchangerequest_form.html +++ /dev/null @@ -1,150 +0,0 @@ -{% extends 'base.html' %} - -{% load crispy_forms_tags %} -{% load common %} - -{% block content %} - -
-

- {% if update %} - Update Project Change Request — {{ project.name }} ({{ project.group.owner.user.name }}) - {% else %} - Request Project Change — {{ project.name }} ({{ project.group.owner.user.name }}) - {% endif %} -

-
- - {% include "usersec/modules/comments.html" %} - -
-
- {% csrf_token %} - {% if admin %} -
-
Resource Quotas
-
-
- {% for key, value in object.resources_requested.items %} -
{{ key }}
-
{{ value }}
- {% endfor %} -
-
- -
Requester
-
{{ object.requester.username }}
- -
Description
-
{{ object.description }}
- -
Members {{ object.members.count }}
-
-
    - {% for member in object.members.all %} -
  • {{ member }}
  • - {% endfor %} -
-
- -
Expiration
-
{{ object.expiration|date:"Y-m-d" }}
-
- {% endif %} - - {% for field in form.hidden_fields %} - {{ field }} - {% endfor %} - - {% for field in form.visible_fields %} -
- {% if field.errors %} - - {% endif %} -
- - {% if field.field.required %} - {{ field.label }}* - {% else %} - {{ field.label }} - {% endif %} - - {{ field }} - {% if field.label == "Select Members" %} - - {% endif %} -
- {% if field.help_text %} -

{{ field.help_text|safe }}

- {% endif %} - {% if field.label == "Select Members" %} -
Members selected
-
- No members selected. -
- {% endif %} -
- {% endfor %} - - {% if update %} - - - Cancel - - {% else %} - - - Cancel - - {% endif %} - -
-
-{% endblock content %} - -{% block inline_javascript %} - {{ block.super }} - -{% endblock inline_javascript %} diff --git a/usersec/templates/usersec/hpcprojectchangerequest_retract_confirm.html b/usersec/templates/usersec/hpcprojectchangerequest_retract_confirm.html deleted file mode 100644 index b886279..0000000 --- a/usersec/templates/usersec/hpcprojectchangerequest_retract_confirm.html +++ /dev/null @@ -1,9 +0,0 @@ -{% extends 'base.html' %} - -{% load common %} - -{% block content %} - - {% include "usersec/modules/confirm.html" with action="Retract" object_type="request to change a project" %} - -{% endblock content %} diff --git a/usersec/templates/usersec/hpcprojectcreaterequest_detail.html b/usersec/templates/usersec/hpcprojectcreaterequest_detail.html index 7989e1d..347b666 100644 --- a/usersec/templates/usersec/hpcprojectcreaterequest_detail.html +++ b/usersec/templates/usersec/hpcprojectcreaterequest_detail.html @@ -5,7 +5,7 @@ {% block content %}

- Request to Create a Project + Request Project {% if admin %} {% include "usersec/modules/request_buttons_admin.html" %} @@ -25,21 +25,10 @@

+{% else %} + {% include "usersec/modules/request_status_card.html" %} {% endif %} -{% if not admin %} -
-
- {% if object.status == "ACTIVE" %} - You've requested a new project with the name {{ object.name_requested }}. - We are working on your request and you will receive an email once we approve it. - {% elif object.status == "RETRACTED" %} - You have retracted your request to create a project. Click Re-activate to activate the request. - {% elif object.status == "REVISION" %} - We have asked for you to revise your request to create a project. See our comment and please answer any question. - {% endif %} -
-
-{% endif %} +
@@ -154,7 +143,7 @@
Tier 2
{% if object.delegate %} {{ object.delegate.user.name }} - ({{ object.delegate.username }}) + ({{ object.delegate.username }}, AG {{ object.delegate.primary_group.name }}) {% else %} No delegate. {% endif %} @@ -179,10 +168,10 @@
Tier 2
{% include "usersec/modules/comments.html" %}
-
{% endblock content %} {% block inline_javascript %} + {% if admin %} + {% endif %} {% endblock inline_javascript %} diff --git a/usersec/templates/usersec/hpcprojectcreaterequest_form.html b/usersec/templates/usersec/hpcprojectcreaterequest_form.html index a58e992..cea646e 100644 --- a/usersec/templates/usersec/hpcprojectcreaterequest_form.html +++ b/usersec/templates/usersec/hpcprojectcreaterequest_form.html @@ -7,15 +7,19 @@

{% if update %} - Update Project Request + {% if admin %} + Request Revision + {% else %} + Update Project Request + {% endif %} {% else %} - Request Project + Create Project Request {% endif %}

{% include "usersec/modules/comments.html" %} -
+ {% csrf_token %} {% if admin %}
@@ -45,64 +49,56 @@

{{ field }} {% endfor %} - {{ form.members }} + {% if admin %} +
+ {% endif %} + {{ form.members }} - {% include "usersec/form_field.html" with field=form.name_requested %} - {% include "usersec/form_field.html" with field=form.description %} - {% include "usersec/form_field.html" with field=form.expiration %} + {% include "usersec/form_field.html" with field=form.name_requested %} + {% include "usersec/form_field.html" with field=form.description %} + {% include "usersec/form_field.html" with field=form.expiration %} - {{ form.delegate }} +

Delegate

-

Members

+ {{ form.delegate }} -
    -
-
- -
+

Members

-

Resources

- -
-
-
Tier 1
- {% include "usersec/form_field.html" with field=form.tier1_scratch %} -
-
-
Tier 2
- {% include "usersec/form_field.html" with field=form.tier2_unmirrored %} +
    +
+
+
-
-
-
- {% include "usersec/form_field.html" with field=form.tier1_work %} + +

Resources

+ +
+
+
Tier 1
+ {% include "usersec/form_field.html" with field=form.tier1_scratch %} +
+
+
Tier 2
+ {% include "usersec/form_field.html" with field=form.tier2_unmirrored %} +
-
- {% include "usersec/form_field.html" with field=form.tier2_mirrored %} +
+
+ {% include "usersec/form_field.html" with field=form.tier1_work %} +
+
+ {% include "usersec/form_field.html" with field=form.tier2_mirrored %} +
+ {% if admin %}
- -

Comment for the HPC Team

+ {% endif %} {% include "usersec/form_field.html" with field=form.comment %} - {% if update %} - - Cancel - - {% else %} - - Cancel - - {% endif %} + + Cancel +

+
+
+ {% include "usersec/modules/comments.html" %}
+
{% endblock content %} diff --git a/usersec/templates/usersec/hpcuserchangerequest_form.html b/usersec/templates/usersec/hpcuserchangerequest_form.html index 7b16325..4f712e5 100644 --- a/usersec/templates/usersec/hpcuserchangerequest_form.html +++ b/usersec/templates/usersec/hpcuserchangerequest_form.html @@ -4,96 +4,75 @@ {% block content %} -
-

- {% if update %} - Update User Change Request - {% else %} - Request User Change - {% endif %} -

-
+

+ {% if update %} + {% if admin %} + Request Revision + {% else %} + Update User Change Request + {% endif %} + {% else %} + Create User Change Request + {% endif %} + — + {{ user }} +

-
- Change request is for user {{ user }} -
+{% include "usersec/modules/comments.html" %} - {% include "usersec/modules/comments.html" %} - -
- - {% csrf_token %} - {% if admin %} -
-
Requester
-
{{ object.requester.username }}
+ + {% csrf_token %} + {% if admin %} +
+
Requester
+
{{ object.requester.username }}
-
Expiration
-
{{ object.expiration|date:"Y-m-d" }}
-
- {% endif %} +
Expiration
+
{{ object.expiration|date:"Y-m-d" }}
+
+ {% endif %} - {% for field in form.hidden_fields %} - {{ field }} - {% endfor %} + {% for field in form.hidden_fields %} + {{ field }} + {% endfor %} - {% for field in form.visible_fields %} -
- {% if field.errors %} - - {% endif %} -
- - {% if field.field.required %} - {{ field.label }}* - {% else %} - {{ field.label }} - {% endif %} - - {{ field }} -
- {% if field.help_text %} -

{{ field.help_text|safe }}

- {% endif %} + {% for field in form.visible_fields %} + + {% if field.help_text %} +

{{ field.help_text|safe }}

+ {% endif %} +
+ {% endfor %} + + + Cancel + + - -
+ {% else %} + Submit + {% endif %} + + {% endblock content %} diff --git a/usersec/templates/usersec/hpcusercreaterequest_detail.html b/usersec/templates/usersec/hpcusercreaterequest_detail.html index 00b779a..6e16298 100644 --- a/usersec/templates/usersec/hpcusercreaterequest_detail.html +++ b/usersec/templates/usersec/hpcusercreaterequest_detail.html @@ -18,41 +18,27 @@

{% if admin %} -
-
Status
-
- {{ object.display_status }} - -
- -
Invitee
-
{{ object.email }}
- -
Requester
-
{{ object.requester }}
- -
Group
-
{{ object.group.name }}
- -
Expiration
-
{{ object.expiration|date:"Y-m-d" }}
-
+
+
Status
+
+ {{ object.display_status }} + +
+ +
Invitee
+
{{ object.email }}
+ +
Requester
+
{{ object.requester }}
+ +
Group
+
{{ object.group.name }}
+ +
Expiration
+
{{ object.expiration|date:"Y-m-d" }}
+
{% else %} -
-
- {% if object.status == "ACTIVE" %} - You've invited the user {{ object.email }} to your group. - We are working on your request and you will receive an email once we approve it. - {% elif object.status == "RETRACTED" %} - You have retracted your request to invite {{ object.email }} to your - group. Click Re-activate to re-activate the request for invitation. - {% elif object.status == "REVISION" %} - We have asked for you to revise your request to invite - {{ object.email }} to your group. See our comment and please answer any - question. - {% endif %} -
-
+ {% include "usersec/modules/request_detail.html" %} {% endif %}
diff --git a/usersec/templates/usersec/hpcusercreaterequest_form.html b/usersec/templates/usersec/hpcusercreaterequest_form.html index 5582f12..51610a2 100644 --- a/usersec/templates/usersec/hpcusercreaterequest_form.html +++ b/usersec/templates/usersec/hpcusercreaterequest_form.html @@ -6,9 +6,9 @@

{% if update %} - Update User Request + Update User Invitation {% else %} - Request User + Invite User {% endif %}

@@ -50,28 +50,9 @@

{{ field }} {% endfor %} - {% for field in form.visible_fields %} -
- {% if field.errors %} - - {% endif %} -
- - {% if field.field.required %} - {{ field.label }}* - {% else %} - {{ field.label }} - {% endif %} - - {{ field }} -
- {% if field.help_text %} -

{{ field.help_text|safe }}

- {% endif %} -
- {% endfor %} + {% include "usersec/form_field.html" with field=form.email %} + {% include "usersec/form_field.html" with field=form.expiration %} + {% include "usersec/form_field.html" with field=form.comment %} {% if update %} - Cancel {% endif %} diff --git a/usersec/templates/usersec/modules/comments.html b/usersec/templates/usersec/modules/comments.html index 5332af7..7f62f83 100644 --- a/usersec/templates/usersec/modules/comments.html +++ b/usersec/templates/usersec/modules/comments.html @@ -1,5 +1,4 @@ -{% if object.get_comment_history %} -
+
Comments
    @@ -11,8 +10,9 @@
    Comments
    {{ comment.2 }} + {% empty %} +
  • No comments.
  • {% endfor %}
-{% endif %} diff --git a/usersec/templates/usersec/modules/confirm.html b/usersec/templates/usersec/modules/confirm.html index b0b5e8a..d8f62ed 100644 --- a/usersec/templates/usersec/modules/confirm.html +++ b/usersec/templates/usersec/modules/confirm.html @@ -11,7 +11,6 @@

the {{ object_type }}?

- {{ form }} Cancel diff --git a/usersec/templates/usersec/modules/manage.html b/usersec/templates/usersec/modules/manage.html index fee36c1..3829f86 100644 --- a/usersec/templates/usersec/modules/manage.html +++ b/usersec/templates/usersec/modules/manage.html @@ -1,160 +1,177 @@ {% load common %} - -
-
-
-
-
Manage Group
-
-
- + -
-
- -
-
-
-
Manage Projects
-
- -
+ + {% endif %} +
  • + + Invite User + +
  • +
  • +
  • +
  • + + New Project + +
  • +
    +

    Open Requests

    + + + + + + + + + + + + + {% for obj in requests %} + + + + + + + + {% empty %} + + + + {% endfor %} + +
    Request TypeCreatedModifiedStatus
    {{ obj.get_request_type }}{{ obj.date_created|date:"Y-m-d H:i" }}{{ obj.date_modified|date:"Y-m-d H:i" }}{{ obj.status }} +
    + {% if is_decided %} + + + + {% endif %} + + + +
    +
    + No pending requests. +
    + +

    Group Members

    + + + + + + + + + + + + + {% for member in object.primary_group.hpcuser.all|order_by:"user__name" %} + + + + + + + + {% empty %} + + + + {% endfor %} + +
    NameUsernameJoinedExpires
    {{ member.user.name }}{{ member.username }}{{ member.date_created|date:"Y-m-d H:i" }}{{ member.expiration|date:"Y-m-d H:i" }} + +
    + No users. +
    + +

    Projects

    + + + + + + + + + + + + + {% for project in object.hpcproject_members.all|order_by:"name" %} + + + + + + + + {% empty %} + + + + {% endfor %} + +
    NameDelegateCreatedExpires
    {{ project.name }}{{ project.delegate.user.name|default:"None" }}{{ project.date_created|date:"Y-m-d H:i" }}{{ project.expiration|date:"Y-m-d H:i" }} + +
    + No projects. +
    + {% block inline_javascript %} - -{% endblock inline_javascript %} diff --git a/usersec/templates/usersec/modules/request_grid_group_change.html b/usersec/templates/usersec/modules/request_grid_group_change.html deleted file mode 100644 index a28fe9b..0000000 --- a/usersec/templates/usersec/modules/request_grid_group_change.html +++ /dev/null @@ -1,32 +0,0 @@ -{% load common %} - -
    -
    -
    - {% if admin %} - - Change Requests - {% else %} - - - Update Group - - {% endif %} -
    -
    -
      - {% for obj in hpcgroupchangerequests %} -
    • - {{ obj.group.name }} - - {{ obj.display_status }} - -
      - {{ obj.requester.username }} - {{ obj.date_created|date:"Y-m-d H:i" }} -
    • - {% empty %} -
    • No requests.
    • - {% endfor %} -
    -
    diff --git a/usersec/templates/usersec/modules/request_grid_group_create.html b/usersec/templates/usersec/modules/request_grid_group_create.html deleted file mode 100644 index 5fe44c8..0000000 --- a/usersec/templates/usersec/modules/request_grid_group_create.html +++ /dev/null @@ -1,25 +0,0 @@ -{% load common %} - -
    -
    -
    - - Create Requests -
    -
    -
      - {% for obj in hpcgroupcreaterequests %} -
    • - {{ obj.requester.username }} - - {{ obj.display_status }} - - - {{ obj.date_created|date:"Y-m-d H:i" }} - -
    • - {% empty %} -
    • No requests.
    • - {% endfor %} -
    -
    diff --git a/usersec/templates/usersec/modules/request_grid_group_delete.html b/usersec/templates/usersec/modules/request_grid_group_delete.html deleted file mode 100644 index 05f56c2..0000000 --- a/usersec/templates/usersec/modules/request_grid_group_delete.html +++ /dev/null @@ -1,29 +0,0 @@ -{% load common %} - -
    -
    -
    - {% if admin %} - - Delete Requests - {% else %} - - - Delete Group - - {% endif %} -
    -
    -
      - {% for obj in hpcgroupdeleterequests %} -
    • - {{ obj.requester.username }} - - {{ obj.display_status }} - -
    • - {% empty %} -
    • No requests.
    • - {% endfor %} -
    -
    diff --git a/usersec/templates/usersec/modules/request_grid_no_permission.html b/usersec/templates/usersec/modules/request_grid_no_permission.html deleted file mode 100644 index 47c15da..0000000 --- a/usersec/templates/usersec/modules/request_grid_no_permission.html +++ /dev/null @@ -1,19 +0,0 @@ -
    -
    -
    - {% if request == 'create' %} - - Create {{ obj.capitalize }} - {% elif request == 'update' %} - - Update {{ obj.capitalize }} - {% elif request == 'delete' %} - - Delete {{ obj.capitalize }} - {% endif %} -
    -
    -
    -

    You do not have permission to {{ request }} a {{ obj }}.

    -
    -
    diff --git a/usersec/templates/usersec/modules/request_grid_project_change.html b/usersec/templates/usersec/modules/request_grid_project_change.html deleted file mode 100644 index 1eb9504..0000000 --- a/usersec/templates/usersec/modules/request_grid_project_change.html +++ /dev/null @@ -1,43 +0,0 @@ -{% load common %} - -
    -
    -
    - {% if admin %} - - Change Requests - {% else %} -
    - - {{ form_project_select.projects }} -
    - {% endif %} -
    -
    -
      - {% for obj in hpcprojectchangerequests %} -
    • - {{ obj.project.name_requested }} - - {{ obj.display_status }} - -
      - {{ obj.requester.username }} - {{ obj.date_created|date:"Y-m-d H:i" }} -
      -
    • - {% empty %} -
    • No requests.
    • - {% endfor %} -
    -
    diff --git a/usersec/templates/usersec/modules/request_grid_project_create.html b/usersec/templates/usersec/modules/request_grid_project_create.html deleted file mode 100644 index b7cb14d..0000000 --- a/usersec/templates/usersec/modules/request_grid_project_create.html +++ /dev/null @@ -1,33 +0,0 @@ -{% load common %} - -
    -
    -
    - {% if admin %} - - Create Requests - {% else %} - - - Request New Project - - {% endif %} -
    -
    -
      - {% for obj in hpcprojectcreaterequests %} -
    • - {{ obj.name_requested }} - - {{ obj.display_status }} - -
      - {{ obj.requester.username }} - {{ obj.date_created|date:"Y-m-d H:i" }} -
      -
    • - {% empty %} -
    • No requests.
    • - {% endfor %} -
    -
    diff --git a/usersec/templates/usersec/modules/request_grid_project_delete.html b/usersec/templates/usersec/modules/request_grid_project_delete.html deleted file mode 100644 index 73b6ab8..0000000 --- a/usersec/templates/usersec/modules/request_grid_project_delete.html +++ /dev/null @@ -1,29 +0,0 @@ -{% load common %} - -
    -
    -
    - {% if admin %} - - Delete Requests - {% else %} - - - Delete Project - - {% endif %} -
    -
    -
      - {% for obj in hpcprojectdeleterequests %} -
    • - {{ obj.requester.username }} - - {{ obj.display_status }} - -
    • - {% empty %} -
    • No requests.
    • - {% endfor %} -
    -
    diff --git a/usersec/templates/usersec/modules/request_grid_user_change.html b/usersec/templates/usersec/modules/request_grid_user_change.html deleted file mode 100644 index de944ad..0000000 --- a/usersec/templates/usersec/modules/request_grid_user_change.html +++ /dev/null @@ -1,36 +0,0 @@ -{% load common %} - -
    -
    -
    - {% if admin %} - - Change Requests - {% else %} -
    - - {{ form_user_select.members }} -
    - {% endif %} -
    -
    -
      - {% for obj in hpcuserchangerequests %} -
    • - {{ obj.user.user.name }} | - {{ obj.user.username }} - - {{ obj.display_status }} - -
      - {{ obj.requester.username }} - {{ obj.date_created|date:"Y-m-d H:i" }} -
    • - {% empty %} -
    • No requests.
    • - {% endfor %} -
    -
    diff --git a/usersec/templates/usersec/modules/request_grid_user_create.html b/usersec/templates/usersec/modules/request_grid_user_create.html deleted file mode 100644 index 1189eae..0000000 --- a/usersec/templates/usersec/modules/request_grid_user_create.html +++ /dev/null @@ -1,33 +0,0 @@ -{% load common %} - -
    -
    -
    - {% if admin %} - - Create Requests - {% else %} - - - Add User To Group - - {% endif %} -
    -
    -
      - {% for obj in hpcusercreaterequests %} -
    • - {{ obj.email }} - - {{ obj.display_status }} - -
      - {{ obj.requester.username }} - {{ obj.date_created|date:"Y-m-d H:i" }} -
      -
    • - {% empty %} -
    • No requests.
    • - {% endfor %} -
    -
    diff --git a/usersec/templates/usersec/modules/request_grid_user_delete.html b/usersec/templates/usersec/modules/request_grid_user_delete.html deleted file mode 100644 index 7782531..0000000 --- a/usersec/templates/usersec/modules/request_grid_user_delete.html +++ /dev/null @@ -1,29 +0,0 @@ -{% load common %} - -
    -
    -
    - {% if admin %} - - Delete Requests - {% else %} - - - Delete User - - {% endif %} -
    -
    -
      - {% for obj in hpcuserdeleterequests %} -
    • - {{ obj.requester.username }} - - {{ obj.display_status }} - -
    • - {% empty %} -
    • No requests.
    • - {% endfor %} -
    -
    diff --git a/usersec/templates/usersec/modules/request_status_card.html b/usersec/templates/usersec/modules/request_status_card.html new file mode 100644 index 0000000..544b8f4 --- /dev/null +++ b/usersec/templates/usersec/modules/request_status_card.html @@ -0,0 +1,27 @@ +{% load common %} + +
    +
    + {% if object.status == "ACTIVE" or object.status == "REVISED" %} + We are working on your request and you will receive an email once we approve it. + {% elif object.status == "RETRACTED" %} + You have retracted your request. Click Re-activate to activate the request. + {% elif object.status == "REVISION" %} + We have asked you to revise your request with the following comment: +

    + {% with object.get_comment_history|last as comment %} + "{{ comment.2 }}" + {% endwith %} +

    + {% elif object.status == "APPROVED" %} + We have approved your request. + {% elif object.status == "DENIED" %} + We have denied your request with the following comment: +

    + {% with object.get_comment_history|last as comment %} + "{{ comment.2 }}" + {% endwith %} +

    + {% endif %} +
    +
    \ No newline at end of file diff --git a/usersec/templatetags/common.py b/usersec/templatetags/common.py index 883d533..1eac8cc 100644 --- a/usersec/templatetags/common.py +++ b/usersec/templatetags/common.py @@ -52,9 +52,9 @@ def site_version(): REQUEST_STATUS_INITIAL: "info", REQUEST_STATUS_ACTIVE: "info", REQUEST_STATUS_REVISION: "warning", - REQUEST_STATUS_REVISED: "secondary", + REQUEST_STATUS_REVISED: "info", REQUEST_STATUS_APPROVED: "success", - REQUEST_STATUS_DENIED: "secondary", + REQUEST_STATUS_DENIED: "danger", REQUEST_STATUS_RETRACTED: "secondary", } @@ -65,6 +65,16 @@ def colorize_request_status(status): return REQUEST_STATUS_COLOR_MAPPING.get(status, "dark") +@register.filter +def colorize_text(status): + """Return the color for a given status.""" + color = REQUEST_STATUS_COLOR_MAPPING.get(status, "dark") + if color in ("warning", "info"): + return "dark" + else: + return "light" + + @register.filter def colorize_object_status(status): """Return the color for a given status.""" diff --git a/usersec/urls.py b/usersec/urls.py index 290fc9e..284eaa5 100644 --- a/usersec/urls.py +++ b/usersec/urls.py @@ -50,6 +50,11 @@ view=views.HpcGroupCreateRequestDeleteView.as_view(), name="hpcgroupcreaterequest-delete", ), + path( + "hpcgroupcreaterequest//archive/", + view=views.HpcGroupCreateRequestArchiveView.as_view(), + name="hpcgroupcreaterequest-archive", + ), # ------------------------------------------------------------------------------ # HpcGroupChangeRequest related # ------------------------------------------------------------------------------ @@ -83,6 +88,11 @@ view=views.HpcGroupChangeRequestDeleteView.as_view(), name="hpcgroupchangerequest-delete", ), + path( + "hpcgroupchangerequest//archive/", + view=views.HpcGroupChangeRequestArchiveView.as_view(), + name="hpcgroupchangerequest-archive", + ), # ------------------------------------------------------------------------------ # HpcGroupDeleteRequest related # ------------------------------------------------------------------------------ @@ -116,6 +126,11 @@ view=views.HpcGroupDeleteRequestDeleteView.as_view(), name="hpcgroupdeleterequest-delete", ), + path( + "hpcgroupdeleterequest//archive/", + view=views.HpcGroupDeleteRequestArchiveView.as_view(), + name="hpcgroupdeleterequest-archive", + ), # ------------------------------------------------------------------------------ # HpcUser related # ------------------------------------------------------------------------------ @@ -162,6 +177,11 @@ view=views.HpcUserCreateRequestDeleteView.as_view(), name="hpcusercreaterequest-delete", ), + path( + "hpcusercreaterequest//archive/", + view=views.HpcUserCreateRequestArchiveView.as_view(), + name="hpcusercreaterequest-archive", + ), # ------------------------------------------------------------------------------ # HpcUserChangeRequest related # ------------------------------------------------------------------------------ @@ -228,6 +248,11 @@ view=views.HpcUserDeleteRequestDeleteView.as_view(), name="hpcuserdeleterequest-delete", ), + path( + "hpcuserdeleterequest//archive/", + view=views.HpcUserDeleteRequestArchiveView.as_view(), + name="hpcuserdeleterequest-archive", + ), # ------------------------------------------------------------------------------ # HpcProject related # ------------------------------------------------------------------------------ @@ -269,6 +294,11 @@ view=views.HpcProjectCreateRequestDeleteView.as_view(), name="hpcprojectcreaterequest-delete", ), + path( + "hpcprojectcreaterequest//archive/", + view=views.HpcProjectCreateRequestArchiveView.as_view(), + name="hpcprojectcreaterequest-archive", + ), # ------------------------------------------------------------------------------ # HpcProjectChangeRequest related # ------------------------------------------------------------------------------ @@ -302,6 +332,11 @@ view=views.HpcProjectChangeRequestDeleteView.as_view(), name="hpcprojectchangerequest-delete", ), + path( + "hpcprojectchangerequest//archive/", + view=views.HpcProjectChangeRequestArchiveView.as_view(), + name="hpcprojectchangerequest-archive", + ), # ------------------------------------------------------------------------------ # HpcProjectDeleteRequest related # ------------------------------------------------------------------------------ @@ -335,6 +370,11 @@ view=views.HpcProjectDeleteRequestDeleteView.as_view(), name="hpcprojectdeleterequest-delete", ), + path( + "hpcprojectdeleterequest//archive/", + view=views.HpcProjectDeleteRequestArchiveView.as_view(), + name="hpcprojectdeleterequest-archive", + ), # ------------------------------------------------------------------------------ # HpcGroupInvitation related # ------------------------------------------------------------------------------ diff --git a/usersec/views.py b/usersec/views.py index 3a848cb..521b4b4 100644 --- a/usersec/views.py +++ b/usersec/views.py @@ -44,7 +44,11 @@ INVITATION_STATUS_REJECTED, OBJECT_STATUS_ACTIVE, REQUEST_STATUS_ACTIVE, + REQUEST_STATUS_APPROVED, + REQUEST_STATUS_ARCHIVED, + REQUEST_STATUS_DENIED, REQUEST_STATUS_RETRACTED, + REQUEST_STATUS_REVISED, REQUEST_STATUS_REVISION, TERMS_AUDIENCE_ALL, TERMS_AUDIENCE_PI, @@ -74,11 +78,8 @@ MSG_PART_SUBMITTED = "submitted" MSG_PART_UPDATE = "update" MSG_PART_UPDATED = "updated" -MSG_PART_RETRACT = "retract" -MSG_PART_RETRACTED = "retracted" -MSG_PART_REACTIVATE = "re-activate" -MSG_PART_REACTIVATED = "re-activated" MSG_PART_DELETED = "deleted" +MSG_PART_ARCHIVED = "archived" MSG_PART_GROUP_CREATION = "group creation" MSG_PART_GROUP_UPDATE = "group update" MSG_PART_GROUP_DELETION = "group deletion" @@ -104,14 +105,6 @@ MSG_TERMS_CONSENT = "Consented successfully to terms and conditions." -# ----------------------------------------------------------------------------- -# Object comments -# ----------------------------------------------------------------------------- - -COMMENT_REACTIVATED = "Request re-activated" -COMMENT_RETRACTED = "Request retracted" - - class HpcPermissionMixin(LoginRequiredMixin, PermissionRequiredMixin): """Customized required login and permission mixin.""" @@ -211,9 +204,6 @@ def form_valid(self, form): send_notification_manager_group_request(obj) send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_SUBMITTED, MSG_PART_GROUP_CREATION) - ) return HttpResponseRedirect(self.get_success_url(obj.uuid)) @@ -236,6 +226,8 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() + context["is_hpc_group_create_request"] = True return context @@ -288,33 +280,23 @@ def form_valid(self, form): ) return HttpResponseRedirect(reverse("usersec:orphan-user")) - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_UPDATED, MSG_PART_GROUP_CREATION) - ) return HttpResponseRedirect(self.get_success_url()) -class HpcGroupCreateRequestRetractView(HpcPermissionMixin, DeleteView): +class HpcGroupCreateRequestRetractView(HpcPermissionMixin, SingleObjectMixin, View): """HPC group create request update view.""" - template_name_suffix = "_retract_confirm" model = HpcGroupCreateRequest slug_field = "uuid" slug_url_kwarg = "hpcgroupcreaterequest" permission_required = "usersec.manage_hpcgroupcreaterequest" - def post(self, request, *args, **kwargs): + def get(self, request, *args, **kwargs): obj = self.get_object() - obj.comment = COMMENT_RETRACTED obj.editor = self.request.user + obj.comment = "" obj.retract_with_version() - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_RETRACTED, MSG_PART_GROUP_CREATION) - ) - return HttpResponseRedirect( reverse( "usersec:hpcgroupcreaterequest-detail", @@ -334,22 +316,14 @@ class HpcGroupCreateRequestReactivateView(HpcPermissionMixin, SingleObjectMixin, def get(self, request, *args, **kwargs): obj = self.get_object() obj.status = REQUEST_STATUS_ACTIVE - obj.comment = COMMENT_REACTIVATED obj.editor = self.request.user + obj.comment = "" obj.save_with_version() if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_REACTIVATED, MSG_PART_GROUP_CREATION) - ) - return HttpResponseRedirect( - reverse( - "usersec:hpcgroupcreaterequest-detail", - kwargs={"hpcgroupcreaterequest": obj.uuid}, - ) - ) + return HttpResponseRedirect(reverse("home")) class HpcGroupCreateRequestDeleteView(HpcPermissionMixin, DeleteView): @@ -365,6 +339,23 @@ def get_success_url(self): return reverse("home") +class HpcGroupCreateRequestArchiveView(HpcPermissionMixin, SingleObjectMixin, View): + """HPC user change request archive view.""" + + model = HpcGroupCreateRequest + slug_field = "uuid" + slug_url_kwarg = "hpcgroupcreaterequest" + permission_required = "usersec.manage_hpcgroupcreaterequest" + + def get(self, request, *args, **kwargs): + obj = self.get_object() + obj.status = REQUEST_STATUS_ARCHIVED + obj.editor = self.request.user + obj.save_with_version() + + return HttpResponseRedirect(reverse("home")) + + class HpcUserView(HpcPermissionMixin, DetailView): """HPC user overview.""" @@ -434,9 +425,16 @@ def get_requests_by_status(status): context["hpcgroupdeleterequests"] = None context["hpcuserdeleterequests"] = None context["hpcprojectdeleterequests"] = None - context["pending_requests"] = get_requests_by_status(REQUEST_STATUS_ACTIVE) - context["revision_requests"] = get_requests_by_status(REQUEST_STATUS_REVISION) - context["retracted_requests"] = get_requests_by_status(REQUEST_STATUS_RETRACTED) + context["requests"] = list( + chain( + get_requests_by_status(REQUEST_STATUS_ACTIVE), + get_requests_by_status(REQUEST_STATUS_REVISED), + get_requests_by_status(REQUEST_STATUS_REVISION), + get_requests_by_status(REQUEST_STATUS_RETRACTED), + get_requests_by_status(REQUEST_STATUS_APPROVED), + get_requests_by_status(REQUEST_STATUS_DENIED), + ) + ) context["has_pending_group_change_request"] = HpcGroupChangeRequest.objects.filter( group=group, status=REQUEST_STATUS_ACTIVE ).exists() @@ -458,19 +456,14 @@ def get_requests_by_status(status): context["pending_requests"] += list( HpcProjectChangeRequest.objects.filter( Q(project__group=group) | Q(project__delegate=context["object"]), - status=REQUEST_STATUS_ACTIVE, - ) - ) - context["revision_requests"] += list( - HpcProjectChangeRequest.objects.filter( - Q(project__group=group) | Q(project__delegate=context["object"]), - status=REQUEST_STATUS_REVISION, - ) - ) - context["retracted_requests"] += list( - HpcProjectChangeRequest.objects.filter( - Q(project__group=group) | Q(project__delegate=context["object"]), - status=REQUEST_STATUS_RETRACTED, + status__in=( + REQUEST_STATUS_ACTIVE, + REQUEST_STATUS_REVISION, + REQUEST_STATUS_REVISED, + REQUEST_STATUS_RETRACTED, + REQUEST_STATUS_APPROVED, + REQUEST_STATUS_DENIED, + ), ) ) projects_available |= context["object"].hpcproject_delegate.exists() @@ -551,9 +544,6 @@ def form_valid(self, form): if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_FAILURE.format(MSG_PART_SUBMITTED, MSG_PART_USER_CREATION) - ) return HttpResponseRedirect(reverse("home")) @@ -576,6 +566,7 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() return context @@ -630,31 +621,23 @@ def form_valid(self, form): if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_UPDATED, MSG_PART_USER_CREATION) - ) return HttpResponseRedirect(self.get_success_url()) -class HpcUserCreateRequestRetractView(HpcPermissionMixin, DeleteView): +class HpcUserCreateRequestRetractView(HpcPermissionMixin, SingleObjectMixin, View): """HPC user create request update view.""" - template_name_suffix = "_retract_confirm" model = HpcUserCreateRequest slug_field = "uuid" slug_url_kwarg = "hpcusercreaterequest" permission_required = "usersec.manage_hpcusercreaterequest" - def post(self, request, *args, **kwargs): + def get(self, request, *args, **kwargs): obj = self.get_object() - obj.comment = COMMENT_RETRACTED obj.editor = self.request.user + obj.comment = "" obj.retract_with_version() - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_RETRACTED, MSG_PART_USER_CREATION) - ) return HttpResponseRedirect( reverse( "usersec:hpcusercreaterequest-detail", @@ -674,22 +657,14 @@ class HpcUserCreateRequestReactivateView(HpcPermissionMixin, SingleObjectMixin, def get(self, request, *args, **kwargs): obj = self.get_object() obj.status = REQUEST_STATUS_ACTIVE - obj.comment = COMMENT_REACTIVATED obj.editor = self.request.user + obj.comment = "" obj.save_with_version() if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_REACTIVATED, MSG_PART_USER_CREATION) - ) - return HttpResponseRedirect( - reverse( - "usersec:hpcusercreaterequest-detail", - kwargs={"hpcusercreaterequest": obj.uuid}, - ) - ) + return HttpResponseRedirect(reverse("home")) class HpcUserCreateRequestDeleteView(HpcPermissionMixin, DeleteView): @@ -702,12 +677,26 @@ class HpcUserCreateRequestDeleteView(HpcPermissionMixin, DeleteView): permission_required = "usersec.manage_hpcusercreaterequest" def get_success_url(self): - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_DELETED, MSG_PART_USER_CREATION) - ) return reverse("home") +class HpcUserCreateRequestArchiveView(HpcPermissionMixin, SingleObjectMixin, View): + """HPC user create request archive view.""" + + model = HpcUserCreateRequest + slug_field = "uuid" + slug_url_kwarg = "hpcusercreaterequest" + permission_required = "usersec.manage_hpcusercreaterequest" + + def get(self, request, *args, **kwargs): + obj = self.get_object() + obj.status = REQUEST_STATUS_ARCHIVED + obj.editor = self.request.user + obj.save_with_version() + + return HttpResponseRedirect(reverse("home")) + + class HpcGroupDeleteRequestCreateView(View): pass @@ -732,6 +721,10 @@ class HpcGroupDeleteRequestDeleteView(View): pass +class HpcGroupDeleteRequestArchiveView(View): + pass + + class HpcGroupChangeRequestCreateView(HpcPermissionMixin, CreateView): """HPC group change request create view. @@ -767,6 +760,21 @@ def get_context_data(self, **kwargs): context.update({"group": self.get_object()}) return context + def get(self, request, *args, **kwargs): + if HpcGroupChangeRequest.objects.filter( + group=self.get_object(), + status__in=( + REQUEST_STATUS_ACTIVE, + REQUEST_STATUS_REVISION, + REQUEST_STATUS_RETRACTED, + REQUEST_STATUS_REVISED, + ), + ).exists(): + messages.error(request, "There already exists an ongoing request to create the group.") + return HttpResponseRedirect(reverse("home")) + + return super().get(request, *args, **kwargs) + def form_valid(self, form): obj = form.save(commit=False) obj.requester = self.request.user @@ -786,9 +794,6 @@ def form_valid(self, form): if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_SUBMITTED, MSG_PART_GROUP_UPDATE) - ) return HttpResponseRedirect( reverse( "usersec:hpcgroupchangerequest-detail", @@ -816,6 +821,7 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() return context @@ -867,32 +873,23 @@ def form_valid(self, form): ) return HttpResponseRedirect(reverse("home")) - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_UPDATED, MSG_PART_GROUP_UPDATE) - ) return HttpResponseRedirect(self.get_success_url()) -class HpcGroupChangeRequestRetractView(HpcPermissionMixin, DeleteView): +class HpcGroupChangeRequestRetractView(HpcPermissionMixin, SingleObjectMixin, View): """HPC group change request retract view.""" - template_name_suffix = "_retract_confirm" model = HpcGroupChangeRequest slug_field = "uuid" slug_url_kwarg = "hpcgroupchangerequest" permission_required = "usersec.manage_hpcgroupchangerequest" - def post(self, request, *args, **kwargs): + def get(self, request, *args, **kwargs): obj = self.get_object() - obj.comment = COMMENT_RETRACTED obj.editor = self.request.user + obj.comment = "" obj.retract_with_version() - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_RETRACTED, MSG_PART_GROUP_UPDATE) - ) return HttpResponseRedirect( reverse( "usersec:hpcgroupchangerequest-detail", @@ -912,22 +909,14 @@ class HpcGroupChangeRequestReactivateView(HpcPermissionMixin, SingleObjectMixin, def get(self, request, *args, **kwargs): obj = self.get_object() obj.status = REQUEST_STATUS_ACTIVE - obj.comment = COMMENT_REACTIVATED obj.editor = self.request.user + obj.comment = "" obj.save_with_version() if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_REACTIVATED, MSG_PART_GROUP_UPDATE) - ) - return HttpResponseRedirect( - reverse( - "usersec:hpcgroupchangerequest-detail", - kwargs={"hpcgroupchangerequest": obj.uuid}, - ) - ) + return HttpResponseRedirect(reverse("home")) class HpcGroupChangeRequestDeleteView(HpcPermissionMixin, DeleteView): @@ -940,12 +929,26 @@ class HpcGroupChangeRequestDeleteView(HpcPermissionMixin, DeleteView): permission_required = "usersec.manage_hpcgroupchangerequest" def get_success_url(self): - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_DELETED, MSG_PART_GROUP_UPDATE) - ) return reverse("home") +class HpcGroupChangeRequestArchiveView(HpcPermissionMixin, SingleObjectMixin, View): + """HPC group change request archive view.""" + + model = HpcGroupChangeRequest + slug_field = "uuid" + slug_url_kwarg = "hpcgroupchangerequest" + permission_required = "usersec.manage_hpcgroupchangerequest" + + def get(self, request, *args, **kwargs): + obj = self.get_object() + obj.status = REQUEST_STATUS_ARCHIVED + obj.editor = self.request.user + obj.save_with_version() + + return HttpResponseRedirect(reverse("home")) + + class HpcUserDeleteRequestCreateView(View): pass @@ -970,6 +973,10 @@ class HpcUserDeleteRequestDeleteView(View): pass +class HpcUserDeleteRequestArchiveView(View): + pass + + class HpcUserChangeRequestCreateView(HpcPermissionMixin, CreateView): """HPC user change request create view. @@ -1022,9 +1029,6 @@ def form_valid(self, form): if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_SUBMITTED, MSG_PART_USER_UPDATE) - ) return HttpResponseRedirect( reverse( "usersec:hpcuserchangerequest-detail", @@ -1052,6 +1056,7 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() return context @@ -1103,32 +1108,23 @@ def form_valid(self, form): ) return HttpResponseRedirect(reverse("home")) - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_UPDATED, MSG_PART_USER_UPDATE) - ) return HttpResponseRedirect(self.get_success_url()) -class HpcUserChangeRequestRetractView(HpcPermissionMixin, DeleteView): +class HpcUserChangeRequestRetractView(HpcPermissionMixin, SingleObjectMixin, View): """HPC user change request update view.""" - template_name_suffix = "_retract_confirm" model = HpcUserChangeRequest slug_field = "uuid" slug_url_kwarg = "hpcuserchangerequest" permission_required = "usersec.manage_hpcuserchangerequest" - def post(self, request, *args, **kwargs): + def get(self, request, *args, **kwargs): obj = self.get_object() - obj.comment = COMMENT_RETRACTED obj.editor = self.request.user + obj.comment = "" obj.retract_with_version() - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_RETRACTED, MSG_PART_USER_UPDATE) - ) return HttpResponseRedirect( reverse( "usersec:hpcuserchangerequest-detail", @@ -1148,22 +1144,14 @@ class HpcUserChangeRequestReactivateView(HpcPermissionMixin, SingleObjectMixin, def get(self, request, *args, **kwargs): obj = self.get_object() obj.status = REQUEST_STATUS_ACTIVE - obj.comment = COMMENT_REACTIVATED obj.editor = self.request.user + obj.comment = "" obj.save_with_version() if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_REACTIVATED, MSG_PART_USER_UPDATE) - ) - return HttpResponseRedirect( - reverse( - "usersec:hpcuserchangerequest-detail", - kwargs={"hpcuserchangerequest": obj.uuid}, - ) - ) + return HttpResponseRedirect(reverse("home")) class HpcUserChangeRequestDeleteView(HpcPermissionMixin, DeleteView): @@ -1176,12 +1164,26 @@ class HpcUserChangeRequestDeleteView(HpcPermissionMixin, DeleteView): permission_required = "usersec.manage_hpcuserchangerequest" def get_success_url(self): - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_DELETED, MSG_PART_USER_UPDATE) - ) return reverse("home") +class HpcUserChangeRequestArchiveView(HpcPermissionMixin, SingleObjectMixin, View): + """HPC user change request archive view.""" + + model = HpcUserChangeRequest + slug_field = "uuid" + slug_url_kwarg = "hpcuserchangerequest" + permission_required = "usersec.manage_hpcuserchangerequest" + + def get(self, request, *args, **kwargs): + obj = self.get_object() + obj.status = REQUEST_STATUS_ARCHIVED + obj.editor = self.request.user + obj.save_with_version() + + return HttpResponseRedirect(reverse("home")) + + class HpcProjectDetailView(HpcPermissionMixin, DetailView): """HPC project detail view.""" @@ -1224,7 +1226,7 @@ def get_form_kwargs(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context.update({"group": self.get_object()}) + context.update({"owner_id": self.get_object().owner.id}) return context def form_valid(self, form): @@ -1251,9 +1253,6 @@ def form_valid(self, form): send_notification_admin_request(obj) send_notification_manager_project_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_SUBMITTED, MSG_PART_PROJECT_CREATION) - ) return HttpResponseRedirect( reverse( "usersec:hpcprojectcreaterequest-detail", @@ -1281,6 +1280,7 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() return context @@ -1297,6 +1297,7 @@ class HpcProjectCreateRequestUpdateView(HpcPermissionMixin, UpdateView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["update"] = True + context["owner_id"] = self.get_object().group.owner.id return context def get_form_kwargs(self): @@ -1335,33 +1336,23 @@ def form_valid(self, form): obj.members.set(form.cleaned_data["members"]) obj.version_history.last().members.set(form.cleaned_data["members"]) - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_UPDATED, MSG_PART_PROJECT_CREATION) - ) return HttpResponseRedirect(self.get_success_url()) -class HpcProjectCreateRequestRetractView(HpcPermissionMixin, DeleteView): +class HpcProjectCreateRequestRetractView(HpcPermissionMixin, SingleObjectMixin, View): """HPC project create request update view.""" - template_name_suffix = "_retract_confirm" model = HpcProjectCreateRequest slug_field = "uuid" slug_url_kwarg = "hpcprojectcreaterequest" permission_required = "usersec.manage_hpcprojectcreaterequest" - def post(self, request, *args, **kwargs): + def get(self, request, *args, **kwargs): obj = self.get_object() - obj.comment = COMMENT_RETRACTED obj.editor = self.request.user + obj.comment = "" obj.retract_with_version() - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_RETRACTED, MSG_PART_PROJECT_CREATION) - ) - return HttpResponseRedirect( reverse( "usersec:hpcprojectcreaterequest-detail", @@ -1381,23 +1372,14 @@ class HpcProjectCreateRequestReactivateView(HpcPermissionMixin, SingleObjectMixi def get(self, request, *args, **kwargs): obj = self.get_object() obj.status = REQUEST_STATUS_ACTIVE - obj.comment = COMMENT_REACTIVATED obj.editor = self.request.user + obj.comment = "" obj.save_with_version() if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, - MSG_REQUEST_SUCCESS.format(MSG_PART_REACTIVATED, MSG_PART_PROJECT_CREATION), - ) - return HttpResponseRedirect( - reverse( - "usersec:hpcprojectcreaterequest-detail", - kwargs={"hpcprojectcreaterequest": obj.uuid}, - ) - ) + return HttpResponseRedirect(reverse("home")) class HpcProjectCreateRequestDeleteView(HpcPermissionMixin, DeleteView): @@ -1410,12 +1392,26 @@ class HpcProjectCreateRequestDeleteView(HpcPermissionMixin, DeleteView): permission_required = "usersec.manage_hpcprojectcreaterequest" def get_success_url(self): - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_DELETED, MSG_PART_PROJECT_CREATION) - ) return reverse("home") +class HpcProjectCreateRequestArchiveView(HpcPermissionMixin, SingleObjectMixin, View): + """HPC project create request archive view.""" + + model = HpcProjectCreateRequest + slug_field = "uuid" + slug_url_kwarg = "hpcprojectcreaterequest" + permission_required = "usersec.manage_hpcprojectcreaterequest" + + def get(self, request, *args, **kwargs): + obj = self.get_object() + obj.status = REQUEST_STATUS_ARCHIVED + obj.editor = self.request.user + obj.save_with_version() + + return HttpResponseRedirect(reverse("home")) + + class HpcProjectDeleteRequestCreateView(View): pass @@ -1440,6 +1436,10 @@ class HpcProjectDeleteRequestDeleteView(View): pass +class HpcProjectDeleteRequestArchiveView(View): + pass + + class HpcProjectChangeRequestCreateView(HpcPermissionMixin, CreateView): """HPC project create request create view. @@ -1450,7 +1450,7 @@ class HpcProjectChangeRequestCreateView(HpcPermissionMixin, CreateView): # Required for permission checks, usually the CreateView doesn't have the current object # available model = HpcProject - template_name = "usersec/hpcprojectchangerequest_form.html" + template_name = "usersec/hpcprojectcreaterequest_form.html" slug_field = "uuid" slug_url_kwarg = "hpcproject" # Check permission based on HpcProject object @@ -1472,7 +1472,7 @@ def get_form_kwargs(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context.update({"project": self.get_object()}) + context["owner_id"] = self.get_object().group.owner.id return context def form_valid(self, form): @@ -1498,9 +1498,6 @@ def form_valid(self, form): if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_SUBMITTED, MSG_PART_PROJECT_UPDATE) - ) return HttpResponseRedirect( reverse( "usersec:hpcprojectchangerequest-detail", @@ -1528,13 +1525,14 @@ def get_context_data(self, **kwargs): context["is_active"] = obj.is_active() context["is_revision"] = obj.is_revision() context["is_revised"] = obj.is_revised() + context["is_archived"] = obj.is_archived() return context class HpcProjectChangeRequestUpdateView(HpcPermissionMixin, UpdateView): """HPC project change request update view.""" - template_name = "usersec/hpcprojectchangerequest_form.html" + template_name = "usersec/hpcprojectcreaterequest_form.html" form_class = HpcProjectChangeRequestForm model = HpcProjectChangeRequest slug_field = "uuid" @@ -1544,7 +1542,7 @@ class HpcProjectChangeRequestUpdateView(HpcPermissionMixin, UpdateView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["update"] = True - context["project"] = self.get_object().project + context["owner_id"] = self.get_object().project.group.owner.id return context def get_form_kwargs(self): @@ -1579,32 +1577,23 @@ def form_valid(self, form): ) return HttpResponseRedirect(reverse("home")) - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_UPDATED, MSG_PART_PROJECT_UPDATE) - ) return HttpResponseRedirect(self.get_success_url()) -class HpcProjectChangeRequestRetractView(HpcPermissionMixin, DeleteView): +class HpcProjectChangeRequestRetractView(HpcPermissionMixin, SingleObjectMixin, View): """HPC project change request retract view.""" - template_name_suffix = "_retract_confirm" model = HpcProjectChangeRequest slug_field = "uuid" slug_url_kwarg = "hpcprojectchangerequest" permission_required = "usersec.manage_hpcprojectchangerequest" - def post(self, request, *args, **kwargs): + def get(self, request, *args, **kwargs): obj = self.get_object() - obj.comment = COMMENT_RETRACTED obj.editor = self.request.user + obj.comment = "" obj.retract_with_version() - # No email notification required - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_RETRACTED, MSG_PART_PROJECT_UPDATE) - ) return HttpResponseRedirect( reverse( "usersec:hpcprojectchangerequest-detail", @@ -1624,22 +1613,14 @@ class HpcProjectChangeRequestReactivateView(HpcPermissionMixin, SingleObjectMixi def get(self, request, *args, **kwargs): obj = self.get_object() obj.status = REQUEST_STATUS_ACTIVE - obj.comment = COMMENT_REACTIVATED obj.editor = self.request.user + obj.comment = "" obj.save_with_version() if settings.SEND_EMAIL: send_notification_admin_request(obj) - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_REACTIVATED, MSG_PART_PROJECT_UPDATE) - ) - return HttpResponseRedirect( - reverse( - "usersec:hpcprojectchangerequest-detail", - kwargs={"hpcprojectchangerequest": obj.uuid}, - ) - ) + return HttpResponseRedirect(reverse("home")) class HpcProjectChangeRequestDeleteView(HpcPermissionMixin, DeleteView): @@ -1652,12 +1633,26 @@ class HpcProjectChangeRequestDeleteView(HpcPermissionMixin, DeleteView): permission_required = "usersec.manage_hpcprojectchangerequest" def get_success_url(self): - messages.success( - self.request, MSG_REQUEST_SUCCESS.format(MSG_PART_DELETED, MSG_PART_PROJECT_UPDATE) - ) return reverse("home") +class HpcProjectChangeRequestArchiveView(HpcPermissionMixin, SingleObjectMixin, View): + """HPC project change request archive view.""" + + model = HpcProjectChangeRequest + slug_field = "uuid" + slug_url_kwarg = "hpcprojectchangerequest" + permission_required = "usersec.manage_hpcprojectchangerequest" + + def get(self, request, *args, **kwargs): + obj = self.get_object() + obj.status = REQUEST_STATUS_ARCHIVED + obj.editor = self.request.user + obj.save_with_version() + + return HttpResponseRedirect(reverse("home")) + + class HpcGroupInvitationDetailView(HpcPermissionMixin, DetailView): """HPC group invitation detail view.""" @@ -1728,7 +1723,6 @@ def get(self, request, *args, **kwargs): send_notification_manager_user_decided_invitation(obj) send_notification_user_welcome_mail(hpcuser) - messages.success(request, MSG_INVITATION_GROUP_USER_CREATE_SUCCESS) return HttpResponseRedirect( reverse( "usersec:hpcuser-overview", @@ -1753,7 +1747,6 @@ def post(self, request, *args, **kwargs): if settings.SEND_EMAIL: send_notification_manager_user_decided_invitation(obj) - messages.success(request, MSG_INVITATION_REJECTED_SUCCESS) return HttpResponseRedirect( reverse( "usersec:hpcgroupinvitation-detail", @@ -1801,7 +1794,6 @@ def get(self, request, *args, **kwargs): if settings.SEND_EMAIL: send_notification_manager_user_decided_invitation(obj) - messages.success(request, MSG_INVITATION_PROJECT_USER_ADD_SUCCESS) return HttpResponseRedirect( reverse( "usersec:hpcuser-overview", @@ -1826,7 +1818,6 @@ def post(self, request, *args, **kwargs): if settings.SEND_EMAIL: send_notification_manager_user_decided_invitation(obj) - messages.success(self.request, MSG_INVITATION_REJECTED_SUCCESS) return HttpResponseRedirect( reverse( "usersec:hpcuser-overview", @@ -1857,5 +1848,4 @@ def post(self, request, *args, **kwargs): request.user.consented_to_terms = True request.user.save() - messages.success(self.request, MSG_TERMS_CONSENT) return HttpResponseRedirect(reverse("home"))