From bb38c71bbd144d9786d421f3ae90e1e37f5e5343 Mon Sep 17 00:00:00 2001 From: Di Mann Date: Sat, 27 Jul 2024 21:19:09 -0400 Subject: [PATCH 01/48] -Ply: -Dashboards API path handler now has better exception handling. This makes initial database setups trivial. --- dashboard/forge_urls.py | 20 ++++++++++++++++---- dashboard/staff_urls.py | 20 ++++++++++++++++---- dashboard/user_urls.py | 20 ++++++++++++++++---- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/dashboard/forge_urls.py b/dashboard/forge_urls.py index e28e173..5b13572 100644 --- a/dashboard/forge_urls.py +++ b/dashboard/forge_urls.py @@ -14,8 +14,14 @@ # Dynamic Module loading also means Dynamic Path generation. # CAVEAT, NOTE: ANY module that is defined in PLY_WORLDFORGE_DASHBOARD_MODULES or Dynamically below must include the forge_urls and forge_api_urls classes even if it empty. for mname in settings.PLY_WORLDFORGE_DASHBOARD_MODULES: - urlpatterns.append(path(f"api/{mname}/",include(f"{mname}.forge_api_urls"))) - urlpatterns.append(path(f"{mname}/", include(f"{mname}.forge_urls"))) + try: + urlpatterns.append(path(f"api/{mname}/",include(f"{mname}.forge_api_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {mname}.forge_api_urls", e) + try: + urlpatterns.append(path(f"{mname}/", include(f"{mname}.forge_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {mname}.dashboard_api_urls", e) # Now we also support *dynamic* url building using the ply_appinfo APIs: if settings.PLY_DYNAMIC_APP_URLS_ENABLED: @@ -29,8 +35,14 @@ if app_data.PLY_APP_INFO["dashboard_modes"]["forge"]["active"]: if app_data.PLY_APP_INFO['app_module'] not in settings.PLY_WORLDFORGE_DASHBOARD_MODULES: logging.info(f"Forge: Adding Module {app_data.PLY_APP_INFO['app_module']} to url paths...") - urlpatterns.append(path(f"api/{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.forge_api_urls"))) - urlpatterns.append(path(f"{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.forge_urls"))) + try: + urlpatterns.append(path(f"api/{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.forge_api_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {app_data.PLY_APP_INFO['app_module']}.forge_api_urls", e) + try: + urlpatterns.append(path(f"{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.forge_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {app_data.PLY_APP_INFO['app_module']}.forge_urls", e) else: logging.info(f"Forge: Module {app_data.PLY_APP_INFO['app_module']} is defined in settings.PLY_WORLDFORGE_DASHBOARD_MODULES: Not Loading dynamically again.") diff --git a/dashboard/staff_urls.py b/dashboard/staff_urls.py index a72cb9c..99a2a56 100644 --- a/dashboard/staff_urls.py +++ b/dashboard/staff_urls.py @@ -13,8 +13,14 @@ # Dynamic Module loading also means Dynamic Path generation. # CAVEAT, NOTE: ANY module that is defined in PLY_STAFF_DASHBOARD_MODULES must include a forge_urls class even if it's empty. for mname in ply.settings.PLY_STAFF_DASHBOARD_MODULES: - urlpatterns.append(path(f"api/{mname}/", include(f"{mname}.staff_api_urls"))) - urlpatterns.append(path(f"{mname}/", include(f"{mname}.staff_urls"))) + try: + urlpatterns.append(path(f"api/{mname}/", include(f"{mname}.staff_api_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {mname}.staff_api_urls", e) + try: + urlpatterns.append(path(f"{mname}/", include(f"{mname}.staff_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {mname}.staff_urls", e) # Now we also support *dynamic* url building using the ply_appinfo APIs: if settings.PLY_DYNAMIC_APP_URLS_ENABLED: @@ -28,8 +34,14 @@ if app_data.PLY_APP_INFO["dashboard_modes"]["staff"]["active"]: if app_data.PLY_APP_INFO['app_module'] not in settings.PLY_STAFF_DASHBOARD_MODULES: logging.info(f"Staff: Adding Module {app_data.PLY_APP_INFO['app_module']} to url paths...") - urlpatterns.append(path(f"api/{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.staff_api_urls"))) - urlpatterns.append(path(f"{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.staff_urls"))) + try: + urlpatterns.append(path(f"api/{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.staff_api_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {app_data.PLY_APP_INFO['app_module']}.staff_api_urls", e) + try: + urlpatterns.append(path(f"{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.staff_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {app_data.PLY_APP_INFO['app_module']}.staff_urls", e) else: logging.info(f"Staff: Module {app_data.PLY_APP_INFO['app_module']} is defined in settings.PLY_STAFF_DASHBOARD_MODULES: Not Loading dynamically again.") diff --git a/dashboard/user_urls.py b/dashboard/user_urls.py index 7069fff..56882e0 100644 --- a/dashboard/user_urls.py +++ b/dashboard/user_urls.py @@ -13,8 +13,14 @@ # Dynamic Module loading also means Dynamic Path generation. # CAVEAT, NOTE: ANY module that is defined in PLY_USER_DASHBOARD_MODULES must include a dashboard_urls class even if it's empty. for mname in ply.settings.PLY_USER_DASHBOARD_MODULES: - urlpatterns.append(path(f"api/{mname}/", include(f"{mname}.dashboard_api_urls"))) - urlpatterns.append(path(f"{mname}/",include(f"{mname}.dashboard_urls"))) + try: + urlpatterns.append(path(f"api/{mname}/", include(f"{mname}.dashboard_api_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {mname}.dashboard_api_urls:",e) + try: + urlpatterns.append(path(f"{mname}/",include(f"{mname}.dashboard_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {mname}.dashboard_urls:", e) # Now we also support *dynamic* url building using the ply_appinfo APIs: if settings.PLY_DYNAMIC_APP_URLS_ENABLED: logging.info("Dynamic User URL-path builder is enabled by settings.PLY_DYNAMIC_APP_URLS_ENABLED!") @@ -27,8 +33,14 @@ if app_data.PLY_APP_INFO["dashboard_modes"]["user"]["active"]: if app_data.PLY_APP_INFO['app_module'] not in settings.PLY_USER_DASHBOARD_MODULES: logging.info(f"User: Adding Module {app_data.PLY_APP_INFO['app_module']} to url paths...") - urlpatterns.append(path(f"api/{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.dashboard_api_urls"))) - urlpatterns.append(path(f"{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.dashboard_urls"))) + try: + urlpatterns.append(path(f"api/{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.dashboard_api_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {app_data.PLY_APP_INFO['app_module']}.dashboard_api_urls", e) + try: + urlpatterns.append(path(f"{app_data.PLY_APP_INFO['app_module']}/", include(f"{app_data.PLY_APP_INFO['app_module']}.dashboard_urls"))) + except Exception as e: + logging.error(f"Unable to Add App to path: {app_data.PLY_APP_INFO['app_module']}.dashboard_urls", e) else: logging.info(f"User: Module {app_data.PLY_APP_INFO['app_module']} is defined in settings.PLY_USER_DASHBOARD_MODULES: Not Loading dynamically again.") From 99f0928985f389e8fe057d897ee606b533737f22 Mon Sep 17 00:00:00 2001 From: Di Mann Date: Sat, 27 Jul 2024 22:51:53 -0400 Subject: [PATCH 02/48] -Ply: * Default Theme was missing HTML/CSS placeholder files. --- .../default_theme/templates/default_theme/dashboard/css.html | 0 .../templates/default_theme/dashboard/fonts.html | 5 +++++ 2 files changed, 5 insertions(+) create mode 100644 core/plyui/themes/default_theme/templates/default_theme/dashboard/css.html create mode 100644 core/plyui/themes/default_theme/templates/default_theme/dashboard/fonts.html diff --git a/core/plyui/themes/default_theme/templates/default_theme/dashboard/css.html b/core/plyui/themes/default_theme/templates/default_theme/dashboard/css.html new file mode 100644 index 0000000..e69de29 diff --git a/core/plyui/themes/default_theme/templates/default_theme/dashboard/fonts.html b/core/plyui/themes/default_theme/templates/default_theme/dashboard/fonts.html new file mode 100644 index 0000000..5200134 --- /dev/null +++ b/core/plyui/themes/default_theme/templates/default_theme/dashboard/fonts.html @@ -0,0 +1,5 @@ + + + + + From 4a3d8d2f154f91d275a861645b0ca396e74cc4fa Mon Sep 17 00:00:00 2001 From: sjewell Date: Sat, 27 Jul 2024 23:14:22 -0400 Subject: [PATCH 03/48] -added placeholder files for default theme --- .../templates/default_theme/body/dashboarrd/css.html | 0 .../templates/default_theme/body/dashboarrd/fonts.html | 5 +++++ 2 files changed, 5 insertions(+) create mode 100644 core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/css.html create mode 100644 core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/fonts.html diff --git a/core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/css.html b/core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/css.html new file mode 100644 index 0000000..e69de29 diff --git a/core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/fonts.html b/core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/fonts.html new file mode 100644 index 0000000..5200134 --- /dev/null +++ b/core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/fonts.html @@ -0,0 +1,5 @@ + + + + + From a69e55739d063e19fb4505a1355a2dd71903e1ef Mon Sep 17 00:00:00 2001 From: sjewell Date: Sat, 27 Jul 2024 23:18:29 -0400 Subject: [PATCH 04/48] -removed a superfluous r... --- .../default_theme/body/{dashboarrd => dashboard}/css.html | 0 .../default_theme/body/{dashboarrd => dashboard}/fonts.html | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename core/plyui/themes/default_theme/templates/default_theme/body/{dashboarrd => dashboard}/css.html (100%) rename core/plyui/themes/default_theme/templates/default_theme/body/{dashboarrd => dashboard}/fonts.html (100%) diff --git a/core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/css.html b/core/plyui/themes/default_theme/templates/default_theme/body/dashboard/css.html similarity index 100% rename from core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/css.html rename to core/plyui/themes/default_theme/templates/default_theme/body/dashboard/css.html diff --git a/core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/fonts.html b/core/plyui/themes/default_theme/templates/default_theme/body/dashboard/fonts.html similarity index 100% rename from core/plyui/themes/default_theme/templates/default_theme/body/dashboarrd/fonts.html rename to core/plyui/themes/default_theme/templates/default_theme/body/dashboard/fonts.html From 82d1fff8ab8ce609a6df2470ebbacbf3bc9131ac Mon Sep 17 00:00:00 2001 From: Di Mann Date: Sat, 27 Jul 2024 23:44:01 -0400 Subject: [PATCH 05/48] -Ply: * populate_sidebars is back. * setup2.sh now invokes register_plyapps and populate_sidebars. --- .../management/commands/populate_sidebars.py | 20 +++++++++++++------ setup/step2.sh | 8 +++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/communities/community/management/commands/populate_sidebars.py b/communities/community/management/commands/populate_sidebars.py index f58b4e9..a7dcbea 100644 --- a/communities/community/management/commands/populate_sidebars.py +++ b/communities/community/management/commands/populate_sidebars.py @@ -1,9 +1,12 @@ from django.core.management.base import BaseCommand from django.contrib.auth.models import User import os, csv + +from django.db import IntegrityError + from communities.community.models import ( Community, - CommunitySidebarMenu + CommunitySidebarMenu, CommunityDashboardType ) from communities.profiles.models import Profile from ply.models import PlyApplication @@ -18,7 +21,7 @@ def add_arguments(self, parser): def handle(self, *args, **options): community = options["community"] if community == "_all_": - cob = Community.objects.all()[0] + cob = Community.objects.all() else: cob = Community.objects.filter(hash=community) if len(cob) < 1: @@ -28,8 +31,13 @@ def handle(self, *args, **options): ) ) return False - for c in cob: - dtos = PlyApplication.objects.filter(active=True) - for d in dtos: - csmo = CommunitySidebarMenu.get_or_create(community=c,application_mode=d.mode,) + for dt in CommunityDashboardType.objects.all(): + for c in cob: + dtos = PlyApplication.objects.all() + for d in dtos: + try: + self.stdout.write(f"Application: {d}, Mode: {dt.type}....") + csmo = CommunitySidebarMenu.objects.get_or_create(community=c,application_mode=dt.type,module=d) + except IntegrityError: + pass self.stdout.write(self.style.SUCCESS("Success!")) diff --git a/setup/step2.sh b/setup/step2.sh index bce2f59..232a323 100755 --- a/setup/step2.sh +++ b/setup/step2.sh @@ -43,12 +43,18 @@ python3 ./manage.py init_gallery_plugins _all_ echo "*** Load Dashboard Type Data ***" -python3 ./manage.py load_dashboard_types DOCUMvENTATION/dashboards/types.tsv +python3 ./manage.py load_dashboard_types DOCUMENTATION/dashboards/types.tsv echo "***** STOP HERE - RUN A DEVSERVER, LOGIN TO YOUR APPLICATION AND NAVIGATE TO /forge/select/profile to create a profile BEFORE continuing with setup!! ***" read -p "Press Enter when you've created a profile." enter +echo "*** REGISTER APPS ***" +python3 ./manage.py register_plyapps + +echo "*** REGISTER APPS ***" +python3 ./manage.py populate_sidebars _all_ + echo "*** Creating default dashboard dynapages... ***" python3 ./manage.py create_dashboard_dynapages __auto-during-setup__ _all_ From 92f8bdc9b1fbc6bcabcf7d6c5386877f1d325f14 Mon Sep 17 00:00:00 2001 From: mistressAlisi Date: Thu, 15 Aug 2024 01:01:40 -0400 Subject: [PATCH 06/48] Ply: Modified the tooling so the whole app can be a library, ie, 'ply/' alongside your main apps. Reworked settings.py for more generic applications. introduced devtools/app_dev application which includes 'create_app_dashboards' command. --- .../0043_alter_communitysidebarmenu_module.py | 27 ++++++ .../0044_alter_communitysidebarmenu_module.py | 28 +++++++ .../management/commands/init_timezones.py | 2 +- .../management/commands/registertemplate.py | 19 +++-- .../management/commands/registerwidgets.py | 82 ++++++++++--------- core/forge/api_views.py | 13 +-- core/forge/user_views.py | 9 +- dashboard/forge_urls.py | 2 +- dashboard/navigation.py | 3 +- dashboard/staff_urls.py | 5 +- dashboard/user_urls.py | 4 +- dashboard/user_views.py | 5 +- .../__init__.py | 0 devtools/app_dev/__init__.py | 0 devtools/app_dev/admin.py | 3 + devtools/app_dev/apps.py | 6 ++ .../app_dev/management/commands/__init__.py | 0 .../commands/create_app_dashboards.py | 42 ++++++++++ devtools/app_dev/migrations/__init__.py | 0 devtools/app_dev/models.py | 3 + .../app_dashboards}/dashboard_api_urls.py | 0 .../app_dashboards/dashboard_api_views.py | 0 .../app_dashboards}/dashboard_urls.py | 0 .../app_dashboards}/dashboard_views.py | 0 .../app_dashboards}/forge_api_urls.py | 0 .../app_dashboards}/forge_api_views.py | 0 .../app_dashboards}/forge_forms.py | 0 .../pytemplates/app_dashboards}/forge_urls.py | 0 .../app_dashboards}/forge_views.py | 0 .../app_dashboards}/ply_appinfo.py | 0 .../app_dashboards}/public_api_urls.py | 0 .../app_dashboards}/public_api_views.py | 0 .../app_dashboards}/public_urls.py | 0 .../app_dashboards}/public_views.py | 0 .../app_dashboards}/sidebar_forge.py | 0 .../app_dashboards}/sidebar_menu.py | 0 devtools/app_dev/tests.py | 3 + devtools/app_dev/views.py | 3 + ply/management/commands/install_sql_files.py | 29 ++++--- ply/management/commands/register_plyapps.py | 5 +- ply/settings.py | 7 +- .../templatetags/stream_roll_widget.py | 0 42 files changed, 228 insertions(+), 72 deletions(-) create mode 100644 communities/community/migrations/0043_alter_communitysidebarmenu_module.py create mode 100644 communities/community/migrations/0044_alter_communitysidebarmenu_module.py rename DOCUMENTATION/templates/applications/example/dashboard_api_views.py => devtools/__init__.py (100%) create mode 100644 devtools/app_dev/__init__.py create mode 100644 devtools/app_dev/admin.py create mode 100644 devtools/app_dev/apps.py create mode 100644 devtools/app_dev/management/commands/__init__.py create mode 100644 devtools/app_dev/management/commands/create_app_dashboards.py create mode 100644 devtools/app_dev/migrations/__init__.py create mode 100644 devtools/app_dev/models.py rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/dashboard_api_urls.py (100%) create mode 100644 devtools/app_dev/pytemplates/app_dashboards/dashboard_api_views.py rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/dashboard_urls.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/dashboard_views.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/forge_api_urls.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/forge_api_views.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/forge_forms.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/forge_urls.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/forge_views.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/ply_appinfo.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/public_api_urls.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/public_api_views.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/public_urls.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/public_views.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/sidebar_forge.py (100%) rename {DOCUMENTATION/templates/applications/example => devtools/app_dev/pytemplates/app_dashboards}/sidebar_menu.py (100%) create mode 100644 devtools/app_dev/tests.py create mode 100644 devtools/app_dev/views.py rename {communities/stream => roleplaying/plydice}/templatetags/stream_roll_widget.py (100%) diff --git a/communities/community/migrations/0043_alter_communitysidebarmenu_module.py b/communities/community/migrations/0043_alter_communitysidebarmenu_module.py new file mode 100644 index 0000000..9217fa4 --- /dev/null +++ b/communities/community/migrations/0043_alter_communitysidebarmenu_module.py @@ -0,0 +1,27 @@ +# Generated by Django 5.0.1 on 2024-08-15 01:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("community", "0042_merge_20240724_1003"), + ] + + operations = [ + migrations.AlterField( + model_name="communitysidebarmenu", + name="module", + field=models.TextField( + choices=[ + ("communities.preferences", "communities.preferences"), + ("communities.community", "communities.community"), + ("communities.dashboards", "communities.dashboards"), + ("media.gallery.core", "media.gallery.core"), + ], + help_text="Application to Include in the Menus", + max_length=200, + verbose_name="Module/AppName:", + ), + ), + ] diff --git a/communities/community/migrations/0044_alter_communitysidebarmenu_module.py b/communities/community/migrations/0044_alter_communitysidebarmenu_module.py new file mode 100644 index 0000000..2a365e4 --- /dev/null +++ b/communities/community/migrations/0044_alter_communitysidebarmenu_module.py @@ -0,0 +1,28 @@ +# Generated by Django 5.0.1 on 2024-08-15 04:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("community", "0043_alter_communitysidebarmenu_module"), + ] + + operations = [ + migrations.AlterField( + model_name="communitysidebarmenu", + name="module", + field=models.TextField( + choices=[ + ("communities.preferences", "communities.preferences"), + ("communities.community", "communities.community"), + ("communities.dashboards", "communities.dashboards"), + ("media.gallery.core", "media.gallery.core"), + ("leagues.sports", "leagues.sports"), + ], + help_text="Application to Include in the Menus", + max_length=200, + verbose_name="Module/AppName:", + ), + ), + ] diff --git a/communities/preferences/management/commands/init_timezones.py b/communities/preferences/management/commands/init_timezones.py index f134eed..81a2ea6 100644 --- a/communities/preferences/management/commands/init_timezones.py +++ b/communities/preferences/management/commands/init_timezones.py @@ -11,7 +11,7 @@ def handle(self, *args, **options): # All profiles must be owned by the primary admin: - # Add a basic Header Widget to the dynapage template: + self.stdout.write(self.style.SUCCESS('Creating Timezone Objects....')) for tzi in pytz.common_timezones: dto = datetime.datetime.now(pytz.timezone(tzi)) diff --git a/core/dynapages/management/commands/registertemplate.py b/core/dynapages/management/commands/registertemplate.py index 9350344..ca612ea 100644 --- a/core/dynapages/management/commands/registertemplate.py +++ b/core/dynapages/management/commands/registertemplate.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.core.management.base import BaseCommand, CommandError from core.dynapages.models import Templates from bs4 import BeautifulSoup @@ -54,13 +55,19 @@ def register_template_file(self, file, template, app): f'Skipped resgistering Template "{template}" for Application "{app}" - Metadata block not found in file.' ) ) - + def _runner(self,template_dir,app): + templates = os.listdir(template_dir) + for template in templates: + tfile = open(template_dir + "/" + template) + self.register_template_file(tfile, template, app) def handle(self, *args, **options): # Find all templates: - for app in ply.settings.INSTALLED_APPS: + for app in settings.INSTALLED_APPS: template_dir = os.getcwd() + f"/{app.replace('.','/')}/templates/dynapages" if os.path.isdir(template_dir): - templates = os.listdir(template_dir) - for template in templates: - tfile = open(template_dir + "/" + template) - self.register_template_file(tfile, template, app) + self._runner(template_dir,app) + else: + template_dir = os.getcwd() + f"/ply/{app.replace('.', '/')}/templates/dynapages" + if os.path.isdir(template_dir): + self._runner(template_dir, app) + diff --git a/core/dynapages/management/commands/registerwidgets.py b/core/dynapages/management/commands/registerwidgets.py index f47de87..f229de5 100644 --- a/core/dynapages/management/commands/registerwidgets.py +++ b/core/dynapages/management/commands/registerwidgets.py @@ -1,3 +1,4 @@ +from django.conf import settings from django.core.management.base import BaseCommand, CommandError from core.dynapages.models import Templates from bs4 import BeautifulSoup @@ -8,45 +9,52 @@ from core.dynapages.models import Widget,Templates class Command(BaseCommand): help = 'Registers all DynaPage Widgets from the dynapages/widgets/ dir in every app into the database' - + def _runner(self,widget_dir,app): + widgets = os.listdir(widget_dir) + for widget in widgets: + wfile = open(widget_dir + "/" + widget) + try: + wdata = json.load(wfile) + try: + template = Templates.objects.get(template_id=wdata["dynapage_template"]) + except Exception as e: + self.stdout.write(self.style.ERROR(f'Widget "{widget}" Needs Template: "{wdata["dynapage_template"]}"')) + self.stdout.write("Hint: Try registering the templates first with ./managepy registertemplate ;)") + print(e) + return False + widget_obj = Widget.objects.get_or_create(widget_id=wdata["widget_name"], widget_name=wdata["widget_name"], author=wdata["author"], version=wdata["version"], label=wdata["title"], descr=wdata["descr"], helptext=wdata["helptext"], template=template, banner=wdata["modes"]["banner"], mainbody=wdata["modes"]["mainbody"], sidecol=wdata["modes"]["sidecol"], footer=wdata["modes"]["footer"])[0] + if "used_in" in wdata: + widget_obj.profile = wdata["used_in"]["profile"] + widget_obj.SLHUD = wdata["used_in"]["SLHUD"] + widget_obj.group = wdata["used_in"]["group"] + widget_obj.dashboard = wdata["used_in"]["dashboard"] + widget_obj.blog = wdata["used_in"]["blog"] + if "staff" in wdata["used_in"]: + widget_obj.staff = wdata["used_in"]["staff"] + if "icon" in wdata: + widget_obj.icon = wdata["icon"] + if "system" in wdata: + widget_obj.system = wdata["system"] + if "setup_required" in wdata: + widget_obj.setup_required = wdata["setup_required"] + widget_obj.setup_form = wdata["setup_form"] + widget_obj.app = app + widget_obj.save() + self.stdout.write(self.style.SUCCESS(f'Successfully registered/updated Widget "{widget}" for Application "{app}"')) + except Exception as e: + self.stdout.write(self.style.ERROR(f'Widget {widget} Fails registration: {e}')) + print(e) def handle(self, *args, **options): # Find all widgets: - for app in ply.settings.INSTALLED_APPS: + for app in settings.INSTALLED_APPS: widget_dir = os.getcwd() + f"/{app.replace('.','/')}/dynapages/widgets" - if (os.path.isdir(widget_dir)): - widgets = os.listdir(widget_dir) - for widget in widgets: - wfile = open(widget_dir+"/"+widget) - try: - wdata = json.load(wfile) - try: - template = Templates.objects.get(template_id=wdata["dynapage_template"]) - except Exception as e: - self.stdout.write(self.style.ERROR(f'Widget "{widget}" Needs Template: "{wdata["dynapage_template"]}"')) - self.stdout.write("Hint: Try registering the templates first with ./managepy registertemplate ;)") - print(e) - return False - widget_obj = Widget.objects.get_or_create(widget_id=wdata["widget_name"],widget_name=wdata["widget_name"],author=wdata["author"],version=wdata["version"],label=wdata["title"],descr=wdata["descr"],helptext=wdata["helptext"],template=template,banner=wdata["modes"]["banner"],mainbody=wdata["modes"]["mainbody"],sidecol=wdata["modes"]["sidecol"],footer=wdata["modes"]["footer"])[0] - if "used_in" in wdata: - widget_obj.profile = wdata["used_in"]["profile"] - widget_obj.SLHUD = wdata["used_in"]["SLHUD"] - widget_obj.group = wdata["used_in"]["group"] - widget_obj.dashboard = wdata["used_in"]["dashboard"] - widget_obj.blog = wdata["used_in"]["blog"] - if "staff" in wdata["used_in"]: - widget_obj.staff = wdata["used_in"]["staff"] - if "icon" in wdata: - widget_obj.icon = wdata["icon"] - if "system" in wdata: - widget_obj.system = wdata["system"] - if "setup_required" in wdata: - widget_obj.setup_required = wdata["setup_required"] - widget_obj.setup_form = wdata["setup_form"] - widget_obj.app = app - widget_obj.save() - self.stdout.write(self.style.SUCCESS(f'Successfully registered/updated Widget "{widget}" for Application "{app}"')) + if os.path.isdir(widget_dir): + self._runner(widget_dir,app) + else: + widget_dir = os.getcwd() + f"/ply/{app.replace('.', '/')}/dynapages/widgets" + if os.path.isdir(widget_dir): + self._runner(widget_dir, app) + + - except Exception as e: - self.stdout.write(self.style.ERROR(f'Widget {widget} Fails registration: {e}')) - print(e) diff --git a/core/forge/api_views.py b/core/forge/api_views.py index daebb02..c860a4a 100644 --- a/core/forge/api_views.py +++ b/core/forge/api_views.py @@ -74,12 +74,13 @@ def update_character_profile(request): profile.save() # Update the class data if it's present: if 'classtype' in request.POST: - _classtype = request.POST['classtype'] - classtype = ClassType.objects.get(uuid=_classtype) - stlevel = Level.objects.get(level=0) - peo = ProfileExperience.objects.get_or_create(community=community,profile=profile,classtype=classtype,level=stlevel)[0] - peo.classtype = classtype - peo.save() + if request.POST['classtype'] != '': + _classtype = request.POST['classtype'] + classtype = ClassType.objects.get(uuid=_classtype) + stlevel = Level.objects.get(level=0) + peo = ProfileExperience.objects.get_or_create(community=community,profile=profile,classtype=classtype,level=stlevel)[0] + peo.classtype = classtype + peo.save() return JsonResponse({"res":"ok"},safe=False) diff --git a/core/forge/user_views.py b/core/forge/user_views.py index f05670f..2d84402 100644 --- a/core/forge/user_views.py +++ b/core/forge/user_views.py @@ -34,12 +34,14 @@ def select_profile(request): # Render the Create Profile Forge Page: @login_required def create_profile(request): - # Ignore port: + + print(request.session['profile']) vhost = request.META["HTTP_HOST"].split(":")[0]; community = (vhosts.get_vhost_community(hostname=vhost)) theme = themes.get_community_theme_or_def(community) # The FORGE will create a new profile using this view. The first step is to get a placeholder profile so we can start assigning items and data to it: profile = toolkit.profiles.get_placeholder_profile(request) + #print(profile) classes = ClassType.objects.filter(selectable=True,frozen=False,archived=False,blocked=False) if community is None: return render(request,"error-no_vhost_configured.html",{}) @@ -90,7 +92,10 @@ def edit_profile_preview(request): community = (vhosts.get_vhost_community(hostname=vhost)) # The FORGE will create a new profile using this view. The first step is to get a placeholder profile so we can start assigning items and data to it: profile = toolkit.profiles.get_active_profile(request) - exo = ProfileExperience.objects.get(community=community,profile=profile) + try: + exo = ProfileExperience.objects.get(community=community,profile=profile) + except: + exo = {} context = {'community':community,'vhost':vhost,'profile':profile,"av_path":settings.PLY_AVATAR_FILE_URL_BASE_URL,"exp":exo} return render(request,"forge-preview_profile.html",context) diff --git a/dashboard/forge_urls.py b/dashboard/forge_urls.py index 5b13572..311c5e7 100644 --- a/dashboard/forge_urls.py +++ b/dashboard/forge_urls.py @@ -1,7 +1,7 @@ from django.urls import path,include from dashboard import forge_views import ply -from ply import settings +from django.conf import settings from ply.toolkit.core import get_ply_appinfo from ply.toolkit.logger import getLogger diff --git a/dashboard/navigation.py b/dashboard/navigation.py index 074c741..a310e4a 100644 --- a/dashboard/navigation.py +++ b/dashboard/navigation.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 # The Navigation component dotes the Console with the ability to auto-generate sidebar and top menus based on the installed and registered Ceres Modules. +from django.conf import settings from django.conf.urls import include import logging import ply @@ -13,7 +14,7 @@ class SideBarBuilder: def __init__( self, - data=ply.settings.PLY_USER_DASHBOARD_MODULES, + data=settings.PLY_USER_DASHBOARD_MODULES, menu_module_name="sidebar_menu", ): if len(self.modules) == 0: diff --git a/dashboard/staff_urls.py b/dashboard/staff_urls.py index 99a2a56..3dc1e4b 100644 --- a/dashboard/staff_urls.py +++ b/dashboard/staff_urls.py @@ -1,7 +1,7 @@ from django.urls import path, include from dashboard import staff_views import ply -from ply import settings +from django.conf import settings from ply.toolkit.core import get_ply_appinfo from ply.toolkit.logger import getLogger @@ -12,7 +12,8 @@ ] # Dynamic Module loading also means Dynamic Path generation. # CAVEAT, NOTE: ANY module that is defined in PLY_STAFF_DASHBOARD_MODULES must include a forge_urls class even if it's empty. -for mname in ply.settings.PLY_STAFF_DASHBOARD_MODULES: + +for mname in settings.PLY_STAFF_DASHBOARD_MODULES: try: urlpatterns.append(path(f"api/{mname}/", include(f"{mname}.staff_api_urls"))) except Exception as e: diff --git a/dashboard/user_urls.py b/dashboard/user_urls.py index 56882e0..a602725 100644 --- a/dashboard/user_urls.py +++ b/dashboard/user_urls.py @@ -1,7 +1,7 @@ from django.urls import path,include from dashboard import user_views import ply -from ply import settings +from django.conf import settings from ply.toolkit.core import get_ply_appinfo from ply.toolkit.logger import getLogger @@ -12,7 +12,7 @@ ] # Dynamic Module loading also means Dynamic Path generation. # CAVEAT, NOTE: ANY module that is defined in PLY_USER_DASHBOARD_MODULES must include a dashboard_urls class even if it's empty. -for mname in ply.settings.PLY_USER_DASHBOARD_MODULES: +for mname in settings.PLY_USER_DASHBOARD_MODULES: try: urlpatterns.append(path(f"api/{mname}/", include(f"{mname}.dashboard_api_urls"))) except Exception as e: diff --git a/dashboard/user_views.py b/dashboard/user_views.py index 2f26cec..3e2dc97 100644 --- a/dashboard/user_views.py +++ b/dashboard/user_views.py @@ -55,7 +55,10 @@ def dashboard_home(request): log.info(f"Initialising Dynapages for {profile.profile_id}'s dashboard.") profilePage = dp_tools.dashboard_initDynaPage(request.user, profile) log.info(f"Profile Node: {profilePage.dynapage.pk}, {profilePage.node_type}") - exo = ProfileExperience.objects.get(community=community, profile=profile) + try: + exo = ProfileExperience.objects.get(community=community, profile=profile) + except: + exo = {} widgets = dynapages.PageWidget.objects.order_by("order").filter( page=profilePage.dynapage diff --git a/DOCUMENTATION/templates/applications/example/dashboard_api_views.py b/devtools/__init__.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/dashboard_api_views.py rename to devtools/__init__.py diff --git a/devtools/app_dev/__init__.py b/devtools/app_dev/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/devtools/app_dev/admin.py b/devtools/app_dev/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/devtools/app_dev/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/devtools/app_dev/apps.py b/devtools/app_dev/apps.py new file mode 100644 index 0000000..626f088 --- /dev/null +++ b/devtools/app_dev/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class SportsConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "devtools.app_dev" diff --git a/devtools/app_dev/management/commands/__init__.py b/devtools/app_dev/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/devtools/app_dev/management/commands/create_app_dashboards.py b/devtools/app_dev/management/commands/create_app_dashboards.py new file mode 100644 index 0000000..ac4bdcd --- /dev/null +++ b/devtools/app_dev/management/commands/create_app_dashboards.py @@ -0,0 +1,42 @@ +from distutils.file_util import copy_file + +from django.core.management.base import BaseCommand, CommandError + +from bs4 import BeautifulSoup +import uuid +from ply import system_uuids,settings +from django.contrib.auth.models import User +import os + +from core.dynapages.models import Templates,Page,Widget,PageWidget +from communities.profiles.models import Profile + + +class Command(BaseCommand): + help = 'Create the Ply Application Dashboards for the specified Django application - thus also making it a Ply app :)' + + + def add_arguments(self, parser): + parser.add_argument("app", type=str) + + def _runner(self,src,dst): + files = os.listdir(src) + for file in files: + + if not os.path.exists(f"{dst}/{file}"): + copy_file(f"{src}/{file}",f"{dst}/{file}") + else: + self.stdout.write(self.style.WARNING(f"File {dst}/{file} already exists.")) + def handle(self, *args, **options): + app_name = options["app"] + self.stdout.write(self.style.MIGRATE_HEADING(f"Copying Dashboard files from ../pytemplates/app_dashboards to {app_name}...")) + src_path = os.getcwd() + f"/devtools/app_dev/pytemplates/app_dashboards" + dst_path = os.getcwd() + f"/{app_name.replace('.','/')}" + if os.path.isdir(src_path): + self._runner(src_path,dst_path) + else: + src_path = os.getcwd() + f"/ply/devtools/app_dev/pytemplates/app_dashboards" + if os.path.isdir(src_path): + self._runner(src_path,dst_path) + + diff --git a/devtools/app_dev/migrations/__init__.py b/devtools/app_dev/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/devtools/app_dev/models.py b/devtools/app_dev/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/devtools/app_dev/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/DOCUMENTATION/templates/applications/example/dashboard_api_urls.py b/devtools/app_dev/pytemplates/app_dashboards/dashboard_api_urls.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/dashboard_api_urls.py rename to devtools/app_dev/pytemplates/app_dashboards/dashboard_api_urls.py diff --git a/devtools/app_dev/pytemplates/app_dashboards/dashboard_api_views.py b/devtools/app_dev/pytemplates/app_dashboards/dashboard_api_views.py new file mode 100644 index 0000000..e69de29 diff --git a/DOCUMENTATION/templates/applications/example/dashboard_urls.py b/devtools/app_dev/pytemplates/app_dashboards/dashboard_urls.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/dashboard_urls.py rename to devtools/app_dev/pytemplates/app_dashboards/dashboard_urls.py diff --git a/DOCUMENTATION/templates/applications/example/dashboard_views.py b/devtools/app_dev/pytemplates/app_dashboards/dashboard_views.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/dashboard_views.py rename to devtools/app_dev/pytemplates/app_dashboards/dashboard_views.py diff --git a/DOCUMENTATION/templates/applications/example/forge_api_urls.py b/devtools/app_dev/pytemplates/app_dashboards/forge_api_urls.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/forge_api_urls.py rename to devtools/app_dev/pytemplates/app_dashboards/forge_api_urls.py diff --git a/DOCUMENTATION/templates/applications/example/forge_api_views.py b/devtools/app_dev/pytemplates/app_dashboards/forge_api_views.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/forge_api_views.py rename to devtools/app_dev/pytemplates/app_dashboards/forge_api_views.py diff --git a/DOCUMENTATION/templates/applications/example/forge_forms.py b/devtools/app_dev/pytemplates/app_dashboards/forge_forms.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/forge_forms.py rename to devtools/app_dev/pytemplates/app_dashboards/forge_forms.py diff --git a/DOCUMENTATION/templates/applications/example/forge_urls.py b/devtools/app_dev/pytemplates/app_dashboards/forge_urls.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/forge_urls.py rename to devtools/app_dev/pytemplates/app_dashboards/forge_urls.py diff --git a/DOCUMENTATION/templates/applications/example/forge_views.py b/devtools/app_dev/pytemplates/app_dashboards/forge_views.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/forge_views.py rename to devtools/app_dev/pytemplates/app_dashboards/forge_views.py diff --git a/DOCUMENTATION/templates/applications/example/ply_appinfo.py b/devtools/app_dev/pytemplates/app_dashboards/ply_appinfo.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/ply_appinfo.py rename to devtools/app_dev/pytemplates/app_dashboards/ply_appinfo.py diff --git a/DOCUMENTATION/templates/applications/example/public_api_urls.py b/devtools/app_dev/pytemplates/app_dashboards/public_api_urls.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/public_api_urls.py rename to devtools/app_dev/pytemplates/app_dashboards/public_api_urls.py diff --git a/DOCUMENTATION/templates/applications/example/public_api_views.py b/devtools/app_dev/pytemplates/app_dashboards/public_api_views.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/public_api_views.py rename to devtools/app_dev/pytemplates/app_dashboards/public_api_views.py diff --git a/DOCUMENTATION/templates/applications/example/public_urls.py b/devtools/app_dev/pytemplates/app_dashboards/public_urls.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/public_urls.py rename to devtools/app_dev/pytemplates/app_dashboards/public_urls.py diff --git a/DOCUMENTATION/templates/applications/example/public_views.py b/devtools/app_dev/pytemplates/app_dashboards/public_views.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/public_views.py rename to devtools/app_dev/pytemplates/app_dashboards/public_views.py diff --git a/DOCUMENTATION/templates/applications/example/sidebar_forge.py b/devtools/app_dev/pytemplates/app_dashboards/sidebar_forge.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/sidebar_forge.py rename to devtools/app_dev/pytemplates/app_dashboards/sidebar_forge.py diff --git a/DOCUMENTATION/templates/applications/example/sidebar_menu.py b/devtools/app_dev/pytemplates/app_dashboards/sidebar_menu.py similarity index 100% rename from DOCUMENTATION/templates/applications/example/sidebar_menu.py rename to devtools/app_dev/pytemplates/app_dashboards/sidebar_menu.py diff --git a/devtools/app_dev/tests.py b/devtools/app_dev/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/devtools/app_dev/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/devtools/app_dev/views.py b/devtools/app_dev/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/devtools/app_dev/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/ply/management/commands/install_sql_files.py b/ply/management/commands/install_sql_files.py index ca5ede0..b0c25fe 100644 --- a/ply/management/commands/install_sql_files.py +++ b/ply/management/commands/install_sql_files.py @@ -15,26 +15,35 @@ class Command(BaseCommand): def add_arguments(self, parser): parser.add_argument('app', type=str) + def _dir_runner(self,sql_dir): + self.stdout.write(self.style.MIGRATE_HEADING(f'...Installing files in: "{sql_dir}"...')) + sqlfiles = os.listdir(sql_dir) + with connection.cursor() as cursor: + for sql in sqlfiles: + self.stdout.write(self.style.MIGRATE_LABEL(f'Installing file "{sql}"...')) + sqlfile = open(sql_dir + "/" + sql).read() + cursor.execute(sqlfile) + cursor.close() + def run_dir(self,app): sql_dir = os.getcwd() + f"/{app.replace('.','/')}/sql/" if (os.path.isdir(sql_dir)): - self.stdout.write(self.style.MIGRATE_HEADING(f'...Installing files in: "{sql_dir}"...')) - sqlfiles = os.listdir(sql_dir) - with connection.cursor() as cursor: - for sql in sqlfiles: - self.stdout.write(self.style.MIGRATE_LABEL(f'Installing file "{sql}"...')) - sqlfile = open(sql_dir+"/"+sql).read() - cursor.execute(sqlfile) - cursor.close() + self._dir_runner(sql_dir) + else: + sql_dir = os.getcwd() + f"/ply/{app.replace('.', '/')}/sql/" + if (os.path.isdir(sql_dir)): + self._dir_runner(sql_dir) + + def handle(self, *args, **options): self.stdout.write(self.style.SUCCESS('Installing SQL Files...')) if (options['app'] == '_all_'): - for iapp in ply.settings.INSTALLED_APPS: + for iapp in settings.INSTALLED_APPS: self.run_dir(iapp) else: - if (options['app'] in ply.settings.INSTALLED_APPS): + if (options['app'] in settings.INSTALLED_APPS): self.run_dir(options['app']) else: self.stdout.write(self.style.ERROR(f'NO SUCH APP: \'{options["app"]}\'!')) diff --git a/ply/management/commands/register_plyapps.py b/ply/management/commands/register_plyapps.py index 594a899..f12d9c3 100644 --- a/ply/management/commands/register_plyapps.py +++ b/ply/management/commands/register_plyapps.py @@ -1,11 +1,13 @@ from django.core.management.base import BaseCommand, CommandError import uuid from django.utils import timezone -from ply import system_uuids, settings, toolkit +from ply import system_uuids, toolkit from ply.models import PlyApplication +from django.conf import settings import importlib + class Command(BaseCommand): help = "Registers all applications that have a ply_appinfo (Ply Apps) class in the database; using this info to populate dashboard menus.." @@ -57,6 +59,7 @@ def handle(self, *args, **options): _write = False else: appobj.updated = timezone.now() + if _write: appobj.app_name = plyapp_info.PLY_APP_INFO["app_name"] appobj.version_release = plyapp_info.PLY_APP_INFO["version"]["release"] diff --git a/ply/settings.py b/ply/settings.py index 7d2130f..3b81d49 100644 --- a/ply/settings.py +++ b/ply/settings.py @@ -100,6 +100,7 @@ 'ufls.dealers', 'ufls.scheduling', 'ufls.staff', + 'devtools.app_dev', 'mailer', 'whitenoise', 'core.plyui.themes.default_theme' @@ -514,13 +515,15 @@ STRIPE_TEST_SECRET_KEY = PAYMENT_STRIPE_SECRET_KEY STRIPE_LIVE_SECRET_KEY = PAYMENT_STRIPE_SECRET_KEY STRIPE_LIVE_MODE = True # Change to True in production -DJSTRIPE_WEBHOOK_SECRET = config("PLY_DJSTRIPE_WEBHOOK_SECRET") # Get it from the section in the Stripe dashboard where you added the webhook endpoint -DJSTRIPE_USE_NATIVE_JSONFIELD = True # We recommend setting to True for new installations +# TODO : FOR UFLS? +#DJSTRIPE_WEBHOOK_SECRET = config("PLY_DJSTRIPE_WEBHOOK_SECRET",default="") # Get it from the section in the Stripe dashboard where you added the webhook endpoint +#DJSTRIPE_USE_NATIVE_JSONFIELD = True # We recommend setting to True for new installations PLY_DEFAULT_THEME = config('PLY_DEFAULT_THEME',default="core.ui.themes.default") # New Dynamic URL mapping PLY_DYNAMIC_APP_URLS_ENABLED = config("PLY_DYNAMIC_APP_URLS_ENABLED",True) +# TODO: FOR UFLS? DJSTRIPE_FOREIGN_KEY_TO_FIELD = config("DJSTRIPE_FOREIGN_KEY_TO_FIELD","id") SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') \ No newline at end of file diff --git a/communities/stream/templatetags/stream_roll_widget.py b/roleplaying/plydice/templatetags/stream_roll_widget.py similarity index 100% rename from communities/stream/templatetags/stream_roll_widget.py rename to roleplaying/plydice/templatetags/stream_roll_widget.py From bec64f8e5bf579cccec4d7e84a745bd224861504 Mon Sep 17 00:00:00 2001 From: mistressAlisi Date: Thu, 15 Aug 2024 13:05:15 -0400 Subject: [PATCH 07/48] -Ply: -Added new registry functions: -ply_regedit-str.py: Set a given key to the supplied string value in the registry for a community. -ply_getreg.py: Get a given value from the specified community's registry using it's key. -ply_regdump.py: Dump (show) all the specified community's registry values --- ply/management/commands/ply_getreg.py | 34 ++++++++++++++++++++ ply/management/commands/ply_regdump.py | 36 ++++++++++++++++++++++ ply/management/commands/ply_regedit-str.py | 31 +++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 ply/management/commands/ply_getreg.py create mode 100644 ply/management/commands/ply_regdump.py create mode 100644 ply/management/commands/ply_regedit-str.py diff --git a/ply/management/commands/ply_getreg.py b/ply/management/commands/ply_getreg.py new file mode 100644 index 0000000..fbe294a --- /dev/null +++ b/ply/management/commands/ply_getreg.py @@ -0,0 +1,34 @@ +from django.core.management.base import BaseCommand, CommandError +from django.db import connection +from bs4 import BeautifulSoup +import uuid +from ply import system_uuids,settings +from django.contrib.auth.models import User +import os +import ply + +from communities.community.models import Community,CommunityRegistry + + +class Command(BaseCommand): + help = 'GetReg: Get the value of the given [key] in the registry for the given [community].' + + def add_arguments(self, parser): + parser.add_argument('community', type=str) + parser.add_argument('key', type=str) + + + + + def handle(self, *args, **options): + comm = Community.objects.get(uuid=uuid.UUID(options["community"])) + self.stdout.write(self.style.MIGRATE_LABEL(f'Value in Registry for key [{options["key"]}] in Community [{comm.uuid}][{comm.name}]:')) + regobj = CommunityRegistry.objects.get(community=comm,key=options["key"]) + self.stdout.write(f"Text_value:{regobj.text_value}") + self.stdout.write(f"int_value:{regobj.int_value}") + self.stdout.write(f"json_value:{regobj.json_value}") + self.stdout.write(f"bin_value:{regobj.bin_value}") + self.stdout.write(f"bool_value:{regobj.bool_value}") + self.stdout.write(f"uuid_value:{regobj.uuid_value}") + self.stdout.write(self.style.SUCCESS('Success!')) + diff --git a/ply/management/commands/ply_regdump.py b/ply/management/commands/ply_regdump.py new file mode 100644 index 0000000..af56f67 --- /dev/null +++ b/ply/management/commands/ply_regdump.py @@ -0,0 +1,36 @@ +from django.core.management.base import BaseCommand, CommandError +from django.db import connection +from bs4 import BeautifulSoup +import uuid +from ply import system_uuids,settings +from django.contrib.auth.models import User +import os +import ply + +from communities.community.models import Community,CommunityRegistry + + +class Command(BaseCommand): + help = 'RegDump: Dump (show) all the specified [community] registry settings.' + + def add_arguments(self, parser): + parser.add_argument('community', type=str) + + + + + def handle(self, *args, **options): + comm = Community.objects.get(uuid=uuid.UUID(options["community"])) + self.stdout.write(self.style.MIGRATE_LABEL(f'Value in Registry in Community [{comm.uuid}][{comm.name}]:')) + regobj_arr = CommunityRegistry.objects.filter(community=comm) + for regobj in regobj_arr: + self.stdout.write(self.style.MIGRATE_HEADING(f'Value in Registry for key [{regobj.key}]:')) + self.stdout.write(f"Text_value:{regobj.text_value}") + self.stdout.write(f"int_value:{regobj.int_value}") + self.stdout.write(f"json_value:{regobj.json_value}") + self.stdout.write(f"bin_value:{regobj.bin_value}") + self.stdout.write(f"bool_value:{regobj.bool_value}") + self.stdout.write(f"uuid_value:{regobj.uuid_value}") + self.stdout.write("***") + self.stdout.write(self.style.SUCCESS('Success!')) + diff --git a/ply/management/commands/ply_regedit-str.py b/ply/management/commands/ply_regedit-str.py new file mode 100644 index 0000000..f18d0ad --- /dev/null +++ b/ply/management/commands/ply_regedit-str.py @@ -0,0 +1,31 @@ +from django.core.management.base import BaseCommand, CommandError +from django.db import connection +from bs4 import BeautifulSoup +import uuid +from ply import system_uuids,settings +from django.contrib.auth.models import User +import os +import ply + +from communities.community.models import Community,CommunityRegistry + + +class Command(BaseCommand): + help = 'RegEdit-str: Set the given [key] to the given string [value] in the registry for the given [community].' + + def add_arguments(self, parser): + parser.add_argument('community', type=str) + parser.add_argument('key', type=str) + parser.add_argument('value', type=str) + + + + def handle(self, *args, **options): + comm = Community.objects.get(uuid=uuid.UUID(options["community"])) + self.stdout.write(self.style.MIGRATE_LABEL(f'Set value in Registry with key [{options["key"]}] in Community [{comm.uuid}][{comm.name}]')) + regobj,created = CommunityRegistry.objects.get_or_create(community=comm,key=options["key"]) + if not created: + regobj.clear_all() + regobj.text_value = options["value"] + regobj.save() + self.stdout.write(self.style.SUCCESS('Success!')) From 407a7e060bdbd831cec85e77d5c0d80fb2ae8bfa Mon Sep 17 00:00:00 2001 From: mistressAlisi Date: Tue, 27 Aug 2024 21:47:34 -0400 Subject: [PATCH 08/48] -it is now possible to use ply as a library. -out-of-ply url routers now supported. -New registry commands: ply/management/commands/ply_getreg.py ply/management/commands/ply_regdump.py ply/management/commands/ply_regedit-clear.py ply/management/commands/ply_regedit-false.py ply/management/commands/ply_regedit-str.py ply/management/commands/ply_regedit-true.py --- communities/community/forge_api_views.py | 13 ++++--- .../0045_alter_communitysidebarmenu_module.py | 30 ++++++++++++++++ .../0046_alter_communitysidebarmenu_module.py | 31 +++++++++++++++++ communities/community/models.py | 12 +++++++ .../community_admin/dashboard/index.html | 2 +- ...ities-community-installComplete-cover.html | 2 +- .../profile_dashboard_dynapage_wrapper.html | 2 +- .../templates/profiles_index_view.html | 2 +- .../templates/stream/dashboard/dashboard.html | 2 +- .../stream/dashboard/profile_stream.html | 2 +- .../stream_community_index_view.html | 2 +- .../templates/stream_profile_index_view.html | 2 +- .../almanac_create_page-preview.html | 2 +- .../templates/almanac_create_page.html | 2 +- .../almanac/templates/almanac_dashboard.html | 2 +- .../almanac/templates/almanac_edit_menu.html | 2 +- .../templates/almanac_edit_page-preview.html | 2 +- .../almanac/templates/almanac_edit_page.html | 2 +- .../templates/keywords/share_search_view.html | 2 +- .../authentication/registration/login.html | 2 +- .../activation_complete.html | 2 +- .../registration_closed.html | 2 +- .../registration_complete.html | 2 +- .../registration_form.html | 2 +- ...dynapage-template-default-almanacpage.html | 2 +- ...late-default-community-coverPage-main.html | 2 +- .../templates/forge-create_community.html | 2 +- .../templates/forge-preview_community.html | 2 +- .../templates/forge-preview_profile.html | 2 +- .../templates/forge/levelup/levelup.html | 2 +- .../templates/forge/levelup/no_levelup.html | 2 +- .../forge/script_studio/dashboard.html | 2 +- .../core/templates/gallery_index_view.html | 2 +- .../templates/gallery_profile_index_view.html | 2 +- ply/management/commands/create_community.py | 3 +- ply/management/commands/install_sql_files.py | 3 +- ply/management/commands/ply_getreg.py | 3 +- ply/management/commands/ply_regdump.py | 5 +-- ply/management/commands/ply_regedit-clear.py | 34 +++++++++++++++++++ ply/management/commands/ply_regedit-false.py | 31 +++++++++++++++++ ply/management/commands/ply_regedit-str.py | 5 +-- ply/management/commands/ply_regedit-true.py | 31 +++++++++++++++++ ply/templates/ply-bootstrap5.html | 1 - .../templates/SLHUD/errors/no-SLparcel.html | 2 +- .../SLHUD/templates/SLHUD/login/login.html | 2 +- .../templates/SLHUD/registration/start.html | 2 +- .../SLHUD/templates/SLHUD/select/profile.html | 2 +- roleplaying/SLHUD/templates/SLHUD/start.html | 2 +- 48 files changed, 222 insertions(+), 50 deletions(-) create mode 100644 communities/community/migrations/0045_alter_communitysidebarmenu_module.py create mode 100644 communities/community/migrations/0046_alter_communitysidebarmenu_module.py create mode 100644 ply/management/commands/ply_regedit-clear.py create mode 100644 ply/management/commands/ply_regedit-false.py create mode 100644 ply/management/commands/ply_regedit-true.py diff --git a/communities/community/forge_api_views.py b/communities/community/forge_api_views.py index c65ef04..2720d7c 100644 --- a/communities/community/forge_api_views.py +++ b/communities/community/forge_api_views.py @@ -126,15 +126,14 @@ def create_community_sidebar_menu(request): ) if len(is_admin) < 1: return render(request, "error-access-denied.html", {}) - if request.POST["not_edited"] == "False": - logging.info(f"Creating new Sidebar Menu from data: Mode: {request.POST['application_mode']} Module: {request.POST['module']}. Class: {request.POST['sidebar_class']} in Community {request.POST['community']}") - form = CommunitySidebarMenuForm(request.POST) - # form.set_community(community) - - else: + try: + created = False instance = CommunitySidebarMenu.objects.get(pk=request.POST["uuid"]) - form = CommunitySidebarMenuForm(request.POST, instance=instance) + except CommunitySidebarMenu.DoesNotExist: + instance,created = CommunitySidebarMenu.objects.get_or_create(pk=request.POST["uuid"]) + form = CommunitySidebarMenuForm(request.POST, instance=instance) if not form.is_valid(): + instance.delete() return JsonResponse({"res": "err", "e": form.errors}, safe=False) else: form.instance.not_edited = True diff --git a/communities/community/migrations/0045_alter_communitysidebarmenu_module.py b/communities/community/migrations/0045_alter_communitysidebarmenu_module.py new file mode 100644 index 0000000..476ae68 --- /dev/null +++ b/communities/community/migrations/0045_alter_communitysidebarmenu_module.py @@ -0,0 +1,30 @@ +# Generated by Django 5.0.8 on 2024-08-16 01:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("community", "0044_alter_communitysidebarmenu_module"), + ] + + operations = [ + migrations.AlterField( + model_name="communitysidebarmenu", + name="module", + field=models.TextField( + choices=[ + ("communities.preferences", "communities.preferences"), + ("communities.community", "communities.community"), + ("communities.dashboards", "communities.dashboards"), + ("media.gallery.core", "media.gallery.core"), + ("leagues.sports", "leagues.sports"), + ("theodds.odds", "theodds.odds"), + ("player.wager", "player.wager"), + ], + help_text="Application to Include in the Menus", + max_length=200, + verbose_name="Module/AppName:", + ), + ), + ] diff --git a/communities/community/migrations/0046_alter_communitysidebarmenu_module.py b/communities/community/migrations/0046_alter_communitysidebarmenu_module.py new file mode 100644 index 0000000..f7819d6 --- /dev/null +++ b/communities/community/migrations/0046_alter_communitysidebarmenu_module.py @@ -0,0 +1,31 @@ +# Generated by Django 5.0.8 on 2024-08-17 02:12 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("community", "0045_alter_communitysidebarmenu_module"), + ] + + operations = [ + migrations.AlterField( + model_name="communitysidebarmenu", + name="module", + field=models.TextField( + choices=[ + ("communities.preferences", "communities.preferences"), + ("communities.community", "communities.community"), + ("communities.dashboards", "communities.dashboards"), + ("media.gallery.core", "media.gallery.core"), + ("leagues.sports", "leagues.sports"), + ("leagues.matches", "leagues.matches"), + ("theodds.odds", "theodds.odds"), + ("player.wager", "player.wager"), + ], + help_text="Application to Include in the Menus", + max_length=200, + verbose_name="Module/AppName:", + ), + ), + ] diff --git a/communities/community/models.py b/communities/community/models.py index 5004324..025a4c0 100644 --- a/communities/community/models.py +++ b/communities/community/models.py @@ -1,3 +1,5 @@ +from logging import NullHandler + from django.db import models from django.contrib import admin import uuid @@ -454,6 +456,16 @@ class Meta: bool_value = models.BooleanField(verbose_name="Boolean Value", null=True, blank=True,default=False) uuid_value = models.UUIDField(verbose_name="UUID Value", null=True, blank=True) + def clear_all(self,confirm=False): + if confirm: + self.text_value = None + self.int_value = None + self.json_value = None + self.bin_value = None + self.bool_value = False + self.uuid_value = None + self.save() + def __str__(self): rstr = f"Community: {self.community.name} - Registry Setting {self.key}" if self.grouping_key: diff --git a/communities/community/templates/dashboard/community_admin/dashboard/index.html b/communities/community/templates/dashboard/community_admin/dashboard/index.html index c5374dc..e78d321 100644 --- a/communities/community/templates/dashboard/community_admin/dashboard/index.html +++ b/communities/community/templates/dashboard/community_admin/dashboard/index.html @@ -10,7 +10,7 @@ {% block bootstrap5_content %} - + diff --git a/communities/community/templates/dynapages/communities-community-installComplete-cover.html b/communities/community/templates/dynapages/communities-community-installComplete-cover.html index 1262acd..c523eb4 100644 --- a/communities/community/templates/dynapages/communities-community-installComplete-cover.html +++ b/communities/community/templates/dynapages/communities-community-installComplete-cover.html @@ -39,7 +39,7 @@ {% block bootstrap5_extra_head %}{% endblock %} - + diff --git a/communities/profiles/templates/communities_profiles/profile_dashboard_dynapage_wrapper.html b/communities/profiles/templates/communities_profiles/profile_dashboard_dynapage_wrapper.html index dc9242d..319942a 100644 --- a/communities/profiles/templates/communities_profiles/profile_dashboard_dynapage_wrapper.html +++ b/communities/profiles/templates/communities_profiles/profile_dashboard_dynapage_wrapper.html @@ -7,7 +7,7 @@ - +