Stadnards neu anlegen fertig, Ansicht fertig fehlen noch Gruppensichtbarkeit und das updaten
This commit is contained in:
parent
a491a52039
commit
8f87ed4f37
Binary file not shown.
|
|
@ -384,6 +384,7 @@ function changeGroup(groupid, value){
|
||||||
//MOVING OPERATIONS
|
//MOVING OPERATIONS
|
||||||
function moveFile(fileid)
|
function moveFile(fileid)
|
||||||
{
|
{
|
||||||
|
|
||||||
workingfileid = fileid;
|
workingfileid = fileid;
|
||||||
workingdirid = false;
|
workingdirid = false;
|
||||||
|
|
||||||
|
|
@ -398,14 +399,16 @@ function moveFile(fileid)
|
||||||
success: function( data )
|
success: function( data )
|
||||||
{
|
{
|
||||||
$("#agencydirlist").html("");
|
$("#agencydirlist").html("");
|
||||||
|
html = ['<ul id="simple_list"><li><i class="fa fa-folder"></i> <a href="javascript:targetParentToMove({{rootid}})"><b><u>Heimverzeichnis<u></b></a>'];
|
||||||
createList(data["data"]["agencydirlist"], l);
|
createList(data["data"]["agencydirlist"], l);
|
||||||
$("#agencydirlist").html(html);
|
$("#agencydirlist").html(html);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var html = ['<ul id="simple_list">'];
|
var html = ['<ul id="simple_list"><li><i class="fa fa-folder"></i> <a href="javascript:targetParentToMove({{rootid}})"><b><u>Heimverzeichnis<u></b></a>'];
|
||||||
|
|
||||||
let l = 2;
|
let l = 2;
|
||||||
|
|
||||||
|
|
@ -429,6 +432,7 @@ function createList(arr, l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function targetParentToMove(parid){
|
function targetParentToMove(parid){
|
||||||
|
console.log(parid);
|
||||||
$.ajax(
|
$.ajax(
|
||||||
{
|
{
|
||||||
type: "GET",
|
type: "GET",
|
||||||
|
|
@ -518,7 +522,6 @@ function uploadAction(filetodo, parid){
|
||||||
var formData = new FormData($("#uploadFileForm")[0]);
|
var formData = new FormData($("#uploadFileForm")[0]);
|
||||||
formData.append("uploadedfile", filetodo);
|
formData.append("uploadedfile", filetodo);
|
||||||
|
|
||||||
console.log(filetodo.type);
|
|
||||||
if(allowedtypes.includes(filetodo.type) && filetodo.type.length > 0){
|
if(allowedtypes.includes(filetodo.type) && filetodo.type.length > 0){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{% url 'cloud-adddir' %}" + parid,
|
url: "{% url 'cloud-adddir' %}" + parid,
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ def CloudMain(request, pk):
|
||||||
context = {}
|
context = {}
|
||||||
breadcrump = []
|
breadcrump = []
|
||||||
files = []
|
files = []
|
||||||
|
rootid = list(DataDir.objects.filter(is_root=True, agency=request.user.profile.agency))[0].pk
|
||||||
if(pk == "first"):
|
if(pk == "first"):
|
||||||
diragency = list(DataDir.objects.filter(is_root=True, agency=request.user.profile.agency))[0]
|
diragency = list(DataDir.objects.filter(is_root=True, agency=request.user.profile.agency))[0]
|
||||||
|
|
||||||
|
|
@ -34,7 +34,8 @@ def CloudMain(request, pk):
|
||||||
'dirs' : alldirs,
|
'dirs' : alldirs,
|
||||||
'parentid' : diragency.pk,
|
'parentid' : diragency.pk,
|
||||||
'files' : DataFile.objects.filter(parent=diragency, agency=request.user.profile.agency),
|
'files' : DataFile.objects.filter(parent=diragency, agency=request.user.profile.agency),
|
||||||
'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency)
|
'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency),
|
||||||
|
"rootid" : rootid
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
|
@ -51,7 +52,6 @@ def CloudMain(request, pk):
|
||||||
userisingroup = True
|
userisingroup = True
|
||||||
|
|
||||||
if userisingroup:
|
if userisingroup:
|
||||||
|
|
||||||
alldirs = DataDir.objects.filter(is_root=False, agency=request.user.profile.agency, parent=pk).order_by("name")
|
alldirs = DataDir.objects.filter(is_root=False, agency=request.user.profile.agency, parent=pk).order_by("name")
|
||||||
vieweddir = list(DataDir.objects.filter(pk=pk, agency=request.user.profile.agency))[0]
|
vieweddir = list(DataDir.objects.filter(pk=pk, agency=request.user.profile.agency))[0]
|
||||||
|
|
||||||
|
|
@ -68,7 +68,8 @@ def CloudMain(request, pk):
|
||||||
'parentid' : pk,
|
'parentid' : pk,
|
||||||
'breadcrump' : breadcrump,
|
'breadcrump' : breadcrump,
|
||||||
'files' : DataFile.objects.filter(parent=vieweddir, agency=request.user.profile.agency),
|
'files' : DataFile.objects.filter(parent=vieweddir, agency=request.user.profile.agency),
|
||||||
'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency)
|
'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency),
|
||||||
|
"rootid" : rootid
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
context = {
|
context = {
|
||||||
|
|
@ -122,7 +123,7 @@ def adddirbyajax(request, parent):
|
||||||
DataDir.objects.get(pk=request.GET.get('id'), agency=request.user.profile.agency).delete()
|
DataDir.objects.get(pk=request.GET.get('id'), agency=request.user.profile.agency).delete()
|
||||||
except:
|
except:
|
||||||
success = False
|
success = False
|
||||||
# MOVE DIR
|
# MOVE FILE
|
||||||
elif(request.GET.get("action") == "movefile"):
|
elif(request.GET.get("action") == "movefile"):
|
||||||
tempdatafile = DataFile.objects.get(pk=request.GET.get('fileid'))
|
tempdatafile = DataFile.objects.get(pk=request.GET.get('fileid'))
|
||||||
tempdatafile.parent = DataDir.objects.get(pk=request.GET.get('newpar'))
|
tempdatafile.parent = DataDir.objects.get(pk=request.GET.get('newpar'))
|
||||||
|
|
@ -165,6 +166,7 @@ def adddirbyajax(request, parent):
|
||||||
if(file_ok):
|
if(file_ok):
|
||||||
tempdatafile = DataFile(file=request.FILES['uploadedfile'], name=request.FILES['uploadedfile'].name, owner=request.user, parent=tempdir, agency=request.user.profile.agency)
|
tempdatafile = DataFile(file=request.FILES['uploadedfile'], name=request.FILES['uploadedfile'].name, owner=request.user, parent=tempdir, agency=request.user.profile.agency)
|
||||||
tempdatafile.save()
|
tempdatafile.save()
|
||||||
|
data = {'savedobj_id' : tempdatafile.pk, 'savedobj_name' : tempdatafile.name}
|
||||||
else:
|
else:
|
||||||
success = False
|
success = False
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -3,6 +3,8 @@ from django.forms import ModelForm
|
||||||
from .models import Standards
|
from .models import Standards
|
||||||
from areas.models import Areas
|
from areas.models import Areas
|
||||||
from tasks.models import Tasks
|
from tasks.models import Tasks
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from users.models import Profile, UserFullName
|
||||||
from django_summernote.widgets import SummernoteInplaceWidget
|
from django_summernote.widgets import SummernoteInplaceWidget
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -12,16 +14,19 @@ class StandardAddStandard(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model =Standards
|
model =Standards
|
||||||
widgets = {
|
widgets = {
|
||||||
'content': SummernoteInplaceWidget(),
|
'content': SummernoteInplaceWidget()
|
||||||
}
|
}
|
||||||
labels = {
|
labels = {
|
||||||
"name" : "Titel",
|
"name" : "Titel",
|
||||||
"area" : "Übergeordneter Bereich",
|
"area" : "Übergeordneter Bereich",
|
||||||
"task" : "Aufgabenbereich",
|
"task" : "Aufgabenbereich",
|
||||||
"content": "Inhalt",
|
"content": "Inhalt",
|
||||||
"public" : "Direkt veröffentlichen?"
|
"public" : "Direkt veröffentlichen?",
|
||||||
|
"representative" : "Vertreter",
|
||||||
|
"executor" : "Ausführender",
|
||||||
|
"authority" : "Verantwortlicher",
|
||||||
}
|
}
|
||||||
fields = ['name', 'area', 'task', 'content', 'public']
|
fields = ['name', 'area', 'task', 'content', 'public', "authority", "executor", "representative"]
|
||||||
'''
|
'''
|
||||||
|
|
||||||
Hier werden die Elemente für die DropDowns erstellt, damit
|
Hier werden die Elemente für die DropDowns erstellt, damit
|
||||||
|
|
@ -45,6 +50,13 @@ class StandardAddStandard(forms.ModelForm):
|
||||||
elif self.instance.pk:
|
elif self.instance.pk:
|
||||||
self.fields['task'].queryset = Tasks.objects.none()
|
self.fields['task'].queryset = Tasks.objects.none()
|
||||||
|
|
||||||
|
self.fields['representative'].queryset = UserFullName.objects.filter(profile__agency__pk=kwargs['instance'].profile.agency.pk)
|
||||||
|
self.fields['executor'].queryset = UserFullName.objects.filter(profile__agency__pk=kwargs['instance'].profile.agency.pk)
|
||||||
|
self.fields['authority'].queryset = UserFullName.objects.filter(profile__agency__pk=kwargs['instance'].profile.agency.pk)
|
||||||
|
|
||||||
|
self.fields['checked_groups'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput())
|
||||||
|
self.fields['added_files'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput())
|
||||||
|
self.fields['added_standards'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput())
|
||||||
|
|
||||||
|
|
||||||
class StandardAddStandardEditor(forms.ModelForm):
|
class StandardAddStandardEditor(forms.ModelForm):
|
||||||
|
|
@ -70,9 +82,12 @@ class StandardUpdateStandard(forms.ModelForm):
|
||||||
"name" : "Titel",
|
"name" : "Titel",
|
||||||
"area" : "Übergeordneter Bereich",
|
"area" : "Übergeordneter Bereich",
|
||||||
"task" : "Aufgabenbereich",
|
"task" : "Aufgabenbereich",
|
||||||
"content": "Inhalt"
|
"content": "Inhalt",
|
||||||
|
"representative" : "Vertreter",
|
||||||
|
"executor" : "Ausführender",
|
||||||
|
"authority" : "Verantwortlicher",
|
||||||
}
|
}
|
||||||
fields = ['name', 'area', 'task', 'content']
|
fields = ['name', 'area', 'task', 'content', "authority", "executor", "representative"]
|
||||||
'''
|
'''
|
||||||
|
|
||||||
Hier werden die Elemente für die DropDowns erstellt, damit
|
Hier werden die Elemente für die DropDowns erstellt, damit
|
||||||
|
|
@ -99,6 +114,9 @@ class StandardUpdateStandard(forms.ModelForm):
|
||||||
elif loggeduser.pk:
|
elif loggeduser.pk:
|
||||||
self.fields['task'].queryset = Tasks.objects.filter(area__pk=standard.area.pk)
|
self.fields['task'].queryset = Tasks.objects.filter(area__pk=standard.area.pk)
|
||||||
|
|
||||||
|
self.fields['representative'].queryset = UserFullName.objects.filter(profile__agency__pk=loggeduser.profile.agency.pk)
|
||||||
|
self.fields['executor'].queryset = UserFullName.objects.filter(profile__agency__pk=loggeduser.profile.agency.pk)
|
||||||
|
self.fields['authority'].queryset = UserFullName.objects.filter(profile__agency__pk=loggeduser.profile.agency.pk)
|
||||||
|
|
||||||
|
|
||||||
class StandardUpdateStandardEditor(forms.ModelForm):
|
class StandardUpdateStandardEditor(forms.ModelForm):
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ from users.models import Agency
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from areas.models import Areas
|
from areas.models import Areas
|
||||||
from tasks.models import Tasks
|
from tasks.models import Tasks
|
||||||
|
from cloud.models import DataFile
|
||||||
|
from users.models import AgencyGroup
|
||||||
import datetime
|
import datetime
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
#from ckeditor_uploader.fields import RichTextUploadingField
|
#from ckeditor_uploader.fields import RichTextUploadingField
|
||||||
|
|
@ -14,9 +16,7 @@ class Standards(models.Model):
|
||||||
area = models.ForeignKey(Areas, on_delete=models.CASCADE)
|
area = models.ForeignKey(Areas, on_delete=models.CASCADE)
|
||||||
task = models.ForeignKey(Tasks, on_delete=models.CASCADE)
|
task = models.ForeignKey(Tasks, on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=200, blank=False, default="")
|
name = models.CharField(max_length=200, blank=False, default="")
|
||||||
#content = RichTextUploadingField(blank=True, verbose_name='Inhalt')
|
|
||||||
content = models.TextField(blank=True, verbose_name='Inhalt', default="")
|
content = models.TextField(blank=True, verbose_name='Inhalt', default="")
|
||||||
#content = models.CharField(max_length=200000, blank=True, verbose_name='Inhalt')
|
|
||||||
|
|
||||||
created_standard_by = models.ForeignKey(User, on_delete=models.PROTECT)
|
created_standard_by = models.ForeignKey(User, on_delete=models.PROTECT)
|
||||||
created_standard_date = models.DateTimeField(default=timezone.now, blank=True)
|
created_standard_date = models.DateTimeField(default=timezone.now, blank=True)
|
||||||
|
|
@ -29,6 +29,21 @@ class Standards(models.Model):
|
||||||
|
|
||||||
public = models.BooleanField(default=False)
|
public = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
|
||||||
|
# USER
|
||||||
|
# VERTRETER
|
||||||
|
representative = models.ForeignKey(User, on_delete=models.PROTECT, related_name="user_repr", blank=True, null=True)
|
||||||
|
# AUSFÜHRENDER
|
||||||
|
executor = models.ForeignKey(User, on_delete=models.PROTECT, related_name="user_executor", blank=True, null=True)
|
||||||
|
# VERANTWORTLICHER
|
||||||
|
authority = models.ForeignKey(User, on_delete=models.PROTECT, related_name="user_authority", blank=True, null=True)
|
||||||
|
# FILES
|
||||||
|
addedfiles = models.ManyToManyField(DataFile, blank=True)
|
||||||
|
# VERLINKTE STANDARDS
|
||||||
|
linked_standards = models.ManyToManyField('Standards', blank=True)
|
||||||
|
# GORUPS
|
||||||
|
visibleby = models.ManyToManyField(AgencyGroup, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.name}'
|
return f'{self.name}'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,286 @@
|
||||||
{% extends "users/base.html" %}
|
{% extends "users/base.html" %}
|
||||||
{% load crispy_forms_tags %}
|
{% load crispy_forms_tags %}
|
||||||
|
{% load counter_tag %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="content-section col-8">
|
<div class="content-section col-12">
|
||||||
<h3>Neuen Standard anlegen</h3>
|
<h3>Neuen Standard anlegen <small><i data-toggle="tooltip" data-placement="top" title="Legen Sie hier einen neuen Standard an." class="far fa-question-circle"></i></small></h3>
|
||||||
<hr>
|
<hr>
|
||||||
<form method="POST" id="taskareaform">
|
<form method="POST" id="addstandardform">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{normalForm|crispy}}
|
<div class="row"><div class="col-8">
|
||||||
|
{% for field in normalForm %}
|
||||||
|
{% if forloop.counter|divisibleby:6 %}
|
||||||
|
</div><div class="col-3">
|
||||||
|
{{field|as_crispy_field }}
|
||||||
|
{% else %}
|
||||||
|
{{field|as_crispy_field }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
<!-- COLLAPSE AREA FOR GROUPS FILES AND LINKED STANDARDS -->
|
||||||
|
<div class="accordion" style="margin-top: 47px" id="additionalStandardInfos">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header" id="st_groups">
|
||||||
|
<h5 class="mb-0">
|
||||||
|
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#stgroups_content" aria-expanded="false" aria-controls="stgroups_content">
|
||||||
|
Gruppen <small><i data-toggle="tooltip" data-placement="top" title="Legen Sie fest, welche Gruppe diesen Standard sehen kann. Ist keine ausgewählt, ist der Standard für alle sichtbar." class="far fa-question-circle"></i></small>
|
||||||
|
</button>
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="stgroups_content" class="collapse" aria-labelledby="st_groups" data-parent="#additionalStandardInfos">
|
||||||
|
<div class="card-body">
|
||||||
|
{% for g in agencygroups %}
|
||||||
|
<div class="custom-control custom-checkbox mb-2">
|
||||||
|
<input type="checkbox" class="custom-control-input groupclass" onclick="javascript:groupsChange({{g.pk}}, this.checked)" name="group_{{g.pk}}" id="group_{{g.pk}}">
|
||||||
|
<label class="custom-control-label" for="group_{{g.pk}}" >{{g.agencygroupname}}</label>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% if request.user.profile.agency.module_files %}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header" id="st_files">
|
||||||
|
<h5 class="mb-0">
|
||||||
|
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#st_files_content" aria-expanded="false" aria-controls="st_files_content">
|
||||||
|
Dateien <small><i data-toggle="tooltip" data-placement="top" title="Fügen Sie ihren Standards Dateien zu. Diese liegen entweder bereits unter Dateien oder können iher direkt hochgeladen werden. Neu hochgeladene Dateien werden im Heimverzeichnis gespeichert." class="far fa-question-circle"></i></small>
|
||||||
|
</button>
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
<div id="st_files_content" class="collapse" aria-labelledby="st_files" data-parent="#additionalStandardInfos">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input class="form-control searchuserfieldstask" list="possfiles" id="searchfiles" type="text" onkeyup="javascript:updateLinkedFiles()" >
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button type="button" onclick="javascript:clearSearchfieldAddFile()" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
||||||
|
</div>
|
||||||
|
<datalist id="possfiles">
|
||||||
|
{% for f in files %}
|
||||||
|
<option id="file_{{f.pk}}" value="{{f.name}}">{{f.name}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
Verlinkte Dateien:
|
||||||
|
<table id="linkedfiles" class="table table-hover table-sm">
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<input type="file" id="uploadedfile" name="uploadedfile" style="display:none">
|
||||||
|
{% if user|usergperm:"filesmanager" %}
|
||||||
|
<div class="alert alert-secondary text-center mt-5" id="directdiv" role="alert" style="line-height: 17px; text-align: center;">
|
||||||
|
<button type="button" class="btn btn-primary btn-sm" id="uploadButton" onclick="javascript:uploadButtonPush()"><i class="fas fa-plus"></i></button> <small>klicken/hineinziehen<p class="mt-2">Dateien werden im <b>Heimverzeichnis</b>gespeichert.
|
||||||
|
</small></p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header" id="st_linked">
|
||||||
|
<h5 class="mb-0">
|
||||||
|
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#st_linked_content" aria-expanded="false" aria-controls="st_linked_content">
|
||||||
|
Standards <small><i data-toggle="tooltip" data-placement="top" title="Verlinken Sie hier andere Standards, die etwas mit diesem Standard zutun haben." class="far fa-question-circle"></i></small>
|
||||||
|
</button>
|
||||||
|
</h5>
|
||||||
|
</div>
|
||||||
|
<div id="st_linked_content" class="collapse" aria-labelledby="st_linked" data-parent="#additionalStandardInfos">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input class="form-control" list="possstandards" id="searchstandards" type="text" onkeyup="javascript:updateLinkedStandards()" >
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button type="button" onclick="javascript:clearSearchfieldAddStandard()" class="btn btn-secondary" ><i class="fas fa-times"></i></button>
|
||||||
|
</div>
|
||||||
|
<datalist id="possstandards">
|
||||||
|
{% for s in standards %}
|
||||||
|
<option id="standard_{{s.pk}}" value="{{s.name|truncatechars:30}}">{{s.name|truncatechars:30}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
Verlinkte Standards:
|
||||||
|
<table id="linkedstandards" class="table table-hover table-sm">
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div></div>
|
||||||
<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>
|
<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>
|
<hr>
|
||||||
<button type="submit" class="btn btn-success" href="{% url 'standard-add' %} ">Standard anlegen</button>
|
<button type="submit" class="btn btn-success">Standard anlegen</button>
|
||||||
<a class="btn" href="{% url 'standards' %} ">Abbrechen</a>
|
<a class="btn" href="{% url 'standards' %} ">Abbrechen</a>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- FILE FORBIDDEN DELETE FILE -->
|
||||||
|
<div class="modal fade" id="forbiddenFileType" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="groupDelFunction" aria-hidden="true">
|
||||||
|
<div class="modal-dialog " role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="exampleModalLongTitle">Datei nicht erlaubt</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Diesen Dateitypen dürfen Sie nicht hochladen.
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-success" data-dismiss="modal">Schließen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
//STANDARDS
|
||||||
|
actualStandards = [];
|
||||||
|
|
||||||
|
function clearSearchfieldAddStandard(){
|
||||||
|
$("#searchstandards").val("");
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateLinkedStandards(){
|
||||||
|
var g = $('#searchstandards').val();
|
||||||
|
var id = $('#possstandards').find('option[value="' + g + '"]').attr('id');
|
||||||
|
if(id != undefined && id.length > 0){
|
||||||
|
tempid_standard = id.split("_")[1];
|
||||||
|
actualStandards.push(tempid_standard);
|
||||||
|
clearSearchfieldAddStandard();
|
||||||
|
$("#" + id).remove();
|
||||||
|
$("#linkedstandards").append('<tr id="standardadded_'+tempid_standard+'"><td>' + g + '</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remStandard('+tempid_standard+', \''+g+'\')"><i class="fas fa-trash-alt"></i></button></td></tr>');
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#id_added_standards").val(actualStandards);
|
||||||
|
}
|
||||||
|
|
||||||
|
function remStandard(id, name){
|
||||||
|
index_to_rem = actualStandards.indexOf(id);
|
||||||
|
actualStandards.splice(index_to_rem,1);
|
||||||
|
$('#possstandards').append('<option id="standard_'+id+'" value="'+ name +'">'+ name +'</option>');
|
||||||
|
$("#standardadded_" + id).remove();
|
||||||
|
$("#id_added_standards").val(actualStandards);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//FILES
|
||||||
|
// preventing page from redirecting
|
||||||
|
$("html").on("dragover", function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
$("html").on("drop", function(e) { e.preventDefault(); e.stopPropagation(); });
|
||||||
|
|
||||||
|
$( "#directdiv" ).on('dragenter', function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
currentid = e["currentTarget"]['id'];
|
||||||
|
$("#directdiv").addClass('bg-secondary');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('#directdiv').on('drop', function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
$("#directdiv").removeClass('bg-secondary');
|
||||||
|
uploadAction(e.originalEvent.dataTransfer.files[0], e["currentTarget"]['id'].split("_")[0]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#directdiv').on('dragleave', function (e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
currentid = e["currentTarget"]['id'];
|
||||||
|
$("#directdiv").removeClass('bg-secondary');
|
||||||
|
});
|
||||||
|
|
||||||
|
allowedtypes = "application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, text/plain, application/pdf, image/*"
|
||||||
|
|
||||||
|
|
||||||
|
function uploadButtonPush(){
|
||||||
|
$("#uploadedfile").click();
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#uploadedfile').on('change', function() {
|
||||||
|
uploadAction($("#uploadedfile")[0]['files'][0], {{parentid}});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function uploadAction(filetodo){
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append("uploadedfile", filetodo);
|
||||||
|
if(allowedtypes.includes(filetodo.type) && filetodo.type.length > 0){
|
||||||
|
$.ajax({
|
||||||
|
url: "{% url 'cloud-adddir' parentid %}",
|
||||||
|
headers: {
|
||||||
|
"X-CSRFTOKEN": "{{ csrf_token }}"
|
||||||
|
},
|
||||||
|
data: formData,
|
||||||
|
type: 'POST',
|
||||||
|
cache: false,
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success: function(data) {
|
||||||
|
if(data["success"] == true){
|
||||||
|
actualFiles.push(String(data["data"]["savedobj_id"]));
|
||||||
|
$("#id_added_files").val(actualFiles);
|
||||||
|
$("#linkedfiles") .append('<tr id="fileadded_'+data["data"]["savedobj_id"]+'"><td>' + data["data"]["savedobj_name"] + '</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remFile('+data["data"]["savedobj_id"]+', \''+data["data"]["savedobj_name"]+'\')"><i class="fas fa-trash-alt"></i></button></td></tr>');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$("#forbiddenFileType").modal("toggle")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$("#forbiddenFileType").modal("toggle")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actualFiles = [];
|
||||||
|
|
||||||
|
function clearSearchfieldAddFile(){
|
||||||
|
$("#searchfiles").val("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function updateLinkedFiles(){
|
||||||
|
var g = $('#searchfiles').val();
|
||||||
|
var id = $('#possfiles').find('option[value="' + g + '"]').attr('id');
|
||||||
|
if(id != undefined && id.length > 0){
|
||||||
|
tempid_file = id.split("_")[1];
|
||||||
|
actualFiles.push(tempid_file);
|
||||||
|
$("#id_added_files").val(actualFiles)
|
||||||
|
clearSearchfieldAddFile();
|
||||||
|
$("#" + id).remove();
|
||||||
|
$("#linkedfiles") .append('<tr id="fileadded_'+tempid_file+'"><td>' + g + '</td><td><button type="button" class="btn btn-danger btn-sm" onclick="javascript:remFile('+tempid_file+', \''+g+'\')"><i class="fas fa-trash-alt"></i></button></td></tr>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function remFile(id, name){
|
||||||
|
index_to_rem = actualFiles.indexOf(id);
|
||||||
|
actualFiles.splice(index_to_rem,1);
|
||||||
|
$('#possfiles').append('<option id="file_'+id+'" value="'+ name +'">'+ name +'</option>');
|
||||||
|
$("#fileadded_" + id).remove();
|
||||||
|
$("#id_added_files").val(actualFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GROUPS
|
||||||
|
actualGroups = [];
|
||||||
|
|
||||||
|
function groupsChange(groupid, value){
|
||||||
|
if(value){
|
||||||
|
actualGroups.push(groupid);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
index_to_rem = actualGroups.indexOf(groupid)
|
||||||
|
actualGroups.splice(index_to_rem,1);
|
||||||
|
}
|
||||||
|
$("#id_checked_groups").val(actualGroups);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Ajax-Request zum nachladen der Aufgaben nach Auswahl der Bereiche
|
Ajax-Request zum nachladen der Aufgaben nach Auswahl der Bereiche
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,64 @@
|
||||||
<small><br />
|
<small><br />
|
||||||
Ansprechpartner:
|
Ansprechpartner:
|
||||||
{% for taskuser in standard.task.usersfield.all %}
|
{% for taskuser in standard.task.usersfield.all %}
|
||||||
|
|
||||||
<span class="badge badge-pill badge-primary" style="font-size: 1.1em; background-color: {{standard.task.area.color}}"><a href="{% url 'orga-single' taskuser.pk%}" style="color: #ffffff">{{taskuser.first_name}} {{taskuser.last_name}}</a></span>
|
<span class="badge badge-pill badge-primary" style="font-size: 1.1em; background-color: {{standard.task.area.color}}"><a href="{% url 'orga-single' taskuser.pk%}" style="color: #ffffff">{{taskuser.first_name}} {{taskuser.last_name}}</a></span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if standard.authority %}
|
||||||
|
Verantwortlicher: <a href="{% url 'orga-single' standard.authority.pk%}"> {{standard.authority.first_name}} {{standard.authority.last_name}}</a> |
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if standard.executor %}
|
||||||
|
Ausführende Person: <a href="{% url 'orga-single' standard.executor.pk%}">{{standard.executor.first_name}} {{standard.executor.last_name}}</a> |
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if standard.representative %}
|
||||||
|
Vertreter: <a href="{% url 'orga-single' standard.representative.pk%}">{{standard.representative.first_name}} {{standard.representative.last_name}}</a> |
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
</small>
|
</small>
|
||||||
<hr>
|
<hr>
|
||||||
{{standard.media}}
|
<div class="row col">
|
||||||
{{standard.content|safe}}
|
|
||||||
|
<div class="card col-9" style="min-height: 500px">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title"></h5>
|
||||||
|
<p class="card-text">
|
||||||
|
{{standard.media}}
|
||||||
|
{{standard.content|safe}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- FILES -->
|
||||||
|
<div class="col-3">
|
||||||
|
|
||||||
|
{% if standard.addedfiles.all|length > 0 %}
|
||||||
|
<div class="card col-14 ml-2" style="">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Dateien</h5>
|
||||||
|
<p class="card-text">
|
||||||
|
{% for files in standard.addedfiles.all %}
|
||||||
|
<a href="{{files.file.url}}" download>{{files.name|truncatechars:30}}</a><br />
|
||||||
|
{% endfor %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<!-- STANDARDS -->
|
||||||
|
{% if standard.linked_standards.all|length > 0 %}
|
||||||
|
<div class="card col-14 ml-2 mt-3" style="">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Verwandte Standards</h5>
|
||||||
|
<p class="card-text">
|
||||||
|
{% for standard in standard.linked_standards.all %}
|
||||||
|
<a href="{% url 'standard-single' standard.pk %}">{{standard.name|truncatechars:30}}</a><br />
|
||||||
|
{% endfor %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
@ -10,6 +10,8 @@ from django.contrib.auth.decorators import login_required
|
||||||
from tasks.models import Tasks
|
from tasks.models import Tasks
|
||||||
from areas.models import Areas
|
from areas.models import Areas
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from users.models import AgencyGroup
|
||||||
|
from cloud.models import DataFile, DataDir
|
||||||
|
|
||||||
# ALLE STANDARDS EINER AGENTUR
|
# ALLE STANDARDS EINER AGENTUR
|
||||||
class StandardsManagement(LoginRequiredMixin, ListView):
|
class StandardsManagement(LoginRequiredMixin, ListView):
|
||||||
|
|
@ -53,25 +55,78 @@ def StandardAdd(request):
|
||||||
new_standard.name = normalForm.cleaned_data['name']
|
new_standard.name = normalForm.cleaned_data['name']
|
||||||
new_standard.content = editorForm.cleaned_data['content']
|
new_standard.content = editorForm.cleaned_data['content']
|
||||||
new_standard.public = normalForm.cleaned_data['public']
|
new_standard.public = normalForm.cleaned_data['public']
|
||||||
|
|
||||||
|
new_standard.representative = normalForm.cleaned_data['representative']
|
||||||
|
new_standard.executor = normalForm.cleaned_data['executor']
|
||||||
|
new_standard.authority = normalForm.cleaned_data['authority']
|
||||||
|
|
||||||
|
# GROUPS
|
||||||
new_standard.save()
|
new_standard.save()
|
||||||
|
|
||||||
|
# ADD GROUPS
|
||||||
|
groups = normalForm.cleaned_data['checked_groups'].split(",")
|
||||||
|
for g in groups:
|
||||||
|
new_standard.visibleby.add(AgencyGroup.objects.get(pk=g))
|
||||||
|
|
||||||
|
# ADD STANDARDS
|
||||||
|
standards = normalForm.cleaned_data['added_standards'].split(",")
|
||||||
|
for s in standards:
|
||||||
|
new_standard.linked_standards.add(Standards.objects.get(pk=s))
|
||||||
|
|
||||||
|
# ADD FILES
|
||||||
|
files = normalForm.cleaned_data['added_files'].split(",")
|
||||||
|
for f in files:
|
||||||
|
new_standard.addedfiles.add(DataFile.objects.get(pk=f))
|
||||||
|
|
||||||
tempstandardname = normalForm.cleaned_data['name']
|
tempstandardname = normalForm.cleaned_data['name']
|
||||||
if(new_standard.public and request.user.has_perm('users.standard_management')):
|
if(new_standard.public and request.user.has_perm('users.standardmanager')):
|
||||||
messages.success(request, f'Standard {tempstandardname} hinzugefügt und veröffentlicht.')
|
messages.success(request, f'Standard {tempstandardname} hinzugefügt und veröffentlicht.')
|
||||||
else:
|
else:
|
||||||
new_standard.public = False
|
new_standard.public = False
|
||||||
new_standard.save()
|
new_standard.save()
|
||||||
messages.success(request, f'Standard {tempstandardname} hinzugefügt! Dieser muss noch veröffentlicht werden.')
|
messages.success(request, f'Standard {tempstandardname} hinzugefügt! Dieser muss noch veröffentlicht werden.')
|
||||||
return redirect('standards')
|
return redirect('standards')
|
||||||
|
else:
|
||||||
|
print("INVALID")
|
||||||
|
print(normalForm)
|
||||||
|
print(editorForm)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
normalForm = StandardAddStandard(instance=request.user)
|
normalForm = StandardAddStandard(instance=request.user)
|
||||||
editorForm = StandardAddStandardEditor(instance=request.user)
|
editorForm = StandardAddStandardEditor(instance=request.user)
|
||||||
|
|
||||||
|
'''
|
||||||
|
Hier werden nur die Dateien dem aktuellen User zur Auswahl gestellt, auf die er auch Zugriff hat.
|
||||||
|
Das geht NICHT rekursiv! Es wird nur das oberste Verzeichnis geprüft! SPÄTER!
|
||||||
|
'''
|
||||||
|
|
||||||
|
possibleFilesByVisible = []
|
||||||
|
|
||||||
|
allfiles = DataFile.objects.filter(agency=request.user.profile.agency)
|
||||||
|
|
||||||
|
for file in allfiles:
|
||||||
|
user_can_view_file = False
|
||||||
|
parentdir = DataDir.objects.get(pk=file.parent.pk)
|
||||||
|
if(parentdir.is_root == False):
|
||||||
|
for p_group in parentdir.visibleby.all():
|
||||||
|
if p_group.group in request.user.groups.all():
|
||||||
|
user_can_view_file = True
|
||||||
|
else:
|
||||||
|
user_can_view_file = True
|
||||||
|
|
||||||
|
if user_can_view_file:
|
||||||
|
possibleFilesByVisible.append(file)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'normalForm' : normalForm,
|
'normalForm' : normalForm,
|
||||||
'editorForm' : editorForm,
|
'editorForm' : editorForm,
|
||||||
'active_link' : 'standards'
|
'active_link' : 'standards',
|
||||||
|
'agencygroups' : AgencyGroup.objects.filter(agency=request.user.profile.agency),
|
||||||
|
'files' : possibleFilesByVisible,
|
||||||
|
'parentid' : list(DataDir.objects.filter(agency=request.user.profile.agency, is_root=True))[0].pk,
|
||||||
|
'standards' : Standards.objects.filter(agency=request.user.profile.agency, public=True)
|
||||||
}
|
}
|
||||||
return render(request, 'standards/standards_add.html', context)
|
return render(request, 'standards/standards_add.html', context)
|
||||||
|
|
||||||
|
|
@ -92,6 +147,11 @@ def StandardUpdate(request, id):
|
||||||
existing_standard.area = normalForm.cleaned_data['area']
|
existing_standard.area = normalForm.cleaned_data['area']
|
||||||
existing_standard.name = normalForm.cleaned_data['name']
|
existing_standard.name = normalForm.cleaned_data['name']
|
||||||
existing_standard.content = editorForm.cleaned_data['content']
|
existing_standard.content = editorForm.cleaned_data['content']
|
||||||
|
|
||||||
|
existing_standard.representative = normalForm.cleaned_data['representative']
|
||||||
|
existing_standard.executor = normalForm.cleaned_data['executor']
|
||||||
|
existing_standard.authority = normalForm.cleaned_data['authority']
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
AKTUALISIERUNG
|
AKTUALISIERUNG
|
||||||
|
|
@ -101,7 +161,7 @@ def StandardUpdate(request, id):
|
||||||
aber keine Rechte und ist der Standarf public, wird er auf public=false gesetzt!
|
aber keine Rechte und ist der Standarf public, wird er auf public=false gesetzt!
|
||||||
|
|
||||||
'''
|
'''
|
||||||
if request.user.has_perm('users.standard_management'):
|
if request.user.has_perm('users.standardmanager'):
|
||||||
messages.success(request, f'Standard {existing_standard.name} aktualisiert!')
|
messages.success(request, f'Standard {existing_standard.name} aktualisiert!')
|
||||||
else:
|
else:
|
||||||
if existing_standard.public:
|
if existing_standard.public:
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -205,3 +205,14 @@ class AgencyGroup(models.Model):
|
||||||
('filedirmanager', 'Ordner bearbeiten'),
|
('filedirmanager', 'Ordner bearbeiten'),
|
||||||
('filesviewer', 'Dateien lesen')
|
('filesviewer', 'Dateien lesen')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# SUBCLASS
|
||||||
|
class UserFullName(User):
|
||||||
|
class Meta:
|
||||||
|
proxy = True
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return "MEIN NAME"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f'{self.first_name + " " + self.last_name}'
|
||||||
|
|
@ -27,7 +27,8 @@
|
||||||
|
|
||||||
<!-- include summernote css/js -->
|
<!-- include summernote css/js -->
|
||||||
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.15/dist/summernote.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.15/dist/summernote.min.css" rel="stylesheet">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.15/dist/summernote.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.15/dist/summernote.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<!-- CROPPER -->
|
<!-- CROPPER -->
|
||||||
<link href="{% static 'users/css/cropper.min.css' %}" rel="stylesheet">
|
<link href="{% static 'users/css/cropper.min.css' %}" rel="stylesheet">
|
||||||
|
|
@ -36,8 +37,8 @@
|
||||||
<!--<link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">-->
|
<!--<link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">-->
|
||||||
|
|
||||||
<!-- DATATABLES -->
|
<!-- DATATABLES -->
|
||||||
<link href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css" rel="stylesheet">
|
<!--<link href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css" rel="stylesheet">
|
||||||
<link href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css" rel="stylesheet">
|
<link href="https://cdn.datatables.net/1.10.20/css/dataTables.bootstrap4.min.css" rel="stylesheet">-->
|
||||||
|
|
||||||
<!-- Custom styles for this template-->
|
<!-- Custom styles for this template-->
|
||||||
<link href="{% static 'users/css/sb-admin-2.css' %}" rel="stylesheet">
|
<link href="{% static 'users/css/sb-admin-2.css' %}" rel="stylesheet">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue