Skip to content

Commit

Permalink
Merge branch 'ply-ng' of github.com:furrydelphia/ply into ply-ng
Browse files Browse the repository at this point in the history
  • Loading branch information
resba committed Jul 11, 2024
2 parents a6cf8e2 + a642596 commit 8930951
Show file tree
Hide file tree
Showing 60 changed files with 1,367 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<meta property="dynapage_template_version" content="v1.0"/>
<meta property="dynapage_template_author" content="Alisi"/>
<meta property="dynapage_template_description" content="A simple widget banner for profiles."/>
<meta property="dynapage_template_type" content="widgets"/>
{%if widget.banner == True or mode == "banner" %}
<div class="card"><div class="card_body">
<div class="widget_simpleBanner_main" data-widget="simpleBanner">
Expand Down
7 changes: 5 additions & 2 deletions DOCUMENTATION/examples/dynapages/widgets/simple_banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@
"icon":"fa-solid fa-address-card",
"setup_required":false,
"setup_form":"someclass.someform",
"system":false,
"modes":{
"banner":true,
"mainbody":true,
"sidecol":true,
"footer":true
"footer":true,
"dashboard": false
},
"used_in": {
"profile":true,
"group":true,
"dashboard":true,
"SLHUD":true,
"blog":true
"blog":true,
"staff":false
}
}
14 changes: 4 additions & 10 deletions communities/community/forge_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from communities.group.models import GroupMember
from core.dynapages import models as dynapages
from communities.profiles.models import ProfilePageNode
from ply.toolkit.contexts import admin_context
from ply.toolkit.core import get_ply_appinfo
from roleplaying.stats.models import ProfileStat
from roleplaying.exp.models import ProfileExperience
Expand Down Expand Up @@ -102,7 +103,7 @@ def default_profile_editor(request):
page=profilePage.dynapage
)
available_widgets = dynapages.Widget.objects.filter(active=True, profile=True)
print(available_widgets)
#print(available_widgets)00

exp = ProfileExperience.objects.get(community=community, profile=profile)
stats = ProfileStat.objects.filter(profile=profile)
Expand All @@ -126,17 +127,10 @@ def default_profile_editor(request):
@login_required
def sidebar_menu_editor(request):
# Ignore port:
context, vhost, community, profile = contexts.default_context(request)
context, vhost, community, profile = admin_context(request)
if community is None:
return render(request, "error-no_vhost_configured.html", {})
else:
request.session["community"] = str(community.uuid)
profile = profiles.get_active_profile(request)
is_admin = CommunityAdmins.objects.filter(
community=community, profile=profile, active=True
)
if len(is_admin) < 1:
return render(request, "error-access-denied.html", {})

current_menus = CommunitySidebarMenu.objects.filter(community=community)
context["current_menus"] = current_menus
context["menu_form"] = CommunitySidebarMenuForm(initial={"community":community})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 5.0.1 on 2024-06-20 16:33

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("community", "0037_communityregistrypageview"),
]

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"),
("ufls.event", "ufls.event"),
("ufls.registrar", "ufls.registrar"),
("ufls.staff", "ufls.staff"),
],
help_text="Application to Include in the Menus",
max_length=200,
verbose_name="Module/AppName:",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.drop-accept .badge {
visibility: hidden;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js" integrity="sha512-Meww2sXqNHxI1+5Dyh/9KAtvI9RZSA4c1K2k5iL02oiPO/RH3Q30L3M1albtqMg50u4gRTYdV4EXOQqXEI336A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://kit.fontawesome.com/4f00122db6.js" crossorigin="anonymous"></script>
<link href="/static/css/dashboard.css" rel="stylesheet">
<link href="/static/communities.community/css/dashboard/base.css" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lily+Script+One&display=swap" rel="stylesheet">
Expand All @@ -32,11 +33,18 @@



{%include "dashboard/dashboard_main_panel.html" %}
{% if dynapage %}
{%with "dynapages/"|add:dynapage.template.filename as src %}
{%include src %}
{%endwith %}

{% endif %}



</div>
</div>

<script src="https://unpkg.com/bs5-toast/dist/bs5-toast.js"></script>
<script type="module" src="/static/dashboard/js/dashboard.js"></script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<meta property="dynapage_template_version" content="v1.0"/>
<meta property="dynapage_template_author" content="Alisi"/>
<meta property="dynapage_template_description" content="The Basic Community Cover Page Main Page for \'Installation Complete!'\"/>
<meta property="dynapage_template_type" content="pages"/>
<meta id="og-title" property="og:title" content="{% block meta-og-title %}{{community.name}}{% endblock %}" />
<meta id="og-type" property="og:type" content="{% block meta-og-type %}https://{{vhost}}{% endblock %}" />
<meta id="og-url" property="og:url" content="{% block meta-og-url %}https://{{vhost}}{% endblock %}" />
Expand Down
5 changes: 3 additions & 2 deletions communities/dashboards/forge_api_urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.urls import path,include
from django.urls import path, include
from . import forge_api_views as views

urlpatterns = [

path("studio/load/<uuid:dashboard>", views.load_dashboard),
path("studio/widgets/load/<uuid:dashboard>",views.load_widgets_url)
]
46 changes: 43 additions & 3 deletions communities/dashboards/forge_api_views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,50 @@
from django.shortcuts import render
from django.contrib.auth.decorators import login_required

from django.db.models import Q
from django.http import JsonResponse, HttpResponse
from django.core import serializers
import ply
from ply.toolkit import vhosts,profiles
from communities.community.models import Friend_ExpLvl_View
from ply.toolkit import vhosts, profiles
from communities.community.models import (
Friend_ExpLvl_View,
CommunityDashboardType,
CommunityProfileDashboardRoles,
CommunityRegistryPageView,
)
from communities.profiles.models import Profile
from ply.toolkit.contexts import default_context, admin_context
from core.dynapages.models import Page, PageWidget,Widget
from ply.toolkit.dynapages import get_or_create_dynapage_node


# Create your views here.
@login_required
def load_dashboard(request, dashboard):
context, vhost, community, profile = admin_context(request)
dynapage = Page.objects.get(pk=dashboard)
widgets = PageWidget.objects.filter(page=dynapage)
context.update(
{
"dynapage": dynapage,
"widgets": widgets,
}
)
return render(
request, "communities.dashboards/studio/render_dashboard.html", context
)


def load_widgets_url(request, dashboard):
dynapage = Page.objects.get(pk=dashboard)
filters = {}
if dynapage.system == True:
filters["system"] = True
if dynapage.profile_page == True:
filters["profile"] = True
filters["system"] = False
if dynapage.widget_mode != False:
filters[f"{dynapage.widget_mode}"] = True
filter_q = Q(**filters)
aw = Widget.objects.filter(active=True).filter(filter_q)
available_widgets = serializers.serialize("json",aw)
return JsonResponse({"res": "ok","widgets":available_widgets})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.widget-card {
max-width: 250px;
cursor: grab;

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,64 @@
import { AbstractDashboardApp } from "/static/dashboard/js/Dashboard/AbstractDashboardApp.js";
export class DashboardStudio extends AbstractDashboardApp {
import {DynapageWidgetEditor} from "/static/core.dynapages/js/DynapageWidgetEditor/DynapageWidgetEditor.js";
export class DashboardStudio extends DynapageWidgetEditor {

widgets = {}

constructor(name) {
super(name);
constructor(name,settings) {
super(name,settings);
this.page_uuid = false
this.urls = {
"submit": "/dashboard/forge/api/media.gallery.core/settings/set"
"submit": "/dashboard/forge/api/media.gallery.core/settings/set",
"load_url":"/dashboard/forge/api/communities.dashboards/studio/load/",
"load_widgets_url":"/dashboard/forge/api/communities.dashboards/studio/widgets/load/"

}
this.elements = {
"modal": "#selectDashboardModal",
"dashboardSelector":"#dashboardSelect"
"dashboardSelector":"#dashboardSelect",
"container":"#dashboard_studio_container",
"offcanvas":"#studio_offCanvas",
"widget_container":"#widget_cards_bar"

}
}
_load_widget_bar_h(data) {
if (data.res == "ok") {
this.widgets = JSON.parse(data.widgets);
$(this.elements["widget_container"]).empty();
for (var w in this.widgets) {
var widget = this.widgets[w];
var card = this._createWidgetCard(widget.pk,widget.fields);
$(this.elements["widget_container"]).append(card);
card.draggable = true;

}

}

}
load_widget_bar() {
$.ajax({
url: this.urls["load_widgets_url"] + this.page_uuid,
context: this,
success: this._load_widget_bar_h,
dataType: "json"
});

}

load_dashboard(event) {
event.preventDefault();
event.stopPropagation();
this.page_uuid = $(this.elements["dashboardSelector"])[0].value;
if (this.page_uuid != "") {
this._hideModal();
$(this.elements["container"]).load(this.urls["load_url"]+this.page_uuid,false,$.proxy(this.start_edit,this));
this.load_widget_bar();
} else {
dashboard.normalToast("Select a Dashboard","Can't edit a blank dashboard!");
}

}
showModal() {
this._getModal();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
{%extends "dashboard/dashboard_main_panel-95.html" %}
{%block dashboard_name %}
Dashboard Studio

{%endblock%}

{%block dashboard_content %}
<link href="/static/communities.dashboards/css/dashboard/studio.css" rel="stylesheet">
<div id="studio_container" class="container-fluid">
Select Dashboard to load...
<!-- <nav class="navbar navbar-dark bg-success">-->
<!-- <div class="container-fluid">-->
<!-- Dashboard Editor: <span id="dashboard_name_spn"></span>-->
<!-- <div class="d-flex">-->

<!-- <button class="btn btn-outline-light text-light" type="button"><i class="fa-solid fa-bars"></i></button>-->
<!-- </div>-->
<!-- </div>-->
<!--</nav>-->

<div id="dashboard_studio_container">

</div>
</div>


{% include "communities.dashboards/studio/offcanvas/widget_bar.html" %}
{% include "communities.dashboards/studio/modals/select_dashboard.html" %}
{%endblock%}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="offcanvas offcanvas-bottom" data-bs-scroll="true" data-bs-backdrop="false" tabindex="-1" id="studio_offCanvas" aria-labelledby="studio_offCanvasLabel" class="studio_offcanvas">
<div class="offcanvas-header">
<h6 class="offcanvas-title" id="studio_offCanvasLabel">Widget Selector - <span style="font-size: 11px;" class="text-muted">Drag and drop widgets from this bar into the Dashboard area above. Changes are saved automatically.</span></h6>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body small">
<div class="card-group" id="widget_cards_bar">
{% for widget in available_widgets %}
<!-- {{widget.type}}-->
{%include "dynapages_tools/widget_editor/widget_card.html" %}
{% endfor %}
</div>
</div>
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{%extends "dashboard/dashboard_main_panel-95.html" %}
{%block dashboard_content %}
<div class="container-fluid main-container" id="dashboard_mainPanel">

{%with "dynapages/"|add:dynapage.template.filename as src %}
{%include src %}
{%endwith %}

</div>
{%endblock%}
4 changes: 2 additions & 2 deletions communities/preferences/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
@transaction.atomic
def save_system_settings(request):
uprefs = Preferences.objects.get_or_create(user=request.user)[0]
form_saver = PreferencesForm(request.POST,instance=prefs)
form_saver = PreferencesForm(request.POST,instance=uprefs)
if (not form_saver.is_valid()):
return JsonResponse({"res":"err","e":str(form_saver.errors.as_data())},safe=False)
form_saver.save()
return JsonResponse("ok",safe=False)
return JsonResponse({"res":"ok"},safe=False)
2 changes: 1 addition & 1 deletion communities/preferences/dashboard_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ def system_settings(request):
"av_path": settings.PLY_AVATAR_FILE_URL_BASE_URL,
"url_path": request.path,
"preferencesForm": preferencesForm,
"ply_version": vers.get_version_str()
"ply_version": vers
}
return render(request, "preferences-system_settings.html", context)
38 changes: 38 additions & 0 deletions communities/preferences/ply_appinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# The PLY Appinfo class defines ply-specific details for the given application.
PLY_APP_INFO = {
"app_name": "Ply Preferences",
"app_module": "communities.preferences",
"version": {
"release":2024,
"major":0x7e8,
"minor":0x3e9
},
"required_versions": {
"featureset_major": 0x7e8,
"featureset_minor": 0x3e9,
},

"dashboard_modes": {
"user":{
"privileged": False,
"default": True,
"active": True,
"descr": "The default user dashboard!",
"menu_class": "sidebar_menu",
},
"forge":{
"privileged": True,
"default": False,
"active": True,
"descr": "The WorldForge/World admin dashboard mode",
"menu_class": "sidebar_forge",
},
#"staff": {
# "privileged": True,
# "default": False,
# "active": False,
# "descr": "The Staff dashboard mode",
# "menu_class": "sidebar_staff",
# },
},
}
Loading

0 comments on commit 8930951

Please sign in to comment.