Repository: wevote/WeVoteServer

Issue:
Repo Python/Django Cleanup
The cleanup and organization of this cookie cutter can be cleaned up to make it enhanced for the application. All of the client side code will live in the `WebAppPublic` directory - or whatever this will be renamed (most of the time called public). 

Dale mentioned someone who could be of help to handle this.



Discussion:
Dale looked like he started to do the clean up we need at the start and we will continue to do so as we integrate with the API middleware and backend


Resolving patch:
diff --git a/admin_tools/views.py b/admin_tools/views.py
--- a/admin_tools/views.py
+++ b/admin_tools/views.py
@@ -1,6 +1,7 @@
 # admin_tools/views.py
 # Brought to you by We Vote. Be good.
 # -*- coding: UTF-8 -*-
+import os
 
 from django.contrib import messages
 from django.contrib.auth import authenticate, login, logout
@@ -11,19 +12,19 @@
 from django.shortcuts import render
 from django.urls import reverse
 
+import wevote_functions
 from ballot.models import BallotReturned, VoterBallotSaved
 from candidate.controllers import candidates_import_from_sample_file
 from candidate.models import CandidateCampaign, CandidateManager
-from config.base import get_environment_variable, LOGIN_URL
+from config.base import get_environment_variable, LOGIN_URL, BASE_DIR, PROJECT_PATH
 from election.controllers import elections_import_from_sample_file
 from election.models import Election
-from email_outbound.models import EmailAddress, SendGridApiCounterManager
+from email_outbound.models import EmailAddress
 from follow.models import FollowOrganizationList
 from friend.models import CurrentFriend, FriendManager, SuggestedFriend
 from import_export_ctcl.models import CTCLApiCounterManager
 from import_export_facebook.models import FacebookLinkToVoter, FacebookManager
 from import_export_google_civic.models import GoogleCivicApiCounterManager
-from import_export_targetsmart.models import TargetSmartApiCounterManager
 from import_export_vote_usa.models import VoteUSAApiCounterManager
 from measure.models import ContestMeasure, ContestMeasureManager
 from office.controllers import offices_import_from_sample_file
@@ -62,6 +63,8 @@
 WE_VOTE_SERVER_ROOT_URL = get_environment_variable("WE_VOTE_SERVER_ROOT_URL")
 
 
+logger = wevote_functions.admin.get_logger(__name__)
+
 @login_required
 def admin_home_view(request):
     # admin, analytics_admin, partner_organization, political_data_manager, political_data_viewer, verified_volunteer
@@ -70,6 +73,12 @@ def admin_home_view(request):
     if not voter_has_authority(request, authority_required):
         return redirect_to_sign_in_page(request, authority_required)
 
+    logger.info("AdminHome BASE_DIR: %s", BASE_DIR)
+    logger.info("AdminHome PROJECT_PATH: %s", PROJECT_PATH)
+    pth_root_static_css = os.path.join(BASE_DIR, 'static/v1/apis_v1.css')
+    logger.info("AdminHome os.path.isfile BASE_DIR, static/v1/apis_v1.css : %s", os.path.isfile(pth_root_static_css))
+    #  May 1, 2024 --  Nginix error:  Not Found: /apis/v1/static/apis_v1.css
+
     # Create a voter_device_id and voter in the database if one doesn't exist yet
     results = voter_setup(request)
     voter_api_device_id = results['voter_api_device_id']
diff --git a/config/base.py b/config/base.py
--- a/config/base.py
+++ b/config/base.py
@@ -86,6 +86,8 @@ def get_environment_variable_default(var_name, default_value):
 
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+BASE_STATIC_DIR = BASE_DIR + '/static'
+
 PROJECT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
 # Consider switching to the way that Two Scoops of Django 1.8 suggests file path handling, section 5.6
 
@@ -262,9 +264,9 @@ def get_environment_variable_default(var_name, default_value):
 
 # Static files (CSS, JavaScript, Images) Django 5+
 STATIC_URL = 'static/'      # April 2024, don't think this is correct, but can't run without it
-ALT_STATIC_URL = BASE_DIR + "/apis_v1/static"
-STATICFILES_DIRS = [ALT_STATIC_URL]
-
+STATICFILES_DIRS = (
+    BASE_STATIC_DIR,
+)
 
 # # Static files (CSS, JavaScript, Images)  Django 1.11 - 3.nn
 # # https://docs.djangoproject.com/en/1.11/howto/static-files/ calls loading static files from the project
diff --git a/config/views.py b/config/views.py
--- a/config/views.py
+++ b/config/views.py
@@ -18,7 +18,7 @@ def favicon_view(request):
     :param request:
     :return:
     """
-    img = open('apis_v1/static/apis_v1/favicon.ico', 'rb')
+    img = open('static/v1/favicon.ico', 'rb')
     response = FileResponse(img)
     return response
 


Test patch: