diff --git a/areas/__pycache__/forms.cpython-38.pyc b/areas/__pycache__/forms.cpython-38.pyc index 8f2aaf5..c9f46ac 100644 Binary files a/areas/__pycache__/forms.cpython-38.pyc and b/areas/__pycache__/forms.cpython-38.pyc differ diff --git a/areas/__pycache__/views.cpython-38.pyc b/areas/__pycache__/views.cpython-38.pyc index 71cffa9..f424ff3 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 5766343..6032309 100644 --- a/areas/forms.py +++ b/areas/forms.py @@ -3,7 +3,6 @@ from django.forms import ModelForm from django.forms.widgets import TextInput from .models import Areas from django.contrib.auth.models import User -from django import forms class AreaAddAreaForm(forms.ModelForm): @@ -17,15 +16,4 @@ class AreaAddAreaForm(forms.ModelForm): } fields = ['name', 'color', 'desc'] - - #def __init__(self, user=None, *args, **kwargs): - # super().__init__(*args, **kwargs) - # if(user != None): - # users_of_agency = User.objects.filter(profile__agency__pk=user.profile.agency.pk) - # self.fields['usersfield'].queryset = users_of_agency -class AjaxForm(forms.ModelForm): - field = forms.CharField(max_length=200) - class Meta: - model = Areas - fields = ['name', 'color', 'desc'] \ No newline at end of file diff --git a/areas/views.py b/areas/views.py index a7aa98f..7ecf455 100644 --- a/areas/views.py +++ b/areas/views.py @@ -3,7 +3,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin from django.views.generic import CreateView, ListView, UpdateView, DetailView, DeleteView, View from .models import Areas from django.contrib import messages -from .forms import AreaAddAreaForm, AjaxForm +from .forms import AreaAddAreaForm from django.contrib.auth.models import User from django.http import HttpResponse, JsonResponse diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc index 79f6a40..e373470 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 2a34fc2..a77585b 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 f3231bd..46a5249 100644 --- a/digitaleagentur/settings.py +++ b/digitaleagentur/settings.py @@ -80,15 +80,16 @@ WSGI_APPLICATION = 'digitaleagentur.wsgi.application' # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases -#DATABASES = { -# 'default': { -# 'ENGINE': 'django.db.backends.mysql', -# 'NAME' : 'digitaleagentur', -# 'USER' : 'digitaleagentur', -# 'PASSWORD' : 'H9hzbzyBqtUCnZlIwL1qSrzh', -# 'PORT' : 3306 -# } -#} +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME' : 'digitaleagentur', + 'USER' : 'digitaleagentur', + 'PASSWORD' : 'H9hzbzyBqtUCnZlIwL1qSrzh', + 'PORT' : 3306 + } +} +''' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', @@ -98,7 +99,7 @@ DATABASES = { 'PORT' : 3306 } } - +''' # Password validation # https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators diff --git a/digitaleagentur/urls.py b/digitaleagentur/urls.py index 6f86747..1cfeebb 100644 --- a/digitaleagentur/urls.py +++ b/digitaleagentur/urls.py @@ -17,6 +17,7 @@ urlpatterns = [ path('admin/', admin.site.urls), path('dashboard/', include('users.urls'), name="dashboard"), path('areas/', include('areas.urls'), name="areas-management"), + path('tasks/', include('tasks.urls'), name="tasks-management"), path('password-reset/', auth_views.PasswordResetView.as_view(template_name='users/password_reset.html'), name='password-reset'), path('password-reset/done/', auth_views.PasswordResetDoneView.as_view(template_name='users/password_reset_done.html'), name='password_reset_done'), path('password-reset-confirm///', auth_views.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'), name='password_reset_confirm'), diff --git a/tasks/__pycache__/models.cpython-38.pyc b/tasks/__pycache__/models.cpython-38.pyc index 1927892..20ff2e8 100644 Binary files a/tasks/__pycache__/models.cpython-38.pyc and b/tasks/__pycache__/models.cpython-38.pyc differ diff --git a/tasks/models.py b/tasks/models.py index 71a8362..2df55ea 100644 --- a/tasks/models.py +++ b/tasks/models.py @@ -1,3 +1,32 @@ from django.db import models +from django.contrib.auth.models import User +from users.models import Agency +from django.urls import reverse +from areas.models import Areas +import datetime + +''' + +Model Tasks + +''' + +class Tasks(models.Model): + + agency = models.ForeignKey(Agency, on_delete=models.PROTECT) + area = models.ForeignKey(Areas, on_delete=models.PROTECT) + name = models.CharField(max_length=200, blank=False, default="") + desc = models.TextField(max_length=3000, blank=True) + usersfield = models.ManyToManyField(User, blank=True, related_name='users_in_task') + created_area_by = models.ForeignKey(User, on_delete=models.PROTECT) + created_area_date = models.DateField(default=datetime.date.today, blank=True) + visible = models.BooleanField(default=True) + + def __str__(self): + return f'{self.name}' + + # Hier Path für Templates des Models mit Parametern + def get_absolute_url(self): + return reverse('tasks-update', kwargs={'pk':self.pk}) + -# Create your models here. diff --git a/tasks/views.py b/tasks/views.py index 91ea44a..7abdd65 100644 --- a/tasks/views.py +++ b/tasks/views.py @@ -1,3 +1,43 @@ from django.shortcuts import render +from django.contrib.auth.mixins import LoginRequiredMixin +from django.views.generic import CreateView, ListView, UpdateView, DetailView, DeleteView, View +from .models import Tasks +from .forms import TasksAddTaskForm +from django.contrib import messages # Create your views here. +class TasksManagement(LoginRequiredMixin, ListView): + model = Tasks + # Adding active_link + # Loading only user same agency + # Change context and return for template-data + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + # # Get all Users of the Same Agency as logged user + tasks_of_agency = Tasks.objects.filter(agency__pk=self.request.user.profile.agency.pk) + context.update({'active_link' : 'tasksmanagement', 'tasks_of_agency':tasks_of_agency}) + return context + +class TasksAddTask(LoginRequiredMixin, CreateView): + model = Tasks + success_url = '/tasks' + form_class = TasksAddTaskForm + + #def get(self,request,*args, **kwargs): + # # User ist der hier Aufgerufene, bzw. das Profil! + # return render (request, self.template_name, {'form':self.form_class(self.request.user), 'active_link': 'areasmanagement'}) + + + # Adding active_link + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context.update({'active_link' : 'tasksmanagement'}) + return context + + def form_valid(self, form): + # Send message to the site + messages.success(self.request, f'Aufgabe angelegt!') + # SAVE OBJECTS TO SIGNALE! + form.instance.agency = self.request.user.profile.agency + form.instance.created_area_by = self.request.user + return super().form_valid(form) diff --git a/users/__pycache__/models.cpython-38.pyc b/users/__pycache__/models.cpython-38.pyc index 81262ec..a25dac1 100644 Binary files a/users/__pycache__/models.cpython-38.pyc and b/users/__pycache__/models.cpython-38.pyc differ diff --git a/users/models.py b/users/models.py index 049e148..3b3772d 100644 --- a/users/models.py +++ b/users/models.py @@ -102,6 +102,7 @@ class Profile(models.Model): permissions = [ ('agency_change', 'Agenturinformationen verändern'), ('users_usermanagement', 'Benutzer bearbeiten'), + ('areas_management', 'Bereiche bearbeiten'), ('tasks_management', 'Aufgabenbereiche bearbeiten'), - ('areas_management', 'Bereiche bearbeiten') - ] \ No newline at end of file + ('standard_management', 'Standards bearbeiten und freischalten') + ] \ No newline at end of file diff --git a/users/templates/users/base.html b/users/templates/users/base.html index 710a1cf..9ab6139 100644 --- a/users/templates/users/base.html +++ b/users/templates/users/base.html @@ -126,7 +126,7 @@ {% else%}