Skip to content

Commit

Permalink
task/WP-149: Upgrade APCD CMS to Django 4.2 (#277)
Browse files Browse the repository at this point in the history
* Update Core-CMS image to v4.5.0 (grab Django 4.2+ update)

* Admin registrations table apps.py misconfigured

* Fix app name in config for admin registrations listing

* Update local dev postgres version

* Update app config names so Django can find them - prepend 'apps.' to each

* Update admin registrations listing namespace

* Update static load in custom template

* Add app config for login app

* Convert to psycopg from psycopg2 for db connections

* Rename taccsite_custom/apcd-cms to taccsite_custom/apcd_cms to match Core-CMS v3.12+ requirements

---------

Co-authored-by: Garrett Edmonds <[email protected]>
  • Loading branch information
edmondsgarrett and Garrett Edmonds authored Mar 13, 2024
1 parent f95f346 commit f0111e8
Show file tree
Hide file tree
Showing 29 changed files with 59 additions and 51 deletions.
4 changes: 2 additions & 2 deletions apcd-cms/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TACC/Core-CMS#v3.11.6
FROM taccwma/core-cms:c5bea4c
# TACC/Core-CMS#v4.5.0
FROM taccwma/core-cms:5473db7

WORKDIR /code

Expand Down
2 changes: 1 addition & 1 deletion apcd-cms/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
- core_cms_net

postgres:
image: postgres:11.5
image: postgres:14.9
environment:
- POSTGRES_PASSWORD=taccforever
- POSTGRES_USER=postgresadmin
Expand Down
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/admin_exception/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.apps import AppConfig

class AdminExceptionConfig(AppConfig):
name = 'admin_exception'
name = 'apps.admin_exception'
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/admin_extension/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.apps import AppConfig

class AdminExtensionConfig(AppConfig):
name = 'admin_extension'
name = 'apps.admin_extension'
4 changes: 2 additions & 2 deletions apcd-cms/src/apps/admin_regis_table/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.apps import AppConfig


class CustomExampleConfig(AppConfig):
name = 'custom_example'
class AdminRegConfig(AppConfig):
name = 'apps.admin_regis_table'
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/admin_regis_table/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import path
from apps.admin_regis_table.views import RegistrationsTable

app_name = 'administration'
app_name = 'admin_regis_table'
urlpatterns = [
path('list-registration-requests/', RegistrationsTable.as_view(), name='admin_regis_table'),
path(r'list-registration-requests/?status=(?P<status>)/', RegistrationsTable.as_view(), name='admin_regis_table'),
Expand Down
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/admin_regis_table/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,5 @@ def getDate(row):

context['query_str'] = queryStr
context.update(paginator(self.request, registration_table_entries))
context['pagination_url_namespaces'] = 'administration:admin_regis_table'
context['pagination_url_namespaces'] = 'admin_regis_table:admin_regis_table'
return context
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/admin_submissions/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.apps import AppConfig

class SubmissionConfig(AppConfig):
name = 'admin_submissions'
name = 'apps.admin_submissions'
5 changes: 5 additions & 0 deletions apcd-cms/src/apps/apcd_login/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class APCDLoginConfig(AppConfig):
name = 'apps.apcd_login'
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/exception/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.apps import AppConfig

class ExceptionFormConfig(AppConfig):
name = 'exception'
name = 'apps.exception'
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/extension/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.apps import AppConfig

class ExtensionFormConfig(AppConfig):
name = 'extension'
name = 'apps.extension'
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/registrations/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.apps import AppConfig

class SubmissionFormConfig(AppConfig):
name = 'register'
name = 'apps.registrations'
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/registrations/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import path
from apps.registrations.views import SubmissionFormView

app_name = 'register'
app_name = 'registrations'
urlpatterns = [
path('request-to-submit/', SubmissionFormView.as_view(), name='register_table')
]
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/submissions/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.apps import AppConfig

class SubmissionConfig(AppConfig):
name = 'submissions'
name = 'apps.submissions'
2 changes: 1 addition & 1 deletion apcd-cms/src/apps/submitter_renewals_listing/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class SubmitterRenewalsListingConfig(AppConfig):
name = 'submitter_renewals_listing'
name = 'apps.submitter_renewals_listing'
67 changes: 35 additions & 32 deletions apcd-cms/src/apps/utils/apcd_database.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.conf import settings
import psycopg2
import psycopg
from datetime import datetime, date
import re
import logging
Expand All @@ -13,7 +13,7 @@ def get_users():
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -57,7 +57,7 @@ def update_user(form):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -114,7 +114,7 @@ def get_user_role(user):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -146,7 +146,7 @@ def get_registrations(reg_id=None, submitter_code=None):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand All @@ -172,7 +172,10 @@ def get_registrations(reg_id=None, submitter_code=None):
{f"WHERE registration_id = {str(reg_id)}" if reg_id is not None else ''}
{f"LEFT JOIN registration_submitters on registrations.registration_id = registration_submitters.registration_id LEFT JOIN submitters ON registration_submitters.submitter_id = submitters.submitter_id WHERE submitter_code = ANY(%s) ORDER BY registrations.registration_id" if submitter_code is not None else ''}"""
cur = conn.cursor()
cur.execute(query, (submitter_code,))
if submitter_code:
cur.execute(query, (submitter_code,))
else:
cur.execute(query)
return cur.fetchall()

except Exception as error:
Expand All @@ -189,7 +192,7 @@ def create_registration(form, renewal=False):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -246,7 +249,7 @@ def update_registration(form, reg_id):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -298,7 +301,7 @@ def get_registration_entities(reg_id=None, submitter_code=None):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -386,7 +389,7 @@ def create_registration_entity(form, reg_id, iteration, from_update_reg=None, ol
file_dc
) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"""

conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -439,7 +442,7 @@ def update_registration_entity(form, reg_id, iteration, no_entities):
reg_id,
form['ent_id_{}'.format(str_end)]
)
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -485,7 +488,7 @@ def delete_registration_entity(reg_id, ent_id):
conn = None
values = ()
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -519,7 +522,7 @@ def get_registration_contacts(reg_id=None, submitter_code=None):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -588,7 +591,7 @@ def create_registration_contact(form, reg_id, iteration, from_update_reg=None, o
contact_email
) VALUES (%s,%s,%s,%s,%s,%s)"""

conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -632,7 +635,7 @@ def update_registration_contact(form, reg_id, iteration, no_contacts):
reg_id,
form[f'cont_id_{iteration}']
)
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -669,7 +672,7 @@ def delete_registration_contact(reg_id, cont_id):
conn = None
values = ()
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -703,7 +706,7 @@ def create_submitter(form, reg_data):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -763,7 +766,7 @@ def create_other_exception(form, sub_data):
conn = None
values = ()
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -816,7 +819,7 @@ def create_threshold_exception(form, iteration, sub_data):
conn = None
values = ()
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -873,7 +876,7 @@ def get_cdl_exceptions(file_type):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -909,7 +912,7 @@ def get_submissions(user):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -943,7 +946,7 @@ def get_submission_logs(submission_id):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -984,7 +987,7 @@ def get_user_submissions_and_logs(user):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -1040,7 +1043,7 @@ def get_all_submissions_and_logs():
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -1142,7 +1145,7 @@ def create_extension(form, iteration, sub_data):
explanation_justification
) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
"""
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand All @@ -1168,7 +1171,7 @@ def update_extension(form):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -1231,7 +1234,7 @@ def get_submitter_info(user):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -1269,7 +1272,7 @@ def get_applicable_data_periods(submitter_id):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand All @@ -1295,7 +1298,7 @@ def get_current_exp_date(submitter_id, applicable_data_period):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand All @@ -1321,7 +1324,7 @@ def get_all_extensions():
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -1369,7 +1372,7 @@ def get_all_exceptions():
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down Expand Up @@ -1423,7 +1426,7 @@ def update_exception(form):
cur = None
conn = None
try:
conn = psycopg2.connect(
conn = psycopg.connect(
host=APCD_DB['host'],
dbname=APCD_DB['database'],
user=APCD_DB['user'],
Expand Down
Loading

0 comments on commit f0111e8

Please sign in to comment.