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
|
||||
function moveFile(fileid)
|
||||
{
|
||||
|
||||
workingfileid = fileid;
|
||||
workingdirid = false;
|
||||
|
||||
|
|
@ -398,14 +399,16 @@ function moveFile(fileid)
|
|||
success: function( data )
|
||||
{
|
||||
$("#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);
|
||||
$("#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;
|
||||
|
||||
|
|
@ -429,6 +432,7 @@ function createList(arr, l) {
|
|||
}
|
||||
|
||||
function targetParentToMove(parid){
|
||||
console.log(parid);
|
||||
$.ajax(
|
||||
{
|
||||
type: "GET",
|
||||
|
|
@ -517,8 +521,7 @@ allowedtypes = "application/msword, application/vnd.ms-excel, application/vnd.ms
|
|||
function uploadAction(filetodo, parid){
|
||||
var formData = new FormData($("#uploadFileForm")[0]);
|
||||
formData.append("uploadedfile", filetodo);
|
||||
|
||||
console.log(filetodo.type);
|
||||
|
||||
if(allowedtypes.includes(filetodo.type) && filetodo.type.length > 0){
|
||||
$.ajax({
|
||||
url: "{% url 'cloud-adddir' %}" + parid,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ def CloudMain(request, pk):
|
|||
context = {}
|
||||
breadcrump = []
|
||||
files = []
|
||||
|
||||
rootid = list(DataDir.objects.filter(is_root=True, agency=request.user.profile.agency))[0].pk
|
||||
if(pk == "first"):
|
||||
diragency = list(DataDir.objects.filter(is_root=True, agency=request.user.profile.agency))[0]
|
||||
|
||||
|
|
@ -34,7 +34,8 @@ def CloudMain(request, pk):
|
|||
'dirs' : alldirs,
|
||||
'parentid' : diragency.pk,
|
||||
'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:
|
||||
|
||||
|
|
@ -51,7 +52,6 @@ def CloudMain(request, pk):
|
|||
userisingroup = True
|
||||
|
||||
if userisingroup:
|
||||
|
||||
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]
|
||||
|
||||
|
|
@ -68,7 +68,8 @@ def CloudMain(request, pk):
|
|||
'parentid' : pk,
|
||||
'breadcrump' : breadcrump,
|
||||
'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:
|
||||
context = {
|
||||
|
|
@ -122,10 +123,10 @@ def adddirbyajax(request, parent):
|
|||
DataDir.objects.get(pk=request.GET.get('id'), agency=request.user.profile.agency).delete()
|
||||
except:
|
||||
success = False
|
||||
# MOVE DIR
|
||||
# MOVE FILE
|
||||
elif(request.GET.get("action") == "movefile"):
|
||||
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'))
|
||||
tempdatafile.date_last_modified = datetime.now()
|
||||
tempdatafile.save()
|
||||
# GROUPS
|
||||
|
|
@ -164,7 +165,8 @@ def adddirbyajax(request, parent):
|
|||
|
||||
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.save()
|
||||
tempdatafile.save()
|
||||
data = {'savedobj_id' : tempdatafile.pk, 'savedobj_name' : tempdatafile.name}
|
||||
else:
|
||||
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 areas.models import Areas
|
||||
from tasks.models import Tasks
|
||||
from django.contrib.auth.models import User
|
||||
from users.models import Profile, UserFullName
|
||||
from django_summernote.widgets import SummernoteInplaceWidget
|
||||
|
||||
|
||||
|
|
@ -12,16 +14,19 @@ class StandardAddStandard(forms.ModelForm):
|
|||
class Meta:
|
||||
model =Standards
|
||||
widgets = {
|
||||
'content': SummernoteInplaceWidget(),
|
||||
'content': SummernoteInplaceWidget()
|
||||
}
|
||||
labels = {
|
||||
"name" : "Titel",
|
||||
"area" : "Übergeordneter Bereich",
|
||||
"task" : "Aufgabenbereich",
|
||||
"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
|
||||
|
|
@ -45,6 +50,13 @@ class StandardAddStandard(forms.ModelForm):
|
|||
elif self.instance.pk:
|
||||
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):
|
||||
|
|
@ -70,9 +82,12 @@ class StandardUpdateStandard(forms.ModelForm):
|
|||
"name" : "Titel",
|
||||
"area" : "Übergeordneter Bereich",
|
||||
"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
|
||||
|
|
@ -99,6 +114,9 @@ class StandardUpdateStandard(forms.ModelForm):
|
|||
elif loggeduser.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):
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ from users.models import Agency
|
|||
from django.urls import reverse
|
||||
from areas.models import Areas
|
||||
from tasks.models import Tasks
|
||||
from cloud.models import DataFile
|
||||
from users.models import AgencyGroup
|
||||
import datetime
|
||||
from django.utils import timezone
|
||||
#from ckeditor_uploader.fields import RichTextUploadingField
|
||||
|
|
@ -13,11 +15,9 @@ 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')
|
||||
name = models.CharField(max_length=200, blank=False, 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_date = models.DateTimeField(default=timezone.now, blank=True)
|
||||
|
||||
|
|
@ -29,6 +29,21 @@ class Standards(models.Model):
|
|||
|
||||
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):
|
||||
return f'{self.name}'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,286 @@
|
|||
{% extends "users/base.html" %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% load counter_tag %}
|
||||
{% block content %}
|
||||
<div class="content-section col-8">
|
||||
<h3>Neuen Standard anlegen</h3>
|
||||
<div class="content-section col-12">
|
||||
<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>
|
||||
<form method="POST" id="taskareaform">
|
||||
{% csrf_token %}
|
||||
{{normalForm|crispy}}
|
||||
<form method="POST" id="addstandardform">
|
||||
{% csrf_token %}
|
||||
<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>
|
||||
<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>
|
||||
</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>
|
||||
<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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -18,13 +18,65 @@
|
|||
</small>
|
||||
<small><br />
|
||||
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>
|
||||
{% 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>
|
||||
<hr>
|
||||
{{standard.media}}
|
||||
{{standard.content|safe}}
|
||||
<div class="row col">
|
||||
|
||||
<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>
|
||||
{% endblock content %}
|
||||
|
|
@ -10,6 +10,8 @@ from django.contrib.auth.decorators import login_required
|
|||
from tasks.models import Tasks
|
||||
from areas.models import Areas
|
||||
from datetime import datetime
|
||||
from users.models import AgencyGroup
|
||||
from cloud.models import DataFile, DataDir
|
||||
|
||||
# ALLE STANDARDS EINER AGENTUR
|
||||
class StandardsManagement(LoginRequiredMixin, ListView):
|
||||
|
|
@ -53,25 +55,78 @@ def StandardAdd(request):
|
|||
new_standard.name = normalForm.cleaned_data['name']
|
||||
new_standard.content = editorForm.cleaned_data['content']
|
||||
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()
|
||||
|
||||
# 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']
|
||||
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.')
|
||||
else:
|
||||
new_standard.public = False
|
||||
new_standard.save()
|
||||
messages.success(request, f'Standard {tempstandardname} hinzugefügt! Dieser muss noch veröffentlicht werden.')
|
||||
return redirect('standards')
|
||||
else:
|
||||
print("INVALID")
|
||||
print(normalForm)
|
||||
print(editorForm)
|
||||
|
||||
else:
|
||||
normalForm = StandardAddStandard(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 = {
|
||||
'normalForm' : normalForm,
|
||||
'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)
|
||||
|
||||
|
|
@ -91,7 +146,12 @@ 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']
|
||||
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
|
||||
|
|
@ -101,7 +161,7 @@ def StandardUpdate(request, id):
|
|||
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!')
|
||||
else:
|
||||
if existing_standard.public:
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -204,4 +204,15 @@ class AgencyGroup(models.Model):
|
|||
('filesmanager', 'Dateien bearbeiten'),
|
||||
('filedirmanager', 'Ordner bearbeiten'),
|
||||
('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,8 +27,9 @@
|
|||
|
||||
<!-- include summernote css/js -->
|
||||
<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 -->
|
||||
<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">-->
|
||||
|
||||
<!-- 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/dataTables.bootstrap4.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">-->
|
||||
|
||||
<!-- Custom styles for this template-->
|
||||
<link href="{% static 'users/css/sb-admin-2.css' %}" rel="stylesheet">
|
||||
|
|
|
|||
Loading…
Reference in New Issue