Zwischencommit 5 Agenturverbund
This commit is contained in:
parent
d39aa9f2a4
commit
c7873d6d44
|
|
@ -9,6 +9,11 @@ from users.models import AgencyGroup
|
|||
import datetime
|
||||
from django.utils import timezone
|
||||
#from ckeditor_uploader.fields import RichTextUploadingField
|
||||
class StandardCommentRate(models.Model):
|
||||
standard = models.ForeignKey("Standards", on_delete=models.CASCADE)
|
||||
rated_by = models.ForeignKey(User, on_delete=models.PROTECT)
|
||||
rate_stats = models.IntegerField(default=0)
|
||||
oncomment = models.ForeignKey("StandardComments", on_delete=models.PROTECT)
|
||||
|
||||
class StandardComments(models.Model):
|
||||
standard = models.ForeignKey("Standards", on_delete=models.CASCADE)
|
||||
|
|
@ -16,10 +21,8 @@ class StandardComments(models.Model):
|
|||
comment_by = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
comment_on = models.DateTimeField(default=timezone.now, blank=True)
|
||||
last_modified_on = models.DateTimeField(default=timezone.now, blank=True)
|
||||
rated = models.IntegerField()
|
||||
|
||||
|
||||
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)
|
||||
|
|
@ -59,8 +62,8 @@ class Standards(models.Model):
|
|||
# GORUPS
|
||||
visibleby = models.ManyToManyField(AgencyGroup, blank=True)
|
||||
|
||||
indi_name = models.CharField(max_length=200, blank=False, default="")
|
||||
indi_conmtent = models.CharField(max_length=500, blank=False, default="")
|
||||
#indi_name = models.CharField(max_length=200, blank=False, default="")
|
||||
#indi_conmtent = models.CharField(max_length=500, blank=False, default="")
|
||||
|
||||
# FIELD FOR AGENCYNETWORK
|
||||
comments = models.ManyToManyField("StandardComments", blank=True, related_name='comments')
|
||||
|
|
|
|||
|
|
@ -55,7 +55,11 @@
|
|||
<div class="card-body">
|
||||
<h5 class="card-title">Beliebte Standards</h5>
|
||||
<p class="card-text">
|
||||
Keine
|
||||
{% for s in allagencynetworkstandards %}
|
||||
{% if forloop.counter < 10 %}
|
||||
<a href="{% url 'standard-single-agn' s.pk %}">{{s.name|truncatechars:30}}</a> ({{s.agencynetworkcounter}})<br/>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<div class="content-section col-12">
|
||||
<h3>Standards aus Agenturverbund {{agn.name}}</h3>
|
||||
<small>Sie sehen nur veröffentlichte Standards innerhalb des Verbunds und Standards, die nicht von Ihrer Agentur geteilt sind.</small>
|
||||
<small>Sie sehen nur veröffentlichte Standards innerhalb des Verbunds und Standards, die nicht von Ihrer Agentur geteilt worden sind.</small>
|
||||
<hr>
|
||||
|
||||
|
||||
|
|
@ -19,16 +19,20 @@
|
|||
<th scope="col">Agentur</th>
|
||||
<th scope="col">Zuletzt geändert am</th>
|
||||
<th scope="col">Geteilt</th>
|
||||
<th scope="col">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for standard in standards_of_agency_network %}
|
||||
{% checkifsharedstandardinagency request.user.profile.agency standard as isshared %}
|
||||
|
||||
{% if standard.public and standard.agency != request.user.profile.agency %}
|
||||
<tr>
|
||||
<td><a href="{% url 'standard-single-agn' standard.pk %}">{{standard.name}}</a></td>
|
||||
<td>{{standard.agency.name}}</td>
|
||||
<td>{{standard.last_modified_on|date:"d.m.Y, H:i"}}</td>
|
||||
<td>{{standard.agencynetworkcounter}}</td>
|
||||
<td>{% if isshared %}Übernommen{% endif %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
|
@ -46,9 +50,6 @@
|
|||
|
||||
$(document).ready(function(){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$('#agnstandards').DataTable({
|
||||
responsive: true,
|
||||
|
|
|
|||
|
|
@ -2,8 +2,18 @@
|
|||
{% load counter_tag %}
|
||||
{% block content %}
|
||||
<div class="content-section col-12">
|
||||
<h2>{{standard.name}}</h2>
|
||||
|
||||
<h2>{{standard.name}}
|
||||
{% checkifsharedstandardinagency request.user.profile.agency standard as isshared %}
|
||||
{% if isshared == False %}
|
||||
<span style="float: right">
|
||||
<button style="float: right" class="btn btn-primary ml-2" onclick="javascript:askForCopy()" data-toggle="tooltip" data-placement="top" title="Übernehmen Sie diesen Standard in Ihre Agentur."><small><!--<i class="fas fa-file-import" ></i></small>-->Standard übernehmen</button>
|
||||
</span>
|
||||
{% else %}
|
||||
<span style="float: right; padding-top:16px; font-size: 16pt;">
|
||||
<small>Standard übernommen</small>
|
||||
</span>
|
||||
{% endif %}
|
||||
</h2>
|
||||
<hr>
|
||||
<div class="row col">
|
||||
{% if standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.authority.count > 0 or standard.executor.count > 0 or standard.representative.count > 0 or standard.addedfiles.all|length > 0 or standard.linked_standards.all|length > 0 or standard.freefield_title|length > 0 %}
|
||||
|
|
@ -19,10 +29,7 @@
|
|||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
|
||||
|
||||
{% if standard.freefield_title|length > 0 %}
|
||||
<div class="card col-14 ml-1 mb-2" style="">
|
||||
<div class="card-body">
|
||||
|
|
@ -33,11 +40,6 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- FILES -->
|
||||
|
||||
{% if standard.addedfiles.all|length > 0 %}
|
||||
|
|
@ -57,8 +59,127 @@
|
|||
</div>
|
||||
<div class="mt-2">
|
||||
<small>
|
||||
Erstellt in Agentur <b>{{standard.agency.name}}</b> und zuletzt bearbeitet am {{ standard.last_modified_on}}. Der Standard wurde bereits {{standard.agencynetworkcounter}} geteilt.
|
||||
Erstellt in Agentur <b>{{standard.agency.name}}</b> und zuletzt bearbeitet am {{ standard.last_modified_on}}. Der Standard wurde bereits {{standard.agencynetworkcounter}} mal geteilt.
|
||||
</small>
|
||||
</div>
|
||||
<hr>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
<div class="col-6">
|
||||
<div class="mt-2">
|
||||
<p><span id="comments_counter">{{comments|length}}</span> <span id="comments_word">{% if comments|length < 2 %} Kommentar {% else %} Kommentare {% endif %}</span></p>
|
||||
<div class="form-group">
|
||||
<input maxlength="199" type="text" class="form-control" id="newcomment" placeholder="Mein Kommentar zum Standard {{standard.name}}">
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" onclick="javascript:newComment()">Kommentieren</button>
|
||||
</div>
|
||||
<hr>
|
||||
<div id="commentsection">
|
||||
{% for comment in comments %}
|
||||
|
||||
<div id="comment_{{comment.pk}}">
|
||||
<small>Von {{comment.comment_by.first_name}} {{comment.comment_by.last_name}} am {{comment.last_modified_on|date:"d.m.Y H:i"}}</small><br />
|
||||
{{comment.content}}<br/>
|
||||
<div class="mt-2">
|
||||
<!--<button type="button" class="btn btn-sm btn-secondary" {% if comment.comment_by == request.user %} disabled="true" {% endif %}><i class="far fa-thumbs-down"></i></button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" {% if comment.comment_by == request.user %} disabled="true" {% endif %}><i class="far fa-thumbs-up"></i></button> -->
|
||||
|
||||
{% if comment.comment_by == request.user or standard.created_standard_by == request.user or standard.last_modified_by == request.user %}
|
||||
<span style="float: right;">
|
||||
<button type="button" class="btn btn-sm btn-secondary" onclick="javascript:delComment({{comment.pk}})" ><i class="fa fa-trash"></i></button>
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- MODEAL NEW GROUP -->
|
||||
<div class="modal fade" id="askForCopy" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="" aria-hidden="true">
|
||||
<div class="modal-dialog " role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="modTitle">Standard übernehmen</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Möchten Sie den Standard <b>{{standard.name}}</b> inkl. aller Dateien und Informationen im Freifeld in Ihre Agentur übernehmen?<br/>
|
||||
<small>Es wird ein neuer Standard in Ihrer Agentur mit den Informationen dieses Standards erstellt.</small>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-danger" data-dismiss="modal">Abbrechen</button>
|
||||
<button type="button" class="btn btn-success" data-dismiss="modal" onclick="javascript:doCopy()">Standard übernehmen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var comments_counter = {{comments|length}};
|
||||
|
||||
function askForCopy(){
|
||||
$("#askForCopy").modal("toggle");
|
||||
}
|
||||
|
||||
function doCopy(){
|
||||
location.href = "{% url 'standard-copyagn' standard.pk %}"
|
||||
}
|
||||
|
||||
function newComment(){
|
||||
$.ajax({
|
||||
url: "{% url 'update_standard_by_ajax_agn' standard.pk %}",
|
||||
data: {
|
||||
action : 'add_comment',
|
||||
content : $("#newcomment").val()
|
||||
},
|
||||
success: function (data) {
|
||||
comments_counter = comments_counter + 1;
|
||||
$("#comments_counter").html(comments_counter);
|
||||
|
||||
if(comments_counter < 2){
|
||||
$("#comments_word").html("Kommentar");
|
||||
}
|
||||
else {
|
||||
$("#comments_word").html("Kommentare");
|
||||
}
|
||||
|
||||
$("#commentsection").prepend('<div id="comment_'+data["sc_id"]+'"><small>Von '+data['sc_user'] +' am '+data['sc_date'] +'</small><br />'+data['sc_c'] +'<span style="float: right;"><button type="button" class="btn btn-sm btn-secondary" onclick="javascript:delComment('+data['sc_id']+')" ><i class="fa fa-trash"></i></button></span></div><hr></div>');
|
||||
//$("#commentsection").prepend('<div id="comment_'+data["sc_id"]+'"><small>Von '+data['sc_user'] +' am '+data['sc_date'] +'</small><br />'+data['sc_c'] +'<br/><div class="mt-2"><button type="button" class="btn btn-sm btn-secondary" disabled="true"><i class="far fa-thumbs-down"></i></button> <button type="button" class="btn btn-sm btn-secondary" disabled="true"><i class="far fa-thumbs-up"></i></button> <span style="float: right;"><button type="button" class="btn btn-sm btn-secondary" onclick="javascript:delComment('+data['sc_id']+')" ><i class="fa fa-trash"></i></button></span></div><hr></div>');
|
||||
$("#newcomment").val("");
|
||||
}
|
||||
});
|
||||
}
|
||||
var workingid = "";
|
||||
function delComment(id){
|
||||
workingid = id;
|
||||
$.ajax({
|
||||
url: "{% url 'update_standard_by_ajax_agn' standard.pk %}",
|
||||
data: {
|
||||
action : 'del_comment',
|
||||
id : id
|
||||
},
|
||||
success: function (data) {
|
||||
comments_counter = comments_counter - 1;
|
||||
$("#comments_counter").html(comments_counter);
|
||||
if(comments_counter < 2){
|
||||
$("#comments_word").html("Kommentar");
|
||||
}
|
||||
else {
|
||||
$("#comments_word").html("Kommentare");
|
||||
}
|
||||
$("#comment_" + workingid).remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock content %}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -159,29 +159,15 @@ def getoutstandinginvites(agnetwork):
|
|||
|
||||
if len(AgencyNetworkPreperation.objects.filter(target_network=agnetwork)) > 0:
|
||||
outstanding = True
|
||||
|
||||
|
||||
return outstanding
|
||||
|
||||
|
||||
'''
|
||||
class Counter:
|
||||
count = 0
|
||||
@register.simple_tag
|
||||
def increment(self):
|
||||
self.count += 1
|
||||
return ''
|
||||
@register.simple_tag
|
||||
def checkifsharedstandardinagency(agency, standard):
|
||||
|
||||
@register.simple_tag
|
||||
def decrement(self):
|
||||
self.count -= 1
|
||||
return ''
|
||||
checkstandard = Standards.objects.filter(agency=agency, parent_standard=standard)
|
||||
|
||||
@register.simple_tag
|
||||
def double(self):
|
||||
self.count *= 2
|
||||
return ''
|
||||
in_agency = False
|
||||
|
||||
def getCounter(self):
|
||||
return count
|
||||
'''
|
||||
if len(checkstandard) > 0:
|
||||
in_agency = True
|
||||
return in_agency
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ urlpatterns = [
|
|||
path('standardupdate/<int:id>', views.StandardUpdate, name='standard-update'),
|
||||
path('ajax/loadtasks/', views.load_tasks, name='ajax_loadtasks'),
|
||||
path('ajups/<int:pk>', views.updatesbyajax, name='update_standard_by_ajax'),
|
||||
path('ajupsagn/<int:pk>', views.updatesbyajax_agn, name='update_standard_by_ajax_agn'),
|
||||
path('standards/<int:pk>/delete', StandardDeleteView.as_view(), name='standard-delete'),
|
||||
path('standard/<int:pk>/changestat', views.StandardChangePublic, name="standard-status"),
|
||||
path('standard/<int:pk>/single', views.StandardSingle, name="standard-single"),
|
||||
|
|
@ -20,4 +21,8 @@ urlpatterns = [
|
|||
path('standard/<int:pk>/area', views.StandardArea, name="standard-area"),
|
||||
path('standard/<int:pk>/task', views.StandardTask, name="standard-task"),
|
||||
path('standardsagn/<int:pk>', views.StandardFromAgn, name="standard-agn"),
|
||||
path('standardcopy/<int:pk>', views.CopyStandard, name="standard-copyagn"),
|
||||
|
||||
|
||||
|
||||
]
|
||||
|
|
@ -2,7 +2,7 @@ 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 .models import Standards, StandardComments
|
||||
from django.contrib import messages
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from .forms import StandardAddStandard, StandardAddStandardEditor, StandardUpdateStandard, StandardUpdateStandardEditor
|
||||
|
|
@ -13,6 +13,8 @@ from datetime import datetime
|
|||
from users.models import AgencyGroup, AgencyNetwork
|
||||
from cloud.models import DataFile, DataDir
|
||||
from django.contrib.auth.decorators import login_required
|
||||
import re
|
||||
from django.template import defaultfilters
|
||||
|
||||
# ALLE STANDARDS EINER AGENTUR
|
||||
class StandardsManagement(LoginRequiredMixin, ListView):
|
||||
|
|
@ -42,10 +44,15 @@ class StandardsManagement(LoginRequiredMixin, ListView):
|
|||
|
||||
agencynetworks = AgencyNetwork.objects.filter(creator_agency=self.request.user.profile.agency) | AgencyNetwork.objects.filter(adminagencys__in=[self.request.user.profile.agency.pk]) | AgencyNetwork.objects.filter(members__in=[self.request.user.profile.agency.pk]) | AgencyNetwork.objects.filter(sharemembers__in=[self.request.user.profile.agency.pk])
|
||||
|
||||
allagencynetworkstandards = []
|
||||
for agn in agencynetworks:
|
||||
for agn_s in agn.standards.all():
|
||||
allagencynetworkstandards.append(agn_s)
|
||||
|
||||
|
||||
|
||||
context.update({'active_link' : 'standards', 'unpubstandards_of_user' : unpubstandards_of_user, 'areas' : areas, 'standards_of_user' : standards_of_user, 'standardcontent' : standardcontent, "agencynetworks" : agencynetworks})
|
||||
|
||||
allagencynetworkstandards.sort(key=lambda x: x.agencynetworkcounter, reverse=True)
|
||||
|
||||
context.update({'active_link' : 'standards', 'unpubstandards_of_user' : unpubstandards_of_user, 'areas' : areas, 'standards_of_user' : standards_of_user, 'standardcontent' : standardcontent, "agencynetworks" : agencynetworks, "allagencynetworkstandards" : allagencynetworkstandards})
|
||||
|
||||
return context
|
||||
|
||||
|
|
@ -374,15 +381,47 @@ def StandardSingle(request, pk):
|
|||
}
|
||||
return render(request, 'standards/standards_noentrie.html', context)
|
||||
|
||||
|
||||
|
||||
@login_required
|
||||
def StandardSingleAgn(request, pk):
|
||||
def CopyStandard(request, pk):
|
||||
#SANDARD COPY
|
||||
sc = Standards.objects.get(pk=pk)
|
||||
sc.agencynetworkcounter = sc.agencynetworkcounter+1
|
||||
sc.save()
|
||||
|
||||
context = {
|
||||
'active_link':'standards',
|
||||
'standard' : Standards.objects.get(pk=pk)
|
||||
}
|
||||
return render(request, 'standards/standards_single_agn.html', context)
|
||||
area = list(Areas.objects.filter(agency=request.user.profile.agency))[0]
|
||||
task = list(Tasks.objects.filter(agency=request.user.profile.agency))[0]
|
||||
|
||||
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.created_standard_date = datetime.now()
|
||||
new_standard.last_modified_on = datetime.now()
|
||||
new_standard.task = task
|
||||
new_standard.area = area
|
||||
new_standard.name = sc.name
|
||||
new_standard.content = sc.content
|
||||
new_standard.public = False
|
||||
|
||||
new_standard.freefield_content = sc.freefield_content
|
||||
new_standard.freefield_title = sc.freefield_title
|
||||
|
||||
new_standard.parent_standard = sc
|
||||
new_standard.shared_on = datetime.now()
|
||||
|
||||
new_standard.save()
|
||||
|
||||
datadir_parentid = list(DataDir.objects.filter(is_defaultstandard=True, agency__pk=request.user.profile.agency.pk))[0]
|
||||
|
||||
for f in sc.addedfiles.all():
|
||||
tempdatafile = DataFile(file=f.file, name=f.name, owner=request.user, parent=datadir_parentid, agency=request.user.profile.agency)
|
||||
tempdatafile.save()
|
||||
new_standard.addedfiles.add(tempdatafile)
|
||||
|
||||
return redirect('standard-update', new_standard.pk)
|
||||
|
||||
@login_required
|
||||
def StandardArea(request, pk):
|
||||
|
|
@ -411,7 +450,7 @@ def StandardTask(request, pk):
|
|||
}
|
||||
return render(request, 'standards/standard_task.html', context)
|
||||
|
||||
# AJAX SHIT
|
||||
# AJAX Standard
|
||||
@login_required
|
||||
def updatesbyajax(request, pk):
|
||||
if(request.method == "GET"):
|
||||
|
|
@ -467,8 +506,7 @@ def updatesbyajax(request, pk):
|
|||
else:
|
||||
agn.standards.remove(workingstandard)
|
||||
agn.lastactivity = datetime.now()
|
||||
agn.save()
|
||||
|
||||
agn.save()
|
||||
else:
|
||||
success = False
|
||||
|
||||
|
|
@ -487,3 +525,32 @@ def StandardFromAgn(request, pk):
|
|||
'agn' :agn,
|
||||
}
|
||||
return render(request, 'standards/standards_from_agn.html', context)
|
||||
|
||||
|
||||
# View for SingleStandard from AgencyNetwork
|
||||
@login_required
|
||||
def StandardSingleAgn(request, pk):
|
||||
|
||||
context = {
|
||||
'active_link':'standards',
|
||||
'standard' : Standards.objects.get(pk=pk),
|
||||
'comments' : StandardComments.objects.filter(standard=Standards.objects.get(pk=pk)).order_by("-last_modified_on")
|
||||
}
|
||||
return render(request, 'standards/standards_single_agn.html', context)
|
||||
|
||||
@login_required
|
||||
def updatesbyajax_agn(request, pk):
|
||||
if(request.method == "GET"):
|
||||
|
||||
if(request.GET["action"] == "add_comment"):
|
||||
content = re.sub('[^A-Za-z0-9,!?_ äüöÄÜÖ]+', '', request.GET.get("content"))
|
||||
sc = StandardComments(standard=Standards.objects.get(pk=pk), content=content, comment_by=request.user, comment_on=datetime.now(), last_modified_on=datetime.now())
|
||||
sc.save()
|
||||
|
||||
return JsonResponse({"success" : "success", "sc_id" : sc.pk, "sc_c" : sc.content, "sc_user" : sc.comment_by.first_name + " " + sc.comment_by.last_name, "sc_date" : defaultfilters.date(sc.last_modified_on, "SHORT_DATETIME_FORMAT") })
|
||||
elif(request.GET["action"] == "del_comment"):
|
||||
StandardComments.objects.get(pk=request.GET.get("id")).delete()
|
||||
return JsonResponse({})
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue