Nochmal richtig Commited
This commit is contained in:
parent
9eb1a4c9b7
commit
d53020c056
|
|
@ -38,6 +38,8 @@ INSTALLED_APPS = [
|
||||||
'standards.apps.StandardsConfig',
|
'standards.apps.StandardsConfig',
|
||||||
'crispy_forms',
|
'crispy_forms',
|
||||||
'colorful',
|
'colorful',
|
||||||
|
'ckeditor',
|
||||||
|
'ckeditor_uploader',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
|
|
@ -76,7 +78,39 @@ TEMPLATES = [
|
||||||
|
|
||||||
WSGI_APPLICATION = 'digitaleagentur.wsgi.application'
|
WSGI_APPLICATION = 'digitaleagentur.wsgi.application'
|
||||||
|
|
||||||
|
# CKEDITOR
|
||||||
|
CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'
|
||||||
|
|
||||||
|
CKEDITOR_UPLOAD_PATH = "uploadsCK/" # <-- this folder you uploaded image saved in s3 under media folder
|
||||||
|
CKEDITOR_RESTRICT_BY_USER = True
|
||||||
|
CKEDITOR_REQUIRE_STAFF=False
|
||||||
|
AWS_QUERYSTRING_AUTH = True
|
||||||
|
CKEDITOR_IMAGE_BACKEND = "pillow"
|
||||||
|
CKEDITOR_CONFIGS = {
|
||||||
|
'default': {
|
||||||
|
'skin': 'moono-lisa',
|
||||||
|
'toolbar_Basic': [
|
||||||
|
['Source', '-', 'Bold', 'Italic']
|
||||||
|
],
|
||||||
|
'toolbar_YourCustomToolbarConfig': [
|
||||||
|
{'name': 'basicstyles',
|
||||||
|
'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']},
|
||||||
|
{'name': 'paragraph',
|
||||||
|
'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-',
|
||||||
|
'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl',
|
||||||
|
'Language']},
|
||||||
|
{'name': 'links', 'items': ['Link', 'Unlink']},
|
||||||
|
{'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']},
|
||||||
|
{'name': 'colors', 'items': ['TextColor', 'BGColor']},
|
||||||
|
{'name': 'tools', 'items': ['Maximize', 'ShowBlocks']},
|
||||||
|
{'name': 'insert',
|
||||||
|
'items': ['Image', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak']},
|
||||||
|
'/', # put this to force next toolbar on new line
|
||||||
|
],
|
||||||
|
'toolbar': 'YourCustomToolbarConfig', # put selected toolbar config here
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ from django.conf import settings
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from users.views import AgencyCreateView
|
from users.views import AgencyCreateView
|
||||||
from . import views
|
from . import views
|
||||||
|
from ckeditor_uploader.views import upload
|
||||||
|
|
||||||
'''
|
'''
|
||||||
ADMINPAGE - Verwaltung der Super-User
|
ADMINPAGE - Verwaltung der Super-User
|
||||||
- LOGIN-Page
|
- LOGIN-Page
|
||||||
|
|
@ -18,12 +20,14 @@ urlpatterns = [
|
||||||
path('dashboard/', include('users.urls'), name="dashboard"),
|
path('dashboard/', include('users.urls'), name="dashboard"),
|
||||||
path('areas/', include('areas.urls'), name="areas-management"),
|
path('areas/', include('areas.urls'), name="areas-management"),
|
||||||
path('tasks/', include('tasks.urls'), name="tasks-management"),
|
path('tasks/', include('tasks.urls'), name="tasks-management"),
|
||||||
|
path('standards/', include('standards.urls'), name="standards"),
|
||||||
path('password-reset/', auth_views.PasswordResetView.as_view(template_name='users/password_reset.html'), name='password-reset'),
|
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/done/', auth_views.PasswordResetDoneView.as_view(template_name='users/password_reset_done.html'), name='password_reset_done'),
|
||||||
path('password-reset-confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'), name='password_reset_confirm'),
|
path('password-reset-confirm/<uidb64>/<token>/', 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('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/', AgencyCreateView.as_view(template_name='users/register.html'), name='register'),
|
||||||
path('register/done', views.registerdone, name='register-done')
|
path('register/done', views.registerdone, name='register-done'),
|
||||||
|
path('ckeditor/', include('ckeditor_uploader.urls')),
|
||||||
]
|
]
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 281 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 281 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 842 B |
Binary file not shown.
|
After Width: | Height: | Size: 281 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 838 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,3 +1,5 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from .models import Standards
|
||||||
|
# Register your models here.
|
||||||
|
admin.site.register(Standards)
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
from django import forms
|
||||||
|
from django.forms import ModelForm
|
||||||
|
from .models import Standards
|
||||||
|
from areas.models import Areas
|
||||||
|
from tasks.models import Tasks
|
||||||
|
from ckeditor.widgets import CKEditorWidget
|
||||||
|
|
||||||
|
class StandardAddStandard(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model =Standards
|
||||||
|
labels = {
|
||||||
|
"name" : "Titel",
|
||||||
|
"area" : "Übergeordneter Bereich",
|
||||||
|
"task" : "Aufgabenbereich",
|
||||||
|
}
|
||||||
|
fields = ['name', 'area', 'task']
|
||||||
|
'''
|
||||||
|
|
||||||
|
Hier werden die Elemente für die DropDowns erstellt, damit
|
||||||
|
ein Standard nur einem Aufgabenbereich aus einem Bereich zugewiesen wird.
|
||||||
|
|
||||||
|
Damit nach der Auswahl des Bereichs auch eine valide Aufgabe ankommt, wird diese
|
||||||
|
hier manuel validiert und das Query-Set mit der Bereichsauswahl geladen.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(StandardAddStandard, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['area'].queryset = Areas.objects.filter(agency__pk=kwargs['instance'].profile.agency.pk)
|
||||||
|
self.fields['task'].queryset = Tasks.objects.none()
|
||||||
|
if 'area' in self.data:
|
||||||
|
try:
|
||||||
|
areaid = int(self.data.get('area'))
|
||||||
|
self.fields['task'].queryset = Tasks.objects.filter(area__id=areaid).order_by('name')
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
elif self.instance.pk:
|
||||||
|
self.fields['task'].queryset = Tasks.objects.none()
|
||||||
|
|
||||||
|
|
||||||
|
class StandardAddStandardEditor(forms.ModelForm):
|
||||||
|
|
||||||
|
#content = forms.CharField(widget=CKEditorWidget())
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Standards
|
||||||
|
labels = {
|
||||||
|
"content" : "Inhalt"
|
||||||
|
}
|
||||||
|
fields = ['content']
|
||||||
|
|
||||||
|
|
||||||
|
class StandardUpdateStandard(forms.ModelForm):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model =Standards
|
||||||
|
labels = {
|
||||||
|
"name" : "Titel",
|
||||||
|
"area" : "Übergeordneter Bereich",
|
||||||
|
"task" : "Aufgabenbereich",
|
||||||
|
}
|
||||||
|
fields = ['name', 'area', 'task']
|
||||||
|
'''
|
||||||
|
|
||||||
|
Hier werden die Elemente für die DropDowns erstellt, damit
|
||||||
|
ein Standard nur einem Aufgabenbereich aus einem Bereich zugewiesen wird.
|
||||||
|
|
||||||
|
Damit nach der Auswahl des Bereichs auch eine valide Aufgabe ankommt, wird diese
|
||||||
|
hier manuel validiert und das Query-Set mit der Bereichsauswahl geladen.
|
||||||
|
|
||||||
|
'''
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
loggeduser = kwargs['instance'].created_standard_by
|
||||||
|
standard = kwargs['instance']
|
||||||
|
super(StandardUpdateStandard, self).__init__(*args, **kwargs)
|
||||||
|
self.fields['area'].queryset = Areas.objects.filter(agency__pk=loggeduser.profile.agency.pk)
|
||||||
|
# Dummy PK
|
||||||
|
self.fields['task'].queryset = Tasks.objects.filter(area__pk=standard.area.pk)
|
||||||
|
if 'area' in self.data:
|
||||||
|
try:
|
||||||
|
areaid = int(self.data.get('area'))
|
||||||
|
self.fields['task'].queryset = Tasks.objects.filter(area__id=areaid).order_by('name')
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
pass
|
||||||
|
elif loggeduser.pk:
|
||||||
|
self.fields['task'].queryset = Tasks.objects.filter(area__pk=standard.area.pk)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class StandardUpdateStandardEditor(forms.ModelForm):
|
||||||
|
|
||||||
|
#content = forms.CharField(widget=CKEditorWidget())
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Standards
|
||||||
|
labels = {
|
||||||
|
"content" : "Inhalt"
|
||||||
|
}
|
||||||
|
fields = ['content']
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
# Generated by Django 2.2.7 on 2019-12-04 16:51
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('users', '0002_auto_20191204_0857'),
|
||||||
|
('tasks', '0002_tasks_name'),
|
||||||
|
('areas', '0001_initial'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Standards',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(default='', max_length=200)),
|
||||||
|
('content', models.TextField(blank=True, max_length=3000)),
|
||||||
|
('created_area_date', models.DateField(blank=True, default=datetime.date.today)),
|
||||||
|
('public', models.BooleanField(default=True)),
|
||||||
|
('agency', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='users.Agency')),
|
||||||
|
('area', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='areas.Areas')),
|
||||||
|
('created_area_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
|
||||||
|
('task', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='tasks.Tasks')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
# Generated by Django 2.2.7 on 2019-12-04 17:08
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('standards', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='standards',
|
||||||
|
old_name='created_area_by',
|
||||||
|
new_name='created_standard_by',
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='standards',
|
||||||
|
old_name='created_area_date',
|
||||||
|
new_name='created_standard_date',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='standards',
|
||||||
|
name='last_modifed_by',
|
||||||
|
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.PROTECT, related_name='user_modified_standard', to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='standards',
|
||||||
|
name='last_modifed_on',
|
||||||
|
field=models.DateField(blank=True, default=datetime.date.today),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='standards',
|
||||||
|
name='published_by',
|
||||||
|
field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.PROTECT, related_name='user_published_standard', to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='standards',
|
||||||
|
name='published_on',
|
||||||
|
field=models.DateField(blank=True, default=datetime.date.today),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='standards',
|
||||||
|
name='public',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 2.2.7 on 2019-12-04 17:13
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
import tinymce.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('standards', '0002_auto_20191204_1808'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='standards',
|
||||||
|
name='content',
|
||||||
|
field=tinymce.models.HTMLField(),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 2.2.7 on 2019-12-04 17:31
|
||||||
|
|
||||||
|
import ckeditor.fields
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('standards', '0003_auto_20191204_1813'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='standards',
|
||||||
|
name='content',
|
||||||
|
field=ckeditor.fields.RichTextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 2.2.7 on 2019-12-04 18:24
|
||||||
|
|
||||||
|
import ckeditor_uploader.fields
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('standards', '0004_auto_20191204_1831'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='standards',
|
||||||
|
name='content',
|
||||||
|
field=ckeditor_uploader.fields.RichTextUploadingField(blank=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 2.2.7 on 2019-12-04 19:03
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('standards', '0005_auto_20191204_1924'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='standards',
|
||||||
|
old_name='last_modifed_by',
|
||||||
|
new_name='last_modified_by',
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='standards',
|
||||||
|
old_name='last_modifed_on',
|
||||||
|
new_name='last_modified_on',
|
||||||
|
),
|
||||||
|
]
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,3 +1,35 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from tinymce.models import HTMLField
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from users.models import Agency
|
||||||
|
from django.urls import reverse
|
||||||
|
from areas.models import Areas
|
||||||
|
from tasks.models import Tasks
|
||||||
|
import datetime
|
||||||
|
from ckeditor_uploader.fields import RichTextUploadingField
|
||||||
|
|
||||||
# Create your models here.
|
class Standards(models.Model):
|
||||||
|
|
||||||
|
agency = models.ForeignKey(Agency, on_delete=models.CASCADE)
|
||||||
|
area = models.ForeignKey(Areas, on_delete=models.CASCADE)
|
||||||
|
task = models.ForeignKey(Tasks, on_delete=models.CASCADE)
|
||||||
|
name = models.CharField(max_length=200, blank=False, default="")
|
||||||
|
content = RichTextUploadingField(blank=True, verbose_name='Inhalt')
|
||||||
|
|
||||||
|
created_standard_by = models.ForeignKey(User, on_delete=models.PROTECT)
|
||||||
|
created_standard_date = models.DateField(default=datetime.date.today, blank=True)
|
||||||
|
|
||||||
|
published_by = models.ForeignKey(User, on_delete=models.PROTECT, related_name='user_published_standard', default=None)
|
||||||
|
published_on = models.DateField(default=datetime.date.today, blank=True)
|
||||||
|
|
||||||
|
last_modified_by = models.ForeignKey(User, on_delete=models.PROTECT, related_name='user_modified_standard', default=None)
|
||||||
|
last_modified_on = models.DateField(default=datetime.date.today, blank=True)
|
||||||
|
|
||||||
|
public = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f'{self.name}'
|
||||||
|
|
||||||
|
# Hier Path für Templates des Models mit Parametern
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse('standards-update', kwargs={'pk':self.pk})
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends "users/base.html" %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="content-section">
|
||||||
|
<div class="media">
|
||||||
|
<div class="media-body">
|
||||||
|
<h2 class="account-heading">Standard {{ object.name }} löschen?</h2>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Für das Speichern der Bilder enctype -->
|
||||||
|
<form method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<button type="submit" class="btn btn-danger">Standard löschen</button>
|
||||||
|
<a href="{% url 'standards' %}" class="btn btn-success">Abbrechen</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
{% extends "users/base.html" %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="content-section col-6">
|
||||||
|
<h3>Neuen Standard anlegen</h3>
|
||||||
|
<hr>
|
||||||
|
<form method="POST" id="taskareaform">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{normalForm|crispy}}
|
||||||
|
{{editorForm.media}}
|
||||||
|
{{editorForm}}
|
||||||
|
|
||||||
|
<p>Wenn ein Standard erstellt wurde, kann er nur von einer Person mit dem Recht <i>Standards bearbeiten und freischalten</i> veröffentlicht werden.</p>
|
||||||
|
<hr>
|
||||||
|
<button type="submit" class="btn btn-success" href="{% url 'standard-add' %} ">Standard anlegen</button>
|
||||||
|
<a class="btn" href="{% url 'standards' %} ">Abbrechen</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
/*
|
||||||
|
Ajax-Request zum nachladen der Aufgaben nach Auswahl der Bereiche
|
||||||
|
*/
|
||||||
|
$("#id_area").change(function () {
|
||||||
|
var areaid = $(this).val();
|
||||||
|
$.ajax({
|
||||||
|
url: "/standards/ajax/loadtasks/",
|
||||||
|
data: {
|
||||||
|
'areaid': areaid
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
$("#id_task").html(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock content %}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
{% extends "users/base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="content-section col-12">
|
||||||
|
<h3>Standards</h3>
|
||||||
|
<hr>
|
||||||
|
<p>
|
||||||
|
Standards dokumentieren und erläutern verschiedenen Verfahren, strukturiert nach Bereichen und Aufgaben.
|
||||||
|
</p>
|
||||||
|
<div class="row">
|
||||||
|
<div class="content-section col-4">
|
||||||
|
<a class="btn btn-primary" href="{% url 'standard-add' %}">Neuen Standard anlegen</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
<div class="row">
|
||||||
|
{% for item in standards_of_agency %}
|
||||||
|
|
||||||
|
<div class=" mb-2 mr-2 col-5">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
|
||||||
|
{{item.name}}
|
||||||
|
{% if item.created_standard_by == user or perms.users.standard_management %}
|
||||||
|
<div class="dropdown no-arrow">
|
||||||
|
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i>
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink">
|
||||||
|
<!--<div class="dropdown-header">Benutzerdaten</div>-->
|
||||||
|
<a class="dropdown-item" href="{% url 'standard-update' item.pk %}">Bearbeiten</a>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<a class="dropdown-item text-danger" href="{% url 'standard-delete' item.pk %}" >Löschen</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">{{item.created_standard_by.first_name}} {{item.created_standard_by.last_name}} <h6>Zuletzt bearbeitet von {{ item.last_modified_by.first_name }} {{ item.last_modified_by.last_name }} am {{ item.last_modified_on }}</h6>
|
||||||
|
</h5>
|
||||||
|
<p class="card-text">{{ item.content|truncatechars:250|safe}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endfor%}
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
<option value="">---------</option>
|
||||||
|
{% for task in tasks %}
|
||||||
|
<option value="{{ task.pk }}">{{ task.name }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
{% extends "users/base.html" %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="content-section col-6">
|
||||||
|
<h3>Standard bearbeiten</h3>
|
||||||
|
<hr>
|
||||||
|
<form method="POST" id="taskareaform">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{normalForm|crispy}}
|
||||||
|
{{editorForm.media}}
|
||||||
|
{{editorForm}}
|
||||||
|
<p>Wenn ein Standard bearbeitet wurde, kann er nur von einer Person mit dem Recht <i>Standards bearbeiten und freischalten</i> wieder veröffentlicht werden. Ein Standard wird nach Bearbeitung als <i>Nicht veröffentlicht</i> gesetzt.</p>
|
||||||
|
<hr>
|
||||||
|
<button type="submit" class="btn btn-success" href="{% url 'standard-update' 1 %} ">Aktualisieren</button>
|
||||||
|
<a class="btn" href="{% url 'standards' %} ">Abbrechen</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
/*
|
||||||
|
Ajax-Request zum nachladen der Aufgaben nach Auswahl der Bereiche
|
||||||
|
*/
|
||||||
|
$("#id_area").change(function () {
|
||||||
|
var areaid = $(this).val();
|
||||||
|
$.ajax({
|
||||||
|
url: "/standards/ajax/loadtasks/",
|
||||||
|
data: {
|
||||||
|
'areaid': areaid
|
||||||
|
},
|
||||||
|
success: function (data) {
|
||||||
|
$("#id_task").html(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock content %}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
from django.urls import path
|
||||||
|
from django.contrib.auth import views as auth_views
|
||||||
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
|
#from .views import StandardsManagement, StandardAdd
|
||||||
|
from .views import StandardsManagement, StandardDeleteView
|
||||||
|
from . import views
|
||||||
|
'''
|
||||||
|
Permissions definiert in models.py bei USERS und dann hier vor die View geschrieben!
|
||||||
|
'''
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', StandardsManagement.as_view(template_name="standards/standards_management.html"), name='standards'),
|
||||||
|
path('standardadd/', views.StandardAdd, name='standard-add'),
|
||||||
|
path('standardupdate/<int:id>', views.StandardUpdate, name='standard-update'),
|
||||||
|
path('ajax/loadtasks/', views.load_tasks, name='ajax_loadtasks'),
|
||||||
|
path('standards/<int:pk>/delete', StandardDeleteView.as_view(), name='standard-delete'),
|
||||||
|
]
|
||||||
|
|
@ -1,3 +1,138 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render, redirect
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.views.generic import CreateView, ListView, UpdateView, DetailView, DeleteView, View
|
||||||
|
from .models import Standards
|
||||||
|
from django.contrib import messages
|
||||||
|
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 datetime import datetime
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
class StandardsManagement(LoginRequiredMixin, ListView):
|
||||||
|
model = Standards
|
||||||
|
# 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
|
||||||
|
standards_of_agency = Standards.objects.filter(agency__pk=self.request.user.profile.agency.pk)
|
||||||
|
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':
|
||||||
|
normalForm = StandardAddStandard(request.POST, instance=request.user)
|
||||||
|
editorForm = StandardAddStandardEditor(request.POST, instance=request.user)
|
||||||
|
|
||||||
|
if editorForm.is_valid() and normalForm.is_valid():
|
||||||
|
normalForm.agency = request.user.profile.agency
|
||||||
|
normalForm.created_standard_by = request.user
|
||||||
|
normalForm.published_by = request.user
|
||||||
|
normalForm.last_modifed_by = request.user
|
||||||
|
normalForm.save()
|
||||||
|
editorForm.save()
|
||||||
|
new_standard = Standards()
|
||||||
|
new_standard.agency = request.user.profile.agency
|
||||||
|
new_standard.created_standard_by = request.user
|
||||||
|
new_standard.published_by = request.user
|
||||||
|
new_standard.last_modified_by = request.user
|
||||||
|
new_standard.task = normalForm.cleaned_data['task']
|
||||||
|
new_standard.area = normalForm.cleaned_data['area']
|
||||||
|
new_standard.name = normalForm.cleaned_data['name']
|
||||||
|
new_standard.content = editorForm.cleaned_data['content']
|
||||||
|
new_standard.save()
|
||||||
|
tempstandardname = normalForm.cleaned_data['name']
|
||||||
|
messages.success(request, f'Standard {tempstandardname} hinzugefügt! Dieser muss noch veröffentlicht werden.')
|
||||||
|
return redirect('standards')
|
||||||
|
|
||||||
|
else:
|
||||||
|
normalForm = StandardAddStandard(instance=request.user)
|
||||||
|
editorForm = StandardAddStandardEditor(instance=request.user)
|
||||||
|
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'normalForm' : normalForm,
|
||||||
|
'editorForm' : editorForm,
|
||||||
|
'active_link' : 'standards'
|
||||||
|
}
|
||||||
|
return render(request, 'standards/standards_add.html', context)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def StandardUpdate(request, id):
|
||||||
|
standard = Standards.objects.get(pk=id)
|
||||||
|
if request.method == 'POST':
|
||||||
|
normalForm = StandardUpdateStandard(request.POST, instance=standard)
|
||||||
|
editorForm = StandardUpdateStandardEditor(request.POST, instance=standard)
|
||||||
|
|
||||||
|
if editorForm.is_valid() and normalForm.is_valid():
|
||||||
|
existing_standard = Standards.objects.get(pk=id)
|
||||||
|
existing_standard.last_modified_by = request.user
|
||||||
|
existing_standard.last_modified_on = datetime.now()
|
||||||
|
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']
|
||||||
|
existing_standard.public = False
|
||||||
|
existing_standard.save()
|
||||||
|
messages.success(request, f'Standard {existing_standard.name} aktualisiert!')
|
||||||
|
return redirect('/standards')
|
||||||
|
|
||||||
|
else:
|
||||||
|
normalForm = StandardUpdateStandard(instance=standard)
|
||||||
|
editorForm = StandardUpdateStandardEditor(instance=standard)
|
||||||
|
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'normalForm' : normalForm,
|
||||||
|
'editorForm' : editorForm,
|
||||||
|
'active_link' : 'standards'
|
||||||
|
}
|
||||||
|
return render(request, 'standards/standards_update.html', context)
|
||||||
|
|
||||||
|
def load_tasks(request):
|
||||||
|
areaid = request.GET.get('areaid')
|
||||||
|
tasks = Tasks.objects.filter(area__id=areaid).order_by('name')
|
||||||
|
return render(request, 'standards/standards_tasklist.html', {'tasks': tasks})
|
||||||
|
|
||||||
|
|
||||||
|
class StandardDeleteView(LoginRequiredMixin, DeleteView):
|
||||||
|
model = Standards
|
||||||
|
success_url = '/standards'
|
||||||
|
template_name = 'standards/standard_confirm_delete.html'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super(StandardDeleteView, self).get_context_data(**kwargs)
|
||||||
|
context['active_link'] = 'standards'
|
||||||
|
return context
|
||||||
|
|
@ -13,8 +13,8 @@ Model Tasks
|
||||||
|
|
||||||
class Tasks(models.Model):
|
class Tasks(models.Model):
|
||||||
|
|
||||||
agency = models.ForeignKey(Agency, on_delete=models.PROTECT)
|
agency = models.ForeignKey(Agency, on_delete=models.CASCADE)
|
||||||
area = models.ForeignKey(Areas, on_delete=models.PROTECT)
|
area = models.ForeignKey(Areas, on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=200, blank=False, default="")
|
name = models.CharField(max_length=200, blank=False, default="")
|
||||||
desc = models.TextField(max_length=3000, blank=True)
|
desc = models.TextField(max_length=3000, blank=True)
|
||||||
usersfield = models.ManyToManyField(User, blank=True, related_name='users_in_task')
|
usersfield = models.ManyToManyField(User, blank=True, related_name='users_in_task')
|
||||||
|
|
|
||||||
|
|
@ -104,5 +104,5 @@ class Profile(models.Model):
|
||||||
('users_usermanagement', 'Benutzer bearbeiten'),
|
('users_usermanagement', 'Benutzer bearbeiten'),
|
||||||
('areas_management', 'Bereiche bearbeiten'),
|
('areas_management', 'Bereiche bearbeiten'),
|
||||||
('tasks_management', 'Aufgabenbereiche bearbeiten'),
|
('tasks_management', 'Aufgabenbereiche bearbeiten'),
|
||||||
('standard_management', 'Standards bearbeiten und freischalten')
|
('standard_management', 'Standards bearbeiten und freischalten')
|
||||||
]
|
]
|
||||||
|
|
@ -62,8 +62,12 @@
|
||||||
Agentur
|
Agentur
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if active_link == 'standards' %}
|
||||||
|
<li class="nav-item active">
|
||||||
|
{% else%}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link " href="#" aria-expanded="true">
|
{%endif%}
|
||||||
|
<a class="nav-link " href="{% url 'standards' %}" aria-expanded="true">
|
||||||
<i class="fas fa-fw fa-lightbulb"></i>
|
<i class="fas fa-fw fa-lightbulb"></i>
|
||||||
<span>Standards</span>
|
<span>Standards</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@
|
||||||
<!-- FORMS LADEN -->
|
<!-- FORMS LADEN -->
|
||||||
{{ form|crispy }}
|
{{ form|crispy }}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<hr>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-success">Speichern</button>
|
<button type="submit" class="btn btn-success">Speichern</button>
|
||||||
<a href="{% url 'users-management' %}" class="btn">Abbrechen</a>
|
<a href="{% url 'users-management' %}" class="btn">Abbrechen</a>
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
<div class="dropdown-header">Benutzerdaten</div>
|
<div class="dropdown-header">Benutzerdaten</div>
|
||||||
<a class="dropdown-item" href="{% url 'users-update' item.profile.pk %}">Bearbeiten</a>
|
<a class="dropdown-item" href="{% url 'users-update' item.profile.pk %}">Bearbeiten</a>
|
||||||
<a class="dropdown-item" href="{% url 'users-perm-update' item.profile.pk %}">Rechte</a>
|
<a class="dropdown-item" href="{% url 'users-perm-update' item.profile.pk %}">Rechte</a>
|
||||||
|
<a class="dropdown-item" href="#">Priorisierung</a>
|
||||||
<hr class="sidebar-divider">
|
<hr class="sidebar-divider">
|
||||||
<!--<div class="dropdown-header"></div>-->
|
<!--<div class="dropdown-header"></div>-->
|
||||||
<a class="dropdown-item" href="#">Bereiche</a>
|
<a class="dropdown-item" href="#">Bereiche</a>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue