diff --git a/.github/workflows/ecep-cms.yml b/.github/workflows/ecep-cms.yml new file mode 100644 index 00000000..1e0127a1 --- /dev/null +++ b/.github/workflows/ecep-cms.yml @@ -0,0 +1,41 @@ +name: ECEP CMS Builds +on: + workflow_dispatch: + push: + branches: [ main ] + paths: + - 'ecep_cms/**' + +jobs: + build_commit: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ecep_cms + steps: + - uses: actions/checkout@v2 + - name: Get shortsha + id: vars + run: | + if [ -z "$EVENT_SHA" ]; then SHORT_SHA=${GITHUB_SHA::8}; else SHORT_SHA=${EVENT_SHA::8}; fi + echo ::set-output name=sha_short::${SHORT_SHA} + env: + EVENT_SHA: ${{ github.event.client_payload.sha }} + - name: Print shortsha + run: | + echo $SHORTSHA + env: + SHORTSHA: ${{ steps.vars.outputs.sha_short }} + - uses: docker/setup-buildx-action@v2 + name: Setup Docker Builds + - uses: docker/login-action@v2 + name: Log in to docker + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - uses: docker/build-push-action@v3 + name: Build & push commit tagged Docker image + with: + context: ecep_cms + push: true + tags: taccwma/ecep-cms:${{ steps.vars.outputs.sha_short }} diff --git a/README.md b/README.md index 1d8084c7..936d3cfc 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Set up a new local CMS instance. 0. Core CMS: - In the `custom_project_dir/` you will run, create a `settings_local.py` with content from [Core-CMS `settings_local.example.py`](https://github.com/TACC/Core-CMS/blob/main/taccsite_cms/settings_local.example.py). + In the `/custom_project_dir/` you will run, create a `./src/taccsite_cms/settings_local.py` with content from [Core-CMS `settings_local.example.py`](https://github.com/TACC/Core-CMS/blob/main/taccsite_cms/settings_local.example.py). 1. Docker Containers: @@ -78,13 +78,10 @@ Set up a new local CMS instance. # To use default "Username" and skip "Email address", press Enter at both prompts. # At "Password" prompts, you may use an easy-to-remember password. python manage.py collectstatic --no-input - # If the project has no static assets, - # (and you have not set up other projects) - # then expect output of "0 static files […]" ``` 3. Django CMS: - 1. Open http://0.0.0.0:8000/. + 1. Open http://localhost:8000/. 2. Login with the credentials you defined in step 2. 3. Create one CMS page.\ (With "New page" highlighted, click "Next" button.) @@ -116,6 +113,8 @@ Update an existing local CMS instance. # That opens a command prompt within the container. python manage.py migrate python manage.py collectstatic --no-input + # If the project has no new/changed assets, + # then expect output of "0 static files […]" ``` [^1]: Pertinent changes are those in the Core CMS or the custom project. Changes to external assets or databases are not pertinent. diff --git a/apcd-cms/README.md b/apcd-cms/README.md index bc383d1d..f3f3b886 100644 --- a/apcd-cms/README.md +++ b/apcd-cms/README.md @@ -6,4 +6,4 @@ An extension of the [Core CMS](https://github.com/TACC/Core-CMS) project ## Basics -See [Core-CMS-Custom](https://github.com/TACC/Core-CMS-Custom#readme). +See [Core-CMS-Custom](../README.md). diff --git a/apcd-cms/src/apps/admin_exception/static/admin_exception/css/modal.css b/apcd-cms/src/apps/admin_exception/static/admin_exception/css/modal.css index fa9f4ea1..74d55342 100644 --- a/apcd-cms/src/apps/admin_exception/static/admin_exception/css/modal.css +++ b/apcd-cms/src/apps/admin_exception/static/admin_exception/css/modal.css @@ -1,7 +1,30 @@ +.title { + margin-top: 0; +} + +.modal-section { + width: 100%; +} + +dl { + display: flex; + flex-flow: row wrap; + padding-left: 0; + } + dt { flex-basis: 25%; + padding: 0; } dd { flex-basis: 75%; -} \ No newline at end of file + margin: 0; + padding: 0; +} +/* Necessary so dl keys display fully */ +.modal-body { + padding: 2rem; + font-size: var(--global-font-size--small); + font-family: var(--global-font-family--sans--portal); +} diff --git a/apcd-cms/src/apps/admin_exception/static/admin_exception/css/table.css b/apcd-cms/src/apps/admin_exception/static/admin_exception/css/table.css new file mode 100644 index 00000000..dbb94a2a --- /dev/null +++ b/apcd-cms/src/apps/admin_exception/static/admin_exception/css/table.css @@ -0,0 +1,16 @@ +.modal-cell { + padding-left: 0px; +} +/* SEE: https://css-tricks.com/responsive-data-tables/ */ +@media (max-width: 767px) { + + /* To label the cells */ + /* RFE: Add `data-label` to each cell so we can use `attr(data-label)` */ + .exception-table td:nth-of-type(1):before { content: "Created"; } + .exception-table td:nth-of-type(2):before { content: "Organization"; } + .exception-table td:nth-of-type(3):before { content: "Requestor Name"; } + .exception-table td:nth-of-type(4):before { content: "Exception Type"; } + .exception-table td:nth-of-type(5):before { content: "Outcome"; } + .exception-table td:nth-of-type(6):before { content: "Status"; } + .exception-table td:nth-of-type(7):before { content: "Actions"; } +} diff --git a/apcd-cms/src/apps/admin_exception/templates/edit_exception_error.html b/apcd-cms/src/apps/admin_exception/templates/edit_exception_error.html new file mode 100644 index 00000000..61e62734 --- /dev/null +++ b/apcd-cms/src/apps/admin_exception/templates/edit_exception_error.html @@ -0,0 +1,16 @@ +{% extends "standard.html" %} +{% block content %} + +{% include 'snippets/tup-175-css-alerts-messages-ui-pattern.html' %} + +
+ {% include "nav_cms_breadcrumbs.html" %} + +

Edit Exception

+
+

+ An error occurred while updating this Exception. For help, submit a ticket. +

+ Back to List Exceptions +
+{% endblock %} \ No newline at end of file diff --git a/apcd-cms/src/apps/admin_exception/templates/edit_exception_modal.html b/apcd-cms/src/apps/admin_exception/templates/edit_exception_modal.html new file mode 100644 index 00000000..5a938335 --- /dev/null +++ b/apcd-cms/src/apps/admin_exception/templates/edit_exception_modal.html @@ -0,0 +1,127 @@ +{% load static %} + + + diff --git a/apcd-cms/src/apps/admin_exception/templates/edit_exception_success.html b/apcd-cms/src/apps/admin_exception/templates/edit_exception_success.html new file mode 100644 index 00000000..e92c77a9 --- /dev/null +++ b/apcd-cms/src/apps/admin_exception/templates/edit_exception_success.html @@ -0,0 +1,13 @@ +{% extends "standard.html" %} +{% block content %} +
+ {% include "nav_cms_breadcrumbs.html" %} + +

Edit Exception

+
+

+ Updating this exception was successful. +

+ Back to List Exceptions +
+{% endblock %} diff --git a/apcd-cms/src/apps/admin_exception/templates/list_admin_exception.html b/apcd-cms/src/apps/admin_exception/templates/list_admin_exception.html index 1b88120b..90a3a9f4 100644 --- a/apcd-cms/src/apps/admin_exception/templates/list_admin_exception.html +++ b/apcd-cms/src/apps/admin_exception/templates/list_admin_exception.html @@ -2,22 +2,36 @@ {% load static %} {% block content %} - - - - - - - +
{% include "nav_cms_breadcrumbs.html" %}

View Exception Requests


All submitted exception requests

-
- +
+
+
+ Filter by Status: + + Filter by Organization: + + {% if selected_status or selected_org %} + + {% endif %} +
+
+
{% for k in header %} @@ -28,44 +42,84 @@

View Exception Requests

{% for r in page %} - - - - - - - + + + + + + - + {% include "edit_exception_modal.html" %} + + + {% endfor %}
{{r.created_at}}{{r.org_name}} - {{r.submitter_id}}{{r.requestor_name}}{{r.request_type}}{{r.outcome}}{{r.status}} + + {{r.created_at}}{{r.org_name}}{{r.requestor_name}}{{r.request_type}}{{r.outcome}}{{r.status}}
+ {% include 'paginator.html' %} +
+ {% endblock %} diff --git a/apcd-cms/src/apps/admin_exception/templates/view_admin_exception_modal.html b/apcd-cms/src/apps/admin_exception/templates/view_admin_exception_modal.html index b2a1c888..a67d1791 100644 --- a/apcd-cms/src/apps/admin_exception/templates/view_admin_exception_modal.html +++ b/apcd-cms/src/apps/admin_exception/templates/view_admin_exception_modal.html @@ -1,3 +1,6 @@ +{% load static %} + + diff --git a/apcd-cms/src/apps/admin_exception/urls.py b/apcd-cms/src/apps/admin_exception/urls.py index a0c72632..966b219f 100644 --- a/apcd-cms/src/apps/admin_exception/urls.py +++ b/apcd-cms/src/apps/admin_exception/urls.py @@ -3,5 +3,8 @@ app_name = 'admin_exception' urlpatterns = [ - path('list-exceptions/', AdminExceptionsTable.as_view(), name="admin_exceptions"), + path('list-exceptions/', AdminExceptionsTable.as_view(), name="list_exceptions"), + path('list-exceptions/', AdminExceptionsTable.as_view(), name='status'), + path('list-exceptions/', AdminExceptionsTable.as_view(), name='org'), + path('list-exceptions/', AdminExceptionsTable.as_view(), name='status_org') ] diff --git a/apcd-cms/src/apps/admin_exception/views.py b/apcd-cms/src/apps/admin_exception/views.py index 7c8ee80f..96ec601b 100644 --- a/apcd-cms/src/apps/admin_exception/views.py +++ b/apcd-cms/src/apps/admin_exception/views.py @@ -1,9 +1,13 @@ -from django.http import HttpResponseRedirect +from django.http import HttpResponseRedirect, HttpResponse from django.core.paginator import Paginator, EmptyPage from django.views.generic.base import TemplateView -from apps.utils.apcd_database import get_all_exceptions +from django.template import loader +from apps.utils.apcd_database import get_all_exceptions, update_exception from apps.utils.apcd_groups import is_apcd_admin from apps.utils.utils import title_case +from apps.utils.utils import table_filter +from apps.components.paginator.paginator import paginator +from dateutil import parser import logging logger = logging.getLogger(__name__) @@ -11,6 +15,32 @@ class AdminExceptionsTable(TemplateView): template_name = 'list_admin_exception.html' + def post(self, request): + + form = request.POST.copy() + + def _err_msg(resp): + if hasattr(resp, 'pgerror'): + return resp.pgerror + if isinstance(resp, Exception): + return str(resp) + return None + + def _edit_exception(form): + errors = [] + exception_response = update_exception(form) + if _err_msg(exception_response): + errors.append(_err_msg(exception_response)) + if len(errors) != 0: + logger.debug(print(errors)) + template = loader.get_template('edit_exception_error.html') + else: + logger.debug(print("success")) + template = loader.get_template('edit_exception_success.html') + return template + + template = _edit_exception(form) + return HttpResponse(template.render({}, request)) def dispatch(self, request, *args, **kwargs): if not request.user.is_authenticated or not is_apcd_admin(request.user): @@ -22,15 +52,24 @@ def get_context_data(self, *args, **kwargs): context = super(AdminExceptionsTable, self).get_context_data(*args, **kwargs) exception_content = get_all_exceptions() + # To get filters from params + queryStr = '' + status_filter = self.request.GET.get('status') + org_filter = self.request.GET.get('org') + + try: + page_num = int(self.request.GET.get('page')) + except: + page_num = 1 def _set_exceptions(exception): return { 'exception_id': exception[0], 'submitter_id': exception[1], 'requestor_name': exception[2], - 'request_type': title_case(exception[3]), + 'request_type': title_case(exception[3]) if exception[3] else None, # to make sure if val doesn't exist, utils don't break page 'explanation_justification': exception[4], - 'outcome': title_case(exception[5]), + 'outcome': title_case(exception[5]) if exception[3] else None, 'created_at': exception[6], 'updated_at': exception[7], 'submitter_code': exception[8], @@ -44,32 +83,63 @@ def _set_exceptions(exception): 'requested_expiration_date': exception[16], 'approved_threshold': exception[17], 'approved_expiration_date': exception[18], - 'status': title_case(exception[19]), + 'status': title_case(exception[19])if exception[3] else None, 'notes': exception[20], 'org_name': exception[21], 'data_file_name': exception[22] } - context['header'] = ['Created', 'Organization', 'Requestor Name', 'Request Type', 'Outcome', 'Status', 'Actions'] - exceptions = [] + context['header'] = ['Created', 'Organization', 'Requestor Name', 'Exception Type', 'Outcome', 'Status', 'Actions'] + context['status_options'] = ['All'] + context['org_options'] = ['All'] + context['outcome_options'] = [] + # In case you need to access an exception directly within the template in the future + context['exceptions'] = [] - for exception in exception_content: - exceptions.append(_set_exceptions(exception)) + def getDate(row): + date = row[1] + return date if date is not None else parser.parse('1-1-0001') - try: - page_num = int(self.request.GET.get('page')) - except: - page_num = 1 + # sort exceptions by newest to oldest + exception_content = sorted(exception_content, key=lambda row:getDate(row), reverse=True) + + exception_table_entries = [] + for exception in exception_content: + # to be used by paginator + exception_table_entries.append(_set_exceptions(exception)) + # to be able to access any exception in a template using exceptions var in the future + context['exceptions'].append(_set_exceptions(exception)) + org_name = title_case(exception[21]) + status = title_case(exception[19]) + outcome = title_case(exception[5]) + if org_name not in context['org_options']: + context['org_options'].append(org_name) + # to make sure All is first in the dropdown filter options after sorting alphabetically + context['org_options'] = sorted(context['org_options'], key=lambda x: (x != 'All', x)) + if status not in context['status_options']: + if status != None: + context['status_options'].append(status) + # to make sure All is first in the dropdown filter options after sorting alphabetically + context['status_options'] = sorted(context['status_options'], key=lambda x: (x != 'All', x)) + if outcome not in context['outcome_options']: + if outcome != None: + context['outcome_options'].append(outcome) + context['outcome_options'] = sorted(context['outcome_options']) - p = Paginator(exceptions, 10) + context['selected_status'] = None + if status_filter is not None and status_filter != 'All': + context['selected_status'] = status_filter + queryStr += f'&status={status_filter}' + exception_table_entries = table_filter(status_filter, exception_table_entries, 'status') - try: - page = p.page(page_num) - except EmptyPage: - page = p.page(1) + context['selected_org'] = None + if org_filter is not None and org_filter != 'All': + context['selected_org'] = org_filter + queryStr += f'&org={org_filter}' + exception_table_entries = table_filter(org_filter.replace("(", "").replace(")",""), exception_table_entries, 'org_name') - context['page'] = page - context['page_num'] = int(page_num) - context['num_pages'] = range(1, p.num_pages + 1) + context['query_str'] = queryStr + context.update(paginator(self.request, exception_table_entries)) + context['pagination_url_namespaces'] = 'admin_exception:list_exceptions' return context diff --git a/apcd-cms/src/apps/admin_extension/static/admin_extension/css/modal.css b/apcd-cms/src/apps/admin_extension/static/admin_extension/css/modal.css index 60a1d827..b09a8bd0 100644 --- a/apcd-cms/src/apps/admin_extension/static/admin_extension/css/modal.css +++ b/apcd-cms/src/apps/admin_extension/static/admin_extension/css/modal.css @@ -1,11 +1,30 @@ +.title { + margin-top: 0; +} + +.modal-section { + width: 100%; +} + +dl { + display: flex; + flex-flow: row wrap; + padding-left: 0; + } + dt { flex-basis: 25%; + padding: 0; } dd { flex-basis: 75%; + margin: 0; + padding: 0; } - -.modal-content { - height: 550px; +/* Necessary so dl keys display fully */ +.modal-body { + padding: 2rem; + font-size: var(--global-font-size--small); + font-family: var(--global-font-family--sans--portal); } \ No newline at end of file diff --git a/apcd-cms/src/apps/admin_extension/static/admin_extension/css/table.css b/apcd-cms/src/apps/admin_extension/static/admin_extension/css/table.css new file mode 100644 index 00000000..f55f0b3d --- /dev/null +++ b/apcd-cms/src/apps/admin_extension/static/admin_extension/css/table.css @@ -0,0 +1,16 @@ +.modal-cell { + padding-left: 0px; +} +/* SEE: https://css-tricks.com/responsive-data-tables/ */ +@media (max-width: 767px) { + /* To label the cells */ + /* RFE: Add `data-label` to each cell so we can use `attr(data-label)` */ + .extension-table td:nth-of-type(1):before { content: "Created"; } + .extension-table td:nth-of-type(2):before { content: "Organization"; } + .extension-table td:nth-of-type(3):before { content: "Requestor Name"; } + .extension-table td:nth-of-type(4):before { content: "Extension Type"; } + .extension-table td:nth-of-type(5):before { content: "Outcome"; } + .extension-table td:nth-of-type(6):before { content: "Status"; } + .extension-table td:nth-of-type(7):before { content: "Approved Expiration"; } + .extension-table td:nth-of-type(8):before { content: "Actions"; } +} diff --git a/apcd-cms/src/apps/admin_extension/templates/edit_extension_error.html b/apcd-cms/src/apps/admin_extension/templates/edit_extension_error.html new file mode 100644 index 00000000..3d22ef07 --- /dev/null +++ b/apcd-cms/src/apps/admin_extension/templates/edit_extension_error.html @@ -0,0 +1,16 @@ +{% extends "standard.html" %} +{% block content %} + +{% include 'snippets/tup-175-css-alerts-messages-ui-pattern.html' %} + +
+ {% include "nav_cms_breadcrumbs.html" %} + +

Edit Extension

+
+

+ An error occurred while updating this Extension. For help, submit a ticket. +

+ Back to List Extensions +
+{% endblock %} diff --git a/apcd-cms/src/apps/admin_extension/templates/edit_extension_modal.html b/apcd-cms/src/apps/admin_extension/templates/edit_extension_modal.html new file mode 100644 index 00000000..251b7e9e --- /dev/null +++ b/apcd-cms/src/apps/admin_extension/templates/edit_extension_modal.html @@ -0,0 +1,121 @@ +{% load static %} + + + + + + diff --git a/apcd-cms/src/apps/admin_extension/templates/edit_extension_success.html b/apcd-cms/src/apps/admin_extension/templates/edit_extension_success.html new file mode 100644 index 00000000..a6a18c5b --- /dev/null +++ b/apcd-cms/src/apps/admin_extension/templates/edit_extension_success.html @@ -0,0 +1,13 @@ +{% extends "standard.html" %} +{% block content %} +
+ {% include "nav_cms_breadcrumbs.html" %} + +

Edit Extension

+
+

+ Updating this extension was successful. +

+ Back to List Extensions +
+{% endblock %} diff --git a/apcd-cms/src/apps/admin_extension/templates/list_admin_extension.html b/apcd-cms/src/apps/admin_extension/templates/list_admin_extension.html index bc6914d4..94372e46 100644 --- a/apcd-cms/src/apps/admin_extension/templates/list_admin_extension.html +++ b/apcd-cms/src/apps/admin_extension/templates/list_admin_extension.html @@ -2,22 +2,36 @@ {% load static %} {% block content %} - - - - - - +
{% include "nav_cms_breadcrumbs.html" %}

View Extension Requests

-

All submitted extension requests


- +
+
+ Filter by Status: + + Filter by Organization: + + {% if selected_status or selected_org %} + + {% endif %} +
+
+
{% for k in header %} @@ -25,47 +39,86 @@

View Extension Requests

{% endfor %} - - {% for r in page %} + + {% for r in page %} - - - - - - - - + + + + + + + + + {% endfor %}
{{r.created_at}}{{r.org_name}} - {{r.submitter_id}}{{r.requestor_name}}{{r.extension_type}}{{r.outcome}}{{r.status}} - {% include "view_admin_extension_modal.html" %} - View Details -
{{r.created_at}}{{r.org_name}} - {{r.submitter_id}}{{r.requestor_name}}{{r.extension_type}}{{r.outcome}}{{r.status}}{{r.approved_expiration_date}}
- - + {% include 'paginator.html' %}
+ {% endblock %} \ No newline at end of file diff --git a/apcd-cms/src/apps/admin_extension/templates/view_admin_extension_modal.html b/apcd-cms/src/apps/admin_extension/templates/view_admin_extension_modal.html index 41153ee8..b5fdf742 100644 --- a/apcd-cms/src/apps/admin_extension/templates/view_admin_extension_modal.html +++ b/apcd-cms/src/apps/admin_extension/templates/view_admin_extension_modal.html @@ -1,10 +1,13 @@ +{% load static %} + +
Submission Dates ${extension}
-
12/05/2023
+
12/31/2023
-
12-05-2023
+
12/31/2023
diff --git a/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_body.html b/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_body.html index 26a4fb05..60d592f3 100644 --- a/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_body.html +++ b/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_body.html @@ -236,210 +236,213 @@ {% if r.view_modal_content %}

Entity/Entities Being Registered

{% for entity in r.view_modal_content.entities %} -
Entity {{ forloop.counter }}
- -
- - - - - -
-
- -
- Provide all available identifiers. At least one of the following - is required. -
-
- -
-
+ {% with forloop.counter as ent_no %} + +
Entity {{ ent_no }}
+
+
- + +
+
+ +
+ Provide all available identifiers. At least one of the following + is required. +
+
-
- Enter in format 12-3456789. +
+
+ + + + + + +
+ Enter in format 12-3456789. +
-
-
- +
+ - + - + -
- Enter digits only. +
+ Enter digits only. +
-
-
- +
+ - + - + -
- Enter digits only. +
+ Enter digits only. +
+
+
+
File Submission
+
+ +
+ Eligibility/Enrollment files are mandatory. Select additional file types to be submitted. +
-
-
-
File Submission
-
- -
- Eligibility/Enrollment files are mandatory. Select additional file types to be submitted. -
-
-
- +
+ -
    -
  • - -
  • - {% for file_type, file_type_selected in r.view_modal_content.entities.files_type.items %} - {% if not forloop.first %} -
  • -
  • + + type="checkbox" + name="types_of_files_eligibility_enrollment_{{ent_no}}_{{r.reg_id}}" + required + id="types_of_files_eligibility_enrollment_{{ent_no}}_{{r.reg_id}}" + checked="" + disabled + />Eligibility/Enrollment*
  • - {% endif %} - {% endfor %} -
-
+ {% for file_type, file_type_selected in entity.files_type.items %} + {% if not forloop.first %} +
  • + +
  • + {% endif %} + {% endfor %} + +
    -
    - Coverage Estimates - (Inclusive of all claims as of December 31 of previous - year.) -
    +
    + Coverage Estimates + (Inclusive of all claims as of December 31 of previous + year.) +
    -
    - +
    + - + - -
    + +
    -
    - +
    + - + - -
    + +
    -
    - +
    + - + - $ - + $ + +
    + {% endwith %} {% endfor %} {# Additional entities rendered here... #} {% with r.view_modal_content.entities|length as no_entities %} diff --git a/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_scripts.html b/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_scripts.html index 1fafce86..6c368bcb 100644 --- a/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_scripts.html +++ b/apcd-cms/src/apps/registrations/templates/submission_form/registration_form_scripts.html @@ -11,12 +11,12 @@ {# To require at least one "entity" identifier value #} -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/apcd-cms/src/apps/view_users/views.py b/apcd-cms/src/apps/view_users/views.py index 008ce565..d1549127 100644 --- a/apcd-cms/src/apps/view_users/views.py +++ b/apcd-cms/src/apps/view_users/views.py @@ -1,6 +1,8 @@ -from django.http import HttpResponseRedirect +from django.http import HttpResponseRedirect, HttpResponse, JsonResponse +from django.core.paginator import Paginator, EmptyPage from django.views.generic.base import TemplateView -from apps.utils.apcd_database import get_users +from django.template import loader +from apps.utils.apcd_database import get_users, update_user from apps.utils.apcd_groups import is_apcd_admin from apps.utils.utils import table_filter from apps.components.paginator.paginator import paginator @@ -10,6 +12,42 @@ class ViewUsersTable(TemplateView): template_name = 'view_users.html' + ##FORM FUNCTION + def post(self, request): + + form = request.POST.copy() + + def _err_msg(resp): + if hasattr(resp, 'pgerror'): + return resp.pgerror + if isinstance(resp, Exception): + return str(resp) + return None + + def _edit_user(form): + errors = [] + user_response = update_user(form) + if _err_msg(user_response): + errors.append(_err_msg(user_response)) + if len(errors) != 0: + logger.debug(print(errors)) + template = loader.get_template('view_user_edit_error.html') + else: + logger.debug(print("success")) + template = loader.get_template('view_user_edit_success.html') + return template + + template = _edit_user(form) + return HttpResponse(template.render({}, request)) + def get(self, request, *args, **kwargs): + user_content = get_users() + + + context = self.get_context_data(user_content, *args,**kwargs) + template = loader.get_template(self.template_name) + return HttpResponse(template.render(context, request)) + ##END FORM FUNCTION + user_content = get_users() def dispatch(self, request, *args, **kwargs): @@ -30,15 +68,31 @@ def _set_user(usr): 'created_at': usr[5], 'updated_at': usr[6], 'notes': usr[7], - 'active': 'Active' if usr[8] else 'Inactive', + 'status': 'Active' if usr[8] else 'Inactive', 'user_number': usr[9], 'role_name': usr[10], 'org_name_no_parens': usr[4].replace("(", "").replace(")", ""), # just for filtering purposes + 'active': usr[8], } - context['header'] = ['User ID', 'Name', 'Organization', 'Role', 'Status', 'User Number', 'See More'] + context['status_options'] = ['All', 'Active', 'Inactive'] context['filter_options'] = ['All'] + context['role_options'] = ['SUBMITTER_USER', 'SUBMITTER_ADMIN','APCD_ADMIN'] + + context['status'] = ['Active', 'Inactive'] + + # this kind of sucks, we should make this not hard coded, just getting it to work for now + context['roles'] = [ + {'role_id': 1, 'role_name': 'APCD_ADMIN'}, + {'role_id': 2, 'role_name': 'SUBMITTER_ADMIN'}, + {'role_id': 3, 'role_name': 'SUBMITTER_USER'} + ] + + try: + page_num = int(self.request.GET.get('page')) + except: + page_num = 1 table_entries = [] for user in user_content: table_entries.append(_set_user(user,)) @@ -46,13 +100,28 @@ def _set_user(usr): if org_name not in context['filter_options']: # prevent duplicates context['filter_options'].append(user[4]) - filter = self.request.GET.get('filter') + queryStr = '' + status_filter = self.request.GET.get('status') + org_filter = self.request.GET.get('org') + role_filter = self.request.GET.get('role_name') + + context['selected_status'] = None + if status_filter is not None and status_filter !='All': + context['selected_status'] = status_filter + queryStr += f'&status={status_filter}' + table_entries = table_filter(status_filter, table_entries, 'status', False) + + if role_filter is not None and role_filter !='All': + context['selected_role'] = role_filter + table_entries = table_filter(role_filter, table_entries, 'role_name', False) - context['selected_filter'] = None - if filter is not None and filter != 'All': - context['selected_filter'] = filter - table_entries = table_filter(filter.replace("(", "").replace(")",""), table_entries, 'org_name_no_parens') + context['selected_org'] = None + if org_filter is not None and org_filter != 'All': + context['selected_org'] = org_filter + queryStr += f'&org={org_filter}' + table_entries = table_filter(org_filter.replace("(", "").replace(")",""), table_entries, 'org_name_no_parens') + context['query_str'] = queryStr context.update(paginator(self.request, table_entries)) context['pagination_url_namespaces'] = 'administration:view_users' diff --git a/demdata_cms/README.md b/demdata_cms/README.md index baff71ba..e4e66e71 100644 --- a/demdata_cms/README.md +++ b/demdata_cms/README.md @@ -6,4 +6,4 @@ An extension of the [Core CMS](https://github.com/TACC/Core-CMS) project ## Basics -See [Core-CMS-Custom](https://github.com/TACC/Core-CMS-Custom#readme). +See [Core-CMS-Custom](../README.md). diff --git a/docs/port-project.md b/docs/port-project.md index 47cdc4f2..695731b2 100644 --- a/docs/port-project.md +++ b/docs/port-project.md @@ -22,7 +22,7 @@ Follow steps in [Create a New Project](./develop-project.md#create-a-new-project
    Reminders -1. From [Core CMS Resources] `/taccsite_custom/custom-project-dir`. +1. From [Core CMS Resources] `/taccsite_custom/custom_project_dir`. To `/custom_project_dir/src/taccsite_custom/custom_project_dir`. 2. From `/taccsite_custom/custom_project_dir/settings_custom.py`. @@ -44,21 +44,30 @@ Follow steps in [Create a New Project](./develop-project.md#create-a-new-project Then: -1. Copy the templates to become placeholders: +1. Copy the templates to become deprecated templates: - from `taccsite_custom/custom_project_dir/templates` - to `taccsite_custom/custom-project-dir/templates` > **Warning** - > The name `custom-project-dir` **must** match the old name as it was, including dashes. -2. Edit the placeholder templates to extend the new templates e.g. + > The name `custom_project_dir` **must** match the old name as it was, including dashes. +2. Edit the deprecated templates to extend the new templates e.g. ```django {% extends "custom_project_dir/templates/standard.html" %} ``` +3. Update `settings_custom.py` to support deprecated templates: + + ```diff + ('custom_project_dir/templates/standard.html', 'Standard'), + ('custom_project_dir/templates/fullwidth.html', 'Full Width'), + + ('custom-project-dir/templates/standard.html', 'DEPRECATED Standard'), + + ('custom-project-dir/templates/fullwidth.html', 'DEPRECATED Full Width'), + ``` + #### Expects CSS Build Step -**If** the custom project directory expects CSS compilation e.g. has +**If** the custom project directory expects CSS build step e.g. has - `css/src/*.css` with `@import` of a `@tacc/core-styles/` path @@ -88,7 +97,23 @@ Then: - to `/static/site_cms/css/build/*.css` 2. Rename relative import paths (e.g. `./**/*.css`): - from `**/*.css` - - to `/static/custom_project_dir/css/build/*.css` + - to `/static/custom_project_dir/css/**/*.css` +3. Add UI test steps to initial deploy of ported custom project. + +#### Expects CSS + +**If** the custom project directory expects any CSS at all i.e. has + +- a template with `