diff --git a/areas/__pycache__/forms.cpython-38.pyc b/areas/__pycache__/forms.cpython-38.pyc
index e09ff6f..e247762 100644
Binary files a/areas/__pycache__/forms.cpython-38.pyc and b/areas/__pycache__/forms.cpython-38.pyc differ
diff --git a/areas/__pycache__/urls.cpython-38.pyc b/areas/__pycache__/urls.cpython-38.pyc
index ddff2d1..20e1575 100644
Binary files a/areas/__pycache__/urls.cpython-38.pyc and b/areas/__pycache__/urls.cpython-38.pyc differ
diff --git a/areas/__pycache__/views.cpython-38.pyc b/areas/__pycache__/views.cpython-38.pyc
index 7b9f003..f12ca16 100644
Binary files a/areas/__pycache__/views.cpython-38.pyc and b/areas/__pycache__/views.cpython-38.pyc differ
diff --git a/areas/forms.py b/areas/forms.py
index 61151d8..6032309 100644
--- a/areas/forms.py
+++ b/areas/forms.py
@@ -12,9 +12,8 @@ class AreaAddAreaForm(forms.ModelForm):
"name" : "Bereichsname",
"color" : "Farbe",
"desc" : "Beschreibung",
- "visible": "Im Organigramm sichtbar",
- "areaorder": "Sortierung"
+ "visible": "Im Organigramm sichtbar"
}
- fields = ['name', 'color', 'desc', 'areaorder']
+ fields = ['name', 'color', 'desc']
diff --git a/areas/templates/areas/areas_management.html b/areas/templates/areas/areas_management.html
index 04bf6c4..99c2f50 100644
--- a/areas/templates/areas/areas_management.html
+++ b/areas/templates/areas/areas_management.html
@@ -1,5 +1,6 @@
{% extends "users/base.html" %}
{% block content %}
+
Bereichsverwaltung
@@ -28,7 +29,7 @@
{% for item in areas_of_agency %}
-
+
| {{ item.name }} |
{{ item.created_area_by.first_name }} {{ item.created_area_by.last_name }} |
{{ item.created_area_date }} |
@@ -53,6 +54,7 @@
+
{% endblock content %}
diff --git a/areas/urls.py b/areas/urls.py
index c6c0640..8d50d0b 100644
--- a/areas/urls.py
+++ b/areas/urls.py
@@ -16,7 +16,8 @@ urlpatterns = [
path('addarea/', permission_required('users.areas_management')(AreasAddArea.as_view(template_name="areas/areas_add.html")), name='areas-addarea'),
path('areas//delete', permission_required('users.areas_management')(AreaDeleteView.as_view()), name='areas-delete'),
path('area//', permission_required('users.areas_management')(AreaUpdateView.as_view()), name='areas-manage'),
- path('areaajax/', views.area_addareas_ajax, name="area-ajaxview")
+ path('areaajax/', views.area_addareas_ajax, name="area-ajaxview"),
+ path('updateorder/', views.area_neworder, name="area-ajaxorder")
]
diff --git a/areas/views.py b/areas/views.py
index 47a209d..96880b1 100644
--- a/areas/views.py
+++ b/areas/views.py
@@ -6,7 +6,7 @@ from django.contrib import messages
from .forms import AreaAddAreaForm
from django.contrib.auth.models import User
from django.http import HttpResponse, JsonResponse
-
+import json
class AreasManagement(LoginRequiredMixin, ListView):
@@ -17,7 +17,7 @@ class AreasManagement(LoginRequiredMixin, ListView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# # Get all Users of the Same Agency as logged user
- areas_of_agency = Areas.objects.filter(agency__pk=self.request.user.profile.agency.pk)
+ areas_of_agency = Areas.objects.filter(agency__pk=self.request.user.profile.agency.pk).order_by('areaorder')
context.update({'active_link' : 'areasmanagement', 'areas_of_agency':areas_of_agency})
return context
@@ -129,5 +129,30 @@ def area_addareas_ajax(request):
# Counter for remaining users to show/hide "Keine Mitarbeiter"-Div
remaining_users_counter = len(added_users)
return JsonResponse({'userid' : userid, 'username_clean' : username_clean, 'remaining_users':possible_users_js, 'remaining_users_counter' : final_possible_users})
+ else:
+ return HttpResponse("Request method is not a GET")
+
+'''
+
+ Update the Area-Order by drag and drop. Save per ID and order in table, example:
+ ID ORDER
+ 0 --> 0
+ 4 --> 1
+ 2 --> 2
+ 5 --> 3
+
+ Triggered by ajax in areas_management.html
+ Save all areas after drag n drop elements in table
+
+'''
+def area_neworder(request):
+ if request.method == 'GET':
+ if request.GET['action'] == 'newareaorder':
+ neworderdata = json.loads(request.GET['finalod'])
+ for ele in neworderdata:
+ area = Areas.objects.get(pk=ele['id'])
+ area.areaorder = ele['neworder']
+ area.save()
+ return HttpResponse("UPDATED")
else:
return HttpResponse("Request method is not a GET")
\ No newline at end of file
diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc
index b6d3f6d..ee5a4f7 100644
Binary files a/digitaleagentur/__pycache__/settings.cpython-38.pyc and b/digitaleagentur/__pycache__/settings.cpython-38.pyc differ
diff --git a/digitaleagentur/__pycache__/urls.cpython-38.pyc b/digitaleagentur/__pycache__/urls.cpython-38.pyc
index f832d29..fe17211 100644
Binary files a/digitaleagentur/__pycache__/urls.cpython-38.pyc and b/digitaleagentur/__pycache__/urls.cpython-38.pyc differ
diff --git a/digitaleagentur/settings.py b/digitaleagentur/settings.py
index f37f049..e005d6a 100644
--- a/digitaleagentur/settings.py
+++ b/digitaleagentur/settings.py
@@ -16,6 +16,8 @@ import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+# FOR SUMMERNOTE ORIGIN
+X_FRAME_OPTIONS = 'SAMEORIGIN'
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
@@ -40,6 +42,7 @@ INSTALLED_APPS = [
'crispy_forms',
'colorful',
'ckeditor',
+ 'django_summernote',
'ckeditor_uploader',
'django.contrib.admin',
'django.contrib.auth',
diff --git a/digitaleagentur/urls.py b/digitaleagentur/urls.py
index 024d6ec..40fc5c6 100644
--- a/digitaleagentur/urls.py
+++ b/digitaleagentur/urls.py
@@ -40,6 +40,7 @@ urlpatterns = [
path('password-reset-complete/', auth_views.PasswordResetCompleteView.as_view(template_name='users/password_reset_complete.html'), name='password_reset_complete'),
path('register/', AgencyCreateView.as_view(template_name='users/register.html'), name='register'),
path('register/done', views.registerdone, name='register-done'),
+ path('summernote/', include('django_summernote.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)