diff --git a/areas/__pycache__/__init__.cpython-38.pyc b/areas/__pycache__/__init__.cpython-38.pyc index 3ff9165..3fed716 100644 Binary files a/areas/__pycache__/__init__.cpython-38.pyc and b/areas/__pycache__/__init__.cpython-38.pyc differ diff --git a/areas/__pycache__/admin.cpython-38.pyc b/areas/__pycache__/admin.cpython-38.pyc index c67ec55..f4e758a 100644 Binary files a/areas/__pycache__/admin.cpython-38.pyc and b/areas/__pycache__/admin.cpython-38.pyc differ diff --git a/areas/__pycache__/apps.cpython-38.pyc b/areas/__pycache__/apps.cpython-38.pyc index e7a6b78..9290f60 100644 Binary files a/areas/__pycache__/apps.cpython-38.pyc and b/areas/__pycache__/apps.cpython-38.pyc differ diff --git a/areas/__pycache__/forms.cpython-38.pyc b/areas/__pycache__/forms.cpython-38.pyc index c9f46ac..b1a2c81 100644 Binary files a/areas/__pycache__/forms.cpython-38.pyc and b/areas/__pycache__/forms.cpython-38.pyc differ diff --git a/areas/__pycache__/models.cpython-38.pyc b/areas/__pycache__/models.cpython-38.pyc index 83d08a8..04f8d72 100644 Binary files a/areas/__pycache__/models.cpython-38.pyc and b/areas/__pycache__/models.cpython-38.pyc differ diff --git a/areas/__pycache__/urls.cpython-38.pyc b/areas/__pycache__/urls.cpython-38.pyc index ddff2d1..7683456 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 f424ff3..87369de 100644 Binary files a/areas/__pycache__/views.cpython-38.pyc and b/areas/__pycache__/views.cpython-38.pyc differ diff --git a/areas/migrations/__pycache__/0001_initial.cpython-38.pyc b/areas/migrations/__pycache__/0001_initial.cpython-38.pyc index 4b1a5c3..77c5047 100644 Binary files a/areas/migrations/__pycache__/0001_initial.cpython-38.pyc and b/areas/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/areas/migrations/__pycache__/__init__.cpython-38.pyc b/areas/migrations/__pycache__/__init__.cpython-38.pyc index 1f7cdb4..2cd3248 100644 Binary files a/areas/migrations/__pycache__/__init__.cpython-38.pyc and b/areas/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/digitaleagentur/__pycache__/__init__.cpython-38.pyc b/digitaleagentur/__pycache__/__init__.cpython-38.pyc index f932871..1ffa496 100644 Binary files a/digitaleagentur/__pycache__/__init__.cpython-38.pyc and b/digitaleagentur/__pycache__/__init__.cpython-38.pyc differ diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc index 3fbb428..9e8bb66 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 3e562f2..8e71126 100644 Binary files a/digitaleagentur/__pycache__/urls.cpython-38.pyc and b/digitaleagentur/__pycache__/urls.cpython-38.pyc differ diff --git a/digitaleagentur/__pycache__/views.cpython-38.pyc b/digitaleagentur/__pycache__/views.cpython-38.pyc index ecd32fe..268c51d 100644 Binary files a/digitaleagentur/__pycache__/views.cpython-38.pyc and b/digitaleagentur/__pycache__/views.cpython-38.pyc differ diff --git a/digitaleagentur/__pycache__/wsgi.cpython-38.pyc b/digitaleagentur/__pycache__/wsgi.cpython-38.pyc index 3e8074e..c66704f 100644 Binary files a/digitaleagentur/__pycache__/wsgi.cpython-38.pyc and b/digitaleagentur/__pycache__/wsgi.cpython-38.pyc differ diff --git a/digitaleagentur/urls.py b/digitaleagentur/urls.py index f900d7b..a0420a3 100644 --- a/digitaleagentur/urls.py +++ b/digitaleagentur/urls.py @@ -6,7 +6,7 @@ from django.conf.urls.static import static from users.views import AgencyCreateView from . import views from ckeditor_uploader.views import upload - +from django.contrib.auth.decorators import login_required ''' ADMINPAGE - Verwaltung der Super-User - LOGIN-Page @@ -26,8 +26,12 @@ urlpatterns = [ path('password-reset-confirm///', auth_views.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'), name='password_reset_confirm'), 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('ckeditor/', include('ckeditor_uploader.urls')), + path('register/done', views.registerdone, name='register-done') ] if settings.DEBUG: - urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +urlpatterns += [ + path(r'^ckeditor/upload/', login_required(upload), name='ckeditor_upload'), + path(r'^ckeditor/', include('ckeditor_uploader.urls')), +] \ No newline at end of file diff --git a/media/uploadsCK/2019/12/05/0002.png b/media/uploadsCK/2019/12/05/0002.png new file mode 100644 index 0000000..5ac0ecb Binary files /dev/null and b/media/uploadsCK/2019/12/05/0002.png differ diff --git a/media/uploadsCK/2019/12/05/0002_thumb.png b/media/uploadsCK/2019/12/05/0002_thumb.png new file mode 100644 index 0000000..78b6882 Binary files /dev/null and b/media/uploadsCK/2019/12/05/0002_thumb.png differ diff --git a/media/uploadsCK/2019/12/05/0009.png b/media/uploadsCK/2019/12/05/0009.png new file mode 100644 index 0000000..5d0acaa Binary files /dev/null and b/media/uploadsCK/2019/12/05/0009.png differ diff --git a/media/uploadsCK/2019/12/05/0009_thumb.png b/media/uploadsCK/2019/12/05/0009_thumb.png new file mode 100644 index 0000000..1fd1018 Binary files /dev/null and b/media/uploadsCK/2019/12/05/0009_thumb.png differ diff --git a/media/uploadsCK/2019/12/05/0829d2ece9919052d3dc3dcd3aada422.jpg b/media/uploadsCK/2019/12/05/0829d2ece9919052d3dc3dcd3aada422.jpg new file mode 100644 index 0000000..3610b45 Binary files /dev/null and b/media/uploadsCK/2019/12/05/0829d2ece9919052d3dc3dcd3aada422.jpg differ diff --git a/media/uploadsCK/2019/12/05/0829d2ece9919052d3dc3dcd3aada422_thumb.jpg b/media/uploadsCK/2019/12/05/0829d2ece9919052d3dc3dcd3aada422_thumb.jpg new file mode 100644 index 0000000..24fcf0d Binary files /dev/null and b/media/uploadsCK/2019/12/05/0829d2ece9919052d3dc3dcd3aada422_thumb.jpg differ diff --git a/media/userprofilepics/0002.png b/media/userprofilepics/0002.png new file mode 100644 index 0000000..09c9586 Binary files /dev/null and b/media/userprofilepics/0002.png differ diff --git a/standards/__pycache__/__init__.cpython-38.pyc b/standards/__pycache__/__init__.cpython-38.pyc index 3efa48c..10c9914 100644 Binary files a/standards/__pycache__/__init__.cpython-38.pyc and b/standards/__pycache__/__init__.cpython-38.pyc differ diff --git a/standards/__pycache__/admin.cpython-38.pyc b/standards/__pycache__/admin.cpython-38.pyc index a4a2637..636f01b 100644 Binary files a/standards/__pycache__/admin.cpython-38.pyc and b/standards/__pycache__/admin.cpython-38.pyc differ diff --git a/standards/__pycache__/apps.cpython-38.pyc b/standards/__pycache__/apps.cpython-38.pyc index 4552384..4506211 100644 Binary files a/standards/__pycache__/apps.cpython-38.pyc and b/standards/__pycache__/apps.cpython-38.pyc differ diff --git a/standards/__pycache__/forms.cpython-38.pyc b/standards/__pycache__/forms.cpython-38.pyc index 1f39393..a5c0e28 100644 Binary files a/standards/__pycache__/forms.cpython-38.pyc and b/standards/__pycache__/forms.cpython-38.pyc differ diff --git a/standards/__pycache__/models.cpython-38.pyc b/standards/__pycache__/models.cpython-38.pyc index adaf8ca..d7f1d7e 100644 Binary files a/standards/__pycache__/models.cpython-38.pyc and b/standards/__pycache__/models.cpython-38.pyc differ diff --git a/standards/__pycache__/urls.cpython-38.pyc b/standards/__pycache__/urls.cpython-38.pyc index b0eb4a0..23f55f1 100644 Binary files a/standards/__pycache__/urls.cpython-38.pyc and b/standards/__pycache__/urls.cpython-38.pyc differ diff --git a/standards/__pycache__/views.cpython-38.pyc b/standards/__pycache__/views.cpython-38.pyc index 44ec7e8..d0f9ea2 100644 Binary files a/standards/__pycache__/views.cpython-38.pyc and b/standards/__pycache__/views.cpython-38.pyc differ diff --git a/standards/migrations/__pycache__/0001_initial.cpython-38.pyc b/standards/migrations/__pycache__/0001_initial.cpython-38.pyc index 8e4ffe6..7411eab 100644 Binary files a/standards/migrations/__pycache__/0001_initial.cpython-38.pyc and b/standards/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/standards/migrations/__pycache__/0002_auto_20191205_0809.cpython-38.pyc b/standards/migrations/__pycache__/0002_auto_20191205_0809.cpython-38.pyc index 176d9da..a457549 100644 Binary files a/standards/migrations/__pycache__/0002_auto_20191205_0809.cpython-38.pyc and b/standards/migrations/__pycache__/0002_auto_20191205_0809.cpython-38.pyc differ diff --git a/standards/migrations/__pycache__/__init__.cpython-38.pyc b/standards/migrations/__pycache__/__init__.cpython-38.pyc index 29deb7e..912f5d5 100644 Binary files a/standards/migrations/__pycache__/__init__.cpython-38.pyc and b/standards/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/standards/templates/standards/standard_area.html b/standards/templates/standards/standard_area.html new file mode 100644 index 0000000..d8125b9 --- /dev/null +++ b/standards/templates/standards/standard_area.html @@ -0,0 +1,50 @@ +{% extends "users/base.html" %} +{% block content %} +
+ +

Standards aus dem Bereich {{areaname}}

+
+
+ {% for item in standards_of_agency_area %} + {% if item.public or item.created_standard_by == user or perms.users.standard_management %} +
+
+
+ + {% if item.public %} +

{{item.name}}

+ {% else %} +

{{item.name}}

+ {% endif %} +
+ {% if item.created_standard_by == user or perms.users.standard_management %} + + {% endif %} +
+
+
{{item.created_standard_by.first_name}} {{item.created_standard_by.last_name}}
Zuletzt bearbeitet von {{ item.last_modified_by.first_name }} {{ item.last_modified_by.last_name }} am {{ item.last_modified_on }}
+ +

{{ item.content|truncatechars:250|safe}}

+
+
+
+ {% endif %} + {% endfor%} +
+
+{% endblock content %} diff --git a/standards/templates/standards/standard_task.html b/standards/templates/standards/standard_task.html new file mode 100644 index 0000000..2ea2f08 --- /dev/null +++ b/standards/templates/standards/standard_task.html @@ -0,0 +1,51 @@ +{% extends "users/base.html" %} +{% block content %} +
+ +

Standards aus dem Aufgabenbereich {{taskname}} des Bereichs {{areaname}}

+
+
+ {% for item in standards_of_agency_task %} + {% if item.public or item.created_standard_by == user or perms.users.standard_management %} +
+
+
+ + {% if item.public %} +

{{item.name}}

+ {% else %} +

{{item.name}}

+ {% endif %} +
+ {% if item.created_standard_by == user or perms.users.standard_management %} + + {% endif %} +
+
+
{{item.created_standard_by.first_name}} {{item.created_standard_by.last_name}}
Zuletzt bearbeitet von {{ item.last_modified_by.first_name }} {{ item.last_modified_by.last_name }} am {{ item.last_modified_on }}
+ +

{{ item.content|truncatechars:250|safe}}

+
+
+
+ {% endif %} + {% endfor%} +
+
+{% endblock content %} diff --git a/standards/templates/standards/standards_management.html b/standards/templates/standards/standards_management.html index 5ec02c8..ec18b60 100644 --- a/standards/templates/standards/standards_management.html +++ b/standards/templates/standards/standards_management.html @@ -1,7 +1,8 @@ {% extends "users/base.html" %} {% block content %}
-

Standards

+

Standards

+ Sichtbar sind alle veröffentlichten und von {{ user.first_name }} {{ user.last_name}} erstellten Standards. Nicht veröffentlichte sind gelb markiert.

Standards dokumentieren und erläutern verschiedenen Verfahren, strukturiert nach Bereichen und Aufgaben. @@ -14,32 +15,39 @@


{% for item in standards_of_agency %} -
-
-
-

{{item.name}}

- {% if item.created_standard_by == user or perms.users.standard_management %} - - + {% if item.created_standard_by == user or perms.users.standard_management %} + + {% endif %} +
+
+
{{item.created_standard_by.first_name}} {{item.created_standard_by.last_name}}
Zuletzt bearbeitet von {{ item.last_modified_by.first_name }} {{ item.last_modified_by.last_name }} am {{ item.last_modified_on }}
+ +

{{ item.content|truncatechars:250|safe}}

+
+
+
+ {% endif %} {% endfor%}
{% endblock content %} diff --git a/standards/templates/standards/standards_single.html b/standards/templates/standards/standards_single.html index f811221..c48bd7d 100644 --- a/standards/templates/standards/standards_single.html +++ b/standards/templates/standards/standards_single.html @@ -4,11 +4,12 @@ +

{{standard.name}}

Erstellt durch {{standard.created_standard_by.first_name}} {{standard.created_standard_by.last_name}} am {{standard.created_standard_date}} | Zuletzt bearbeitet von {{ standard.last_modified_by.first_name}} {{ standard.last_modified_by.last_name}} am {{ standard.last_modified_on}}

{{standard.media}} diff --git a/standards/templates/standards/standards_update.html b/standards/templates/standards/standards_update.html index 5995625..2ed8b7a 100644 --- a/standards/templates/standards/standards_update.html +++ b/standards/templates/standards/standards_update.html @@ -17,7 +17,7 @@ {% if standard_status == False %} Standard veröffentlichen  {% else %} - Standard unveröffentlichen  + Veröffentlichung aufheben  {% endif %} {% endif %} Abbrechen diff --git a/standards/urls.py b/standards/urls.py index 54f4842..132f2da 100644 --- a/standards/urls.py +++ b/standards/urls.py @@ -14,5 +14,7 @@ urlpatterns = [ path('ajax/loadtasks/', views.load_tasks, name='ajax_loadtasks'), path('standards//delete', StandardDeleteView.as_view(), name='standard-delete'), path('standard//changestat', views.StandardChangePublic, name="standard-status"), - path('standard//single', views.StandardSingle, name="standard-single") + path('standard//single', views.StandardSingle, name="standard-single"), + path('standard//area', views.StandardArea, name="standard-area"), + path('standard//task', views.StandardTask, name="standard-task") ] diff --git a/standards/views.py b/standards/views.py index 631ecb4..051e032 100644 --- a/standards/views.py +++ b/standards/views.py @@ -8,9 +8,10 @@ from django.http import HttpResponse, JsonResponse from .forms import StandardAddStandard, StandardAddStandardEditor, StandardUpdateStandard, StandardUpdateStandardEditor from django.contrib.auth.decorators import login_required from tasks.models import Tasks +from areas.models import Areas from datetime import datetime -# Create your views here. +# ALLE STANDARDS EINER AGENTUR class StandardsManagement(LoginRequiredMixin, ListView): model = Standards # Adding active_link @@ -23,32 +24,7 @@ class StandardsManagement(LoginRequiredMixin, ListView): context.update({'active_link' : 'standards', 'standards_of_agency' : standards_of_agency}) return context -''' -class StandardAdd(LoginRequiredMixin, CreateView): - model = Standards - success_url = '/standards' - form_class = StandardAddStandardForm - def get_form_kwargs(self): - kwargs = super(StandardAdd, self).get_form_kwargs() - kwargs['user'] = self.request.user - return kwargs - - def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - context.update({'active_link' : 'standards'}) - return context - - def form_valid(self, form): - # Send message to the site - messages.success(self.request, f'Standard angelegt!') - form.instance.agency = self.request.user.profile.agency - form.instance.created_standard_by = self.request.user - form.instance.published_by = self.request.user - form.instance.last_modifed_by = self.request.user - return super().form_valid(form) - -''' @login_required def StandardAdd(request): if request.method == 'POST': @@ -104,8 +80,17 @@ def StandardUpdate(request, id): existing_standard.task = normalForm.cleaned_data['task'] existing_standard.area = normalForm.cleaned_data['area'] existing_standard.name = normalForm.cleaned_data['name'] - existing_standard.content = editorForm.cleaned_data['content'] - if request.user.has_perm('standard_management'): + existing_standard.content = editorForm.cleaned_data['content'] + ''' + + AKTUALISIERUNG + + Wennn der User selbst den Standard erstellt hat und Rechte zur Standardverwaltung hat, + dann wird der Status nicht verändert (public bleibt true bzw. false). Hat der User + aber keine Rechte und ist der Standarf public, wird er auf public=false gesetzt! + + ''' + if request.user.has_perm('users.standard_management'): messages.success(request, f'Standard {existing_standard.name} aktualisiert!') else: if existing_standard.public: @@ -166,4 +151,34 @@ def StandardSingle(request, pk): 'active_link':'standards', 'standard' : standard } - return render(request, 'standards/standards_single.html', context) \ No newline at end of file + return render(request, 'standards/standards_single.html', context) + + +@login_required +def StandardArea(request, pk): + standards = Standards.objects.filter(agency__pk=request.user.profile.agency.pk).filter(area__pk=pk) + area = Areas.objects.get(pk=pk) + context = { + 'active_link':'standards', + 'standards_of_agency_area' : standards, + 'areaid' : pk, + 'areaname' : area.name + } + return render(request, 'standards/standard_area.html', context) + +@login_required +def StandardTask(request, pk): + standards = Standards.objects.filter(agency__pk=request.user.profile.agency.pk).filter(task__pk=pk) + task = Tasks.objects.get(pk=pk) + area = Areas.objects.get(pk=task.area.pk) + context = { + 'active_link':'standards', + 'standards_of_agency_task' : standards, + 'taskid' : pk, + 'taskname' : task.name, + 'areaid' : area.pk, + 'areaname' : area.name + } + return render(request, 'standards/standard_task.html', context) + + diff --git a/tasks/__pycache__/__init__.cpython-38.pyc b/tasks/__pycache__/__init__.cpython-38.pyc index 5761d3d..ba2b443 100644 Binary files a/tasks/__pycache__/__init__.cpython-38.pyc and b/tasks/__pycache__/__init__.cpython-38.pyc differ diff --git a/tasks/__pycache__/admin.cpython-38.pyc b/tasks/__pycache__/admin.cpython-38.pyc index 64cf5df..4785bcc 100644 Binary files a/tasks/__pycache__/admin.cpython-38.pyc and b/tasks/__pycache__/admin.cpython-38.pyc differ diff --git a/tasks/__pycache__/apps.cpython-38.pyc b/tasks/__pycache__/apps.cpython-38.pyc index 1b8289c..acb7215 100644 Binary files a/tasks/__pycache__/apps.cpython-38.pyc and b/tasks/__pycache__/apps.cpython-38.pyc differ diff --git a/tasks/__pycache__/forms.cpython-38.pyc b/tasks/__pycache__/forms.cpython-38.pyc index bfae0d8..7d05cbf 100644 Binary files a/tasks/__pycache__/forms.cpython-38.pyc and b/tasks/__pycache__/forms.cpython-38.pyc differ diff --git a/tasks/__pycache__/models.cpython-38.pyc b/tasks/__pycache__/models.cpython-38.pyc index 45cdb3b..d012e57 100644 Binary files a/tasks/__pycache__/models.cpython-38.pyc and b/tasks/__pycache__/models.cpython-38.pyc differ diff --git a/tasks/__pycache__/urls.cpython-38.pyc b/tasks/__pycache__/urls.cpython-38.pyc index fbe82ce..065fae8 100644 Binary files a/tasks/__pycache__/urls.cpython-38.pyc and b/tasks/__pycache__/urls.cpython-38.pyc differ diff --git a/tasks/__pycache__/views.cpython-38.pyc b/tasks/__pycache__/views.cpython-38.pyc index da2cc8e..1765bf2 100644 Binary files a/tasks/__pycache__/views.cpython-38.pyc and b/tasks/__pycache__/views.cpython-38.pyc differ diff --git a/tasks/migrations/__pycache__/0001_initial.cpython-38.pyc b/tasks/migrations/__pycache__/0001_initial.cpython-38.pyc index ff34734..decdf9d 100644 Binary files a/tasks/migrations/__pycache__/0001_initial.cpython-38.pyc and b/tasks/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/tasks/migrations/__pycache__/0002_tasks_name.cpython-38.pyc b/tasks/migrations/__pycache__/0002_tasks_name.cpython-38.pyc index d481111..3872823 100644 Binary files a/tasks/migrations/__pycache__/0002_tasks_name.cpython-38.pyc and b/tasks/migrations/__pycache__/0002_tasks_name.cpython-38.pyc differ diff --git a/tasks/migrations/__pycache__/0003_auto_20191205_0809.cpython-38.pyc b/tasks/migrations/__pycache__/0003_auto_20191205_0809.cpython-38.pyc index b9a34c0..212e6c2 100644 Binary files a/tasks/migrations/__pycache__/0003_auto_20191205_0809.cpython-38.pyc and b/tasks/migrations/__pycache__/0003_auto_20191205_0809.cpython-38.pyc differ diff --git a/tasks/migrations/__pycache__/__init__.cpython-38.pyc b/tasks/migrations/__pycache__/__init__.cpython-38.pyc index ded374b..42a7700 100644 Binary files a/tasks/migrations/__pycache__/__init__.cpython-38.pyc and b/tasks/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/tasks/views.py b/tasks/views.py index f78c9aa..c1a025b 100644 --- a/tasks/views.py +++ b/tasks/views.py @@ -6,6 +6,8 @@ from .models import Tasks from .forms import TasksAddTaskForm from django.contrib import messages from django.http import HttpResponse, JsonResponse +from users.priomodel import Prio + # Create your views here. class TasksManagement(LoginRequiredMixin, ListView): @@ -84,6 +86,13 @@ class TasksUpdateView(LoginRequiredMixin, UpdateView): context['objectid'] = context['object'].pk return context +''' + + Hier werden Aufgaben zu Mitarbeitern zugewiesen oder entfernt. Dabei wird bei jeder Aufgabe auch gleich ein + Prio-Objekt erzeugt/entfernt, damit der Mitarbeiter seine Prioritäten auf dem Organigramm einstellen kann. + +''' + def task_addtasks_ajax(request): if request.method == 'GET': @@ -92,11 +101,17 @@ def task_addtasks_ajax(request): task = Tasks.objects.get(pk=request.GET['objectid']) task.usersfield.add(User.objects.get(pk=request.GET['userid'])) task.save() + # PRIO + prio = Prio(user=User.objects.get(pk=request.GET['userid']), task=task) + prio.save() # REMOVE USER TO MANY-TO-MANY USERSFIELD elif request.GET['action'] == 'remuser': task = Tasks.objects.get(pk=request.GET['objectid']) task.usersfield.remove(User.objects.get(pk=request.GET['userid'])) task.save() + # DELETE PRIO + Prio.objects.filter(user__pk=request.GET['userid']).filter(task__pk=request.GET['objectid']).delete() + userid = request.GET['userid'] workinguser = User.objects.get(pk=userid) username_clean = workinguser.first_name + " " + workinguser.last_name diff --git a/users/__pycache__/__init__.cpython-38.pyc b/users/__pycache__/__init__.cpython-38.pyc index 1988400..09287f9 100644 Binary files a/users/__pycache__/__init__.cpython-38.pyc and b/users/__pycache__/__init__.cpython-38.pyc differ diff --git a/users/__pycache__/admin.cpython-38.pyc b/users/__pycache__/admin.cpython-38.pyc index a7ab0e1..131dcf0 100644 Binary files a/users/__pycache__/admin.cpython-38.pyc and b/users/__pycache__/admin.cpython-38.pyc differ diff --git a/users/__pycache__/apps.cpython-38.pyc b/users/__pycache__/apps.cpython-38.pyc index cea3da8..e12f316 100644 Binary files a/users/__pycache__/apps.cpython-38.pyc and b/users/__pycache__/apps.cpython-38.pyc differ diff --git a/users/__pycache__/models.cpython-38.pyc b/users/__pycache__/models.cpython-38.pyc index 30d9168..ca87c8f 100644 Binary files a/users/__pycache__/models.cpython-38.pyc and b/users/__pycache__/models.cpython-38.pyc differ diff --git a/users/__pycache__/priomodel.cpython-38.pyc b/users/__pycache__/priomodel.cpython-38.pyc new file mode 100644 index 0000000..e0c5566 Binary files /dev/null and b/users/__pycache__/priomodel.cpython-38.pyc differ diff --git a/users/__pycache__/signals.cpython-38.pyc b/users/__pycache__/signals.cpython-38.pyc index 5fbd890..46f1761 100644 Binary files a/users/__pycache__/signals.cpython-38.pyc and b/users/__pycache__/signals.cpython-38.pyc differ diff --git a/users/__pycache__/urls.cpython-38.pyc b/users/__pycache__/urls.cpython-38.pyc index 6495e0a..401209d 100644 Binary files a/users/__pycache__/urls.cpython-38.pyc and b/users/__pycache__/urls.cpython-38.pyc differ diff --git a/users/__pycache__/usersforms.cpython-38.pyc b/users/__pycache__/usersforms.cpython-38.pyc index 484239d..e972567 100644 Binary files a/users/__pycache__/usersforms.cpython-38.pyc and b/users/__pycache__/usersforms.cpython-38.pyc differ diff --git a/users/__pycache__/views.cpython-38.pyc b/users/__pycache__/views.cpython-38.pyc index 0d3488f..e4eb673 100644 Binary files a/users/__pycache__/views.cpython-38.pyc and b/users/__pycache__/views.cpython-38.pyc differ diff --git a/users/admin.py b/users/admin.py index cef3afa..e436278 100644 --- a/users/admin.py +++ b/users/admin.py @@ -1,5 +1,7 @@ from django.contrib import admin from .models import Profile, Agency +from .priomodel import Prio admin.site.register(Profile) admin.site.register(Agency) +admin.site.register(Prio) \ No newline at end of file diff --git a/users/migrations/0003_prio.py b/users/migrations/0003_prio.py new file mode 100644 index 0000000..d26f133 --- /dev/null +++ b/users/migrations/0003_prio.py @@ -0,0 +1,26 @@ +# Generated by Django 2.2.7 on 2019-12-05 17:41 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('tasks', '0003_auto_20191205_0809'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('users', '0002_auto_20191204_0857'), + ] + + operations = [ + migrations.CreateModel( + name='Prio', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('prio', models.IntegerField(default=0)), + ('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='tasks.Tasks')), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/users/migrations/__pycache__/0001_initial.cpython-38.pyc b/users/migrations/__pycache__/0001_initial.cpython-38.pyc index 86fdee3..ae1f439 100644 Binary files a/users/migrations/__pycache__/0001_initial.cpython-38.pyc and b/users/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/users/migrations/__pycache__/0002_auto_20191204_0857.cpython-38.pyc b/users/migrations/__pycache__/0002_auto_20191204_0857.cpython-38.pyc index ffe61ff..095b6ca 100644 Binary files a/users/migrations/__pycache__/0002_auto_20191204_0857.cpython-38.pyc and b/users/migrations/__pycache__/0002_auto_20191204_0857.cpython-38.pyc differ diff --git a/users/migrations/__pycache__/0003_prio.cpython-38.pyc b/users/migrations/__pycache__/0003_prio.cpython-38.pyc new file mode 100644 index 0000000..1a17aa4 Binary files /dev/null and b/users/migrations/__pycache__/0003_prio.cpython-38.pyc differ diff --git a/users/migrations/__pycache__/__init__.cpython-38.pyc b/users/migrations/__pycache__/__init__.cpython-38.pyc index e100748..d799506 100644 Binary files a/users/migrations/__pycache__/__init__.cpython-38.pyc and b/users/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/users/models.py b/users/models.py index 494e7eb..23ffc08 100644 --- a/users/models.py +++ b/users/models.py @@ -7,6 +7,7 @@ from PIL import Image from django.contrib.auth.models import AbstractUser, User from django.contrib.auth.models import Permission + # UNIQUE and NO BLANK fields while user-registration User._meta.get_field('email')._unique = True User._meta.get_field('email').blank = False @@ -105,4 +106,6 @@ class Profile(models.Model): ('areas_management', 'Bereiche bearbeiten'), ('tasks_management', 'Aufgabenbereiche bearbeiten'), ('standard_management', 'Standards bearbeiten und freischalten') - ] \ No newline at end of file + ] + + diff --git a/users/priomodel.py b/users/priomodel.py new file mode 100644 index 0000000..90fa395 --- /dev/null +++ b/users/priomodel.py @@ -0,0 +1,17 @@ +from django.db import models +from django.contrib.auth.models import User, AbstractBaseUser +from django.conf import settings + +from tasks.models import Tasks + + +''' + +Model zum Speichern der Priorisierungen von Aufgaben eines Nutzers + +''' + +class Prio(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE) + task = models.ForeignKey(Tasks, on_delete=models.CASCADE) + prio = models.IntegerField(default=0) \ No newline at end of file diff --git a/users/signals.py b/users/signals.py index e1b40fa..ce9c1ae 100644 --- a/users/signals.py +++ b/users/signals.py @@ -19,8 +19,7 @@ def create_profile(sender, instance, created, **kwargs): temprof = Profile for ele in temprof._meta.permissions: tempperm = Permission.objects.get(codename=ele[0]) - tempuser.user_permissions.add(tempperm) - + tempuser.user_permissions.add(tempperm) tempuser.save() diff --git a/users/templates/users/base.html b/users/templates/users/base.html index d86a39c..ee8fbee 100644 --- a/users/templates/users/base.html +++ b/users/templates/users/base.html @@ -194,6 +194,10 @@ Profil + + + Priorisierung + diff --git a/users/templates/users/users_management.html b/users/templates/users/users_management.html index 84a94f7..a77f2b8 100644 --- a/users/templates/users/users_management.html +++ b/users/templates/users/users_management.html @@ -29,7 +29,7 @@ Bearbeiten Rechte - Priorisierung + Priorisierung Bereiche diff --git a/users/templates/users/users_perm.html b/users/templates/users/users_perm.html index 34351c4..c9cc5f8 100644 --- a/users/templates/users/users_perm.html +++ b/users/templates/users/users_perm.html @@ -11,18 +11,6 @@
{% csrf_token %} {% for field in form %} - {% if field.name == 'users_usermanagement'%} - {% if user_tochange.pk != request.user.pk %} -
- {% if field.value %} - - {% else %} - - {% endif %} - -
- {%endif %} - {% else %}
{% if field.value %} @@ -30,8 +18,7 @@ {% endif %} -
- {% endif %} +
{% endfor %}
  diff --git a/users/templates/users/users_prio.html b/users/templates/users/users_prio.html new file mode 100644 index 0000000..900452f --- /dev/null +++ b/users/templates/users/users_prio.html @@ -0,0 +1,51 @@ +{% extends "users/base.html" %} +{% load crispy_forms_tags %} +{% block content %} +
+

Priorisierung von {{ user_first_name }} {{ user_last_name }} verändern

+ Elemente mit einer hohen Zahl werden im Organigramm weiter oben angezeigt. Die Änderungen werden sofort gespeichert. +
+
+ {% for area in areas %} +

Bereich {{ area.name }}

+ {% for prio in prios %} + {% if prio.task.area == area %} +
+ +
+
+
+ {% endif %} + {% endfor%} +
+ {% endfor %} +
+ Zum Dashboard +
+ + +{% endblock content %} + diff --git a/users/urls.py b/users/urls.py index ade566d..3053ac4 100644 --- a/users/urls.py +++ b/users/urls.py @@ -22,7 +22,9 @@ urlpatterns = [ path('usersman//perms', permission_required('users.users_usermanagement')(UsersPermUpdateView.as_view()), name='users-perm-update'), path('usersman//delete', permission_required('users.users_usermanagement')(ProfileDeleteView.as_view()), name='users-delete'), path('agencyinfo/', views.agency, name='agencyinfo'), - path('agencyinfo//', permission_required('users.agency_change')(AgencyUpdateView.as_view()), name='agency-manage'), + path('agencyinfo//', permission_required('users.agency_change')(AgencyUpdateView.as_view()), name='agency-manage'), + path('usersman//prio', views.UsersPrio, name='users-prio'), + path('prioupdate/', views.UsersPrioUpdate, name="users-prioupdate") ] diff --git a/users/usersforms.py b/users/usersforms.py index 32f2080..8c1c265 100644 --- a/users/usersforms.py +++ b/users/usersforms.py @@ -63,16 +63,15 @@ class UsersPermForm(forms.Form): Die erstellen Felder werden entsprechend den Feldern hinzugefügt und ausgegeben. @param: user - - User ist der aufgerufene User! - - ''' + ''' def __init__(self, user, *args, **kwargs): super().__init__(*args, **kwargs) temprof = Profile for ele in temprof._meta.permissions: - if isinstance(user, User): + if isinstance(user, User): if user.has_perm('users.' + ele[0]): - self.fields[ele[0]] = forms.BooleanField(initial=True, help_text=(ele[1])); + self.fields[ele[0]] = forms.BooleanField(required=False, initial=True, help_text=(ele[1])) else: - self.fields[ele[0]] = forms.BooleanField(initial=False, help_text=(ele[1])); \ No newline at end of file + self.fields[ele[0]] = forms.BooleanField(required=False, initial=False, help_text=(ele[1])) + diff --git a/users/views.py b/users/views.py index 1abdfa0..23d1235 100644 --- a/users/views.py +++ b/users/views.py @@ -10,16 +10,15 @@ from django.db import models from .models import Profile, Agency from django.core.mail import send_mail from django.contrib.auth.models import Permission -from django.http import HttpResponseRedirect - - +from django.http import HttpResponseRedirect,HttpResponse +from areas.models import Areas +from tasks.models import Tasks +from .priomodel import Prio ''' DASHBOARD-View -View nach erfolgreichem Login und anzeige des Dashboards. - -TODO: ROLLENVERTEILUNG +View nach erfolgreichem Login Dashboard Templates: welcomeusers.html und base.html @@ -109,19 +108,13 @@ class UsersCreateUser(LoginRequiredMixin, CreateView): # USER muss eingeloggt sein, um diese Seite zu sehen @login_required def profile(request): - # NEUE DATEN KOMMEN AN! if request.method == 'POST': - # Hier werden die Daten aus POST geholt und in die Instance(konkreten User) gespeichert u_form = UsersChangeProfil(request.POST, instance=request.user) - #p_form = UsersAddProfileForm(request.POST, request.FILES, instance=request.user.profile) - + if u_form.is_valid(): - #if u_form.is_valid() and p_form.is_valid(): u_form.save() - #p_form.save() prename = request.user.first_name name = request.user.last_name - #name = p_form.cleaned_data.get('name') messages.success(request, f'Daten für {prename} {name} aktualisiert!') # Daten neu laden und nicht die "Mächten sie die Daten speichern...?" return redirect('users-dashboard') @@ -148,6 +141,7 @@ class UserManagementUpdateForm(LoginRequiredMixin, UpdateView): } fields = ['phoneland','phonemobile','compfunc'] +# Update der Zugrifssrechte eines Users class UsersPermUpdateView(LoginRequiredMixin, View): template_name = 'users/users_perm.html' form_class = UsersPermForm @@ -160,11 +154,6 @@ class UsersPermUpdateView(LoginRequiredMixin, View): user_tochange = Profile.objects.get(pk=kwargs['pk']).user return render (request, self.template_name, {'form':self.form_class(user_tochange), 'active_link': 'usersmanagement', 'user_tochange': user_tochange}) - - #messages.success(self.request, f'Berechtigungen aktualisiert!') - #print(form) - #return super().form_valid(form) - # Handle POST GTTP requests def post(self, request, *args, **kwargs): permissions_loaded = dict(request.POST.lists()) @@ -178,7 +167,11 @@ class UsersPermUpdateView(LoginRequiredMixin, View): if ele[0] in permissions_loaded: user_tochange.user_permissions.add(tempperm) else: - user_tochange.user_permissions.remove(tempperm) + # Eingeloggter User darf sich nicht selbst die Userverwaltungsrechte entziehen + if user_tochange == request.user and ele[0]=='users_usermanagement': + messages.warning(request, f'Benutzerverwaltungsrechte für {user_tochange.first_name} {user_tochange.last_name} kann nicht entfernt werden.') + else: + user_tochange.user_permissions.remove(tempperm) user_tochange.save() messages.success(request, f'Berechtigungen für {user_tochange.first_name} {user_tochange.last_name} aktualisiert!') return HttpResponseRedirect('/dashboard/usersman/') @@ -213,8 +206,6 @@ class ProfileDeleteView(LoginRequiredMixin, DeleteView): return False return True - -# USER muss eingeloggt sein, um diese Seite zu sehen @login_required def agency(request): context = { @@ -233,4 +224,55 @@ class AgencyUpdateView(LoginRequiredMixin, UpdateView): def get_context_data(self, **kwargs): context = super(AgencyUpdateView, self).get_context_data(**kwargs) context['active_link'] = 'agencyinfo' - return context \ No newline at end of file + return context + + +# PRIORISIERUNG +''' + + Es werden alle Aufgabenbereiche den Bereichen der Agentur zugeordnet und ausgegeben. + +''' +def UsersPrio(request, pk): + user = User.objects.get(pk=pk) + + prios = Prio.objects.filter(user__pk=pk) + + areas = Areas.objects.filter(agency__pk=request.user.profile.agency.pk) + ''' + fulldata = [] + areas_dict = list(areas) + + for area in areas_dict: + fulldata.append({"areaname" : area.name, "area" : area, "tasks" : 0}) + + + for fulldataarea in fulldata: + tasks_of_area = Tasks.objects.filter(area__pk=fulldataarea['area'].pk).exclude(pk__in=prios) + fulldataarea['tasks'] = list(tasks_of_area) + print(fulldataarea) + + ''' + user_first_name = user.first_name + user_last_name = user.last_name + user_id = user.pk + context = { + 'active_link' : '', + 'areas' : areas, + 'user_first_name' : user_first_name, + 'user_last_name' : user_last_name, + 'user_id' : user_id, + 'prios' : prios + } + return render(request, 'users/users_prio.html', context) + +def UsersPrioUpdate(request): + if request.method == 'GET': + prio = Prio.objects.filter(user__pk=request.GET['userid']).filter(task__pk=request.GET['taskid']) + prio = list(prio)[0] + prio.prio = request.GET['value'] + prio.save() + return HttpResponse("udated...") + else: + return HttpResponse("Request method is not a GET") + \ No newline at end of file