QS Commit 0.8.3

This commit is contained in:
holger.trampe 2020-04-13 20:38:41 +02:00
parent d8d00279ed
commit 6fc1958626
13 changed files with 146 additions and 37 deletions

View File

@ -40,7 +40,7 @@
<td>{{agn.creator.first_name }} {{agn.creator.last_name }}</td>
<td>{{agn.created_on }}</td>
<td>{{agn.lastactivity}}</td>
<td>{% if is_adminag %} <a href="{% url 'managagn' agn.pk %}"><i class="far fa-eye"></i>&nbsp;&nbsp;{% endif %} {% if outstanding %}<i class="fas fa-info-circle" data-toggle="tooltip" data-placement="top" title="Es gibt ausstehende Einladung."></i> {% endif %}&nbsp;&nbsp;{{agsum}}{% if is_adminag %}</a>{% endif %}</td>
<td>{% if is_adminag %} <a href="{% url 'managagn' agn.pk %}">{% endif %} {% if outstanding %}<i class="fas fa-info-circle" data-toggle="tooltip" data-placement="top" title="Es gibt ausstehende Einladung."></i> {% endif %}{{agsum}}{% if is_adminag %}</a>{% endif %}</td>
<td>{{agn.standards.all|length}}</td>
<td>
{% if is_adminag %}

View File

@ -685,7 +685,19 @@ def ManageAgInAgn(request, pk):
else:
network = list(agn)[0]
allagofagn = network.members.all() | network.sharemembers.all() | network.adminagencys.all()
allagofagn = []
for a in network.members.all():
allagofagn.append(a)
for a in network.sharemembers.all():
allagofagn.append(a)
for a in network.adminagencys.all():
allagofagn.append(a)
print(allagofagn)
context = {
'active_link' : 'dasettings',
'agn' : list(agn)[0],
@ -738,7 +750,6 @@ def AgencyNetworkAjaxSettings(request):
AgencyNetworkPreperation.objects.get(pk=request.GET['agn_inv']).delete()
success = True
elif request.method == 'GET' and request.GET['action'] == "changeagrights":
print("UPDATE")
agency = Agency.objects.get(pk=request.GET['agency'])
agn = AgencyNetwork.objects.get(pk=request.GET['agnid'])
if(agency != None and agn != None):
@ -751,8 +762,6 @@ def AgencyNetworkAjaxSettings(request):
agn.sharemembers.add(agency)
elif (request.GET['newstatus'] == "2"):
agn.adminagencys.add(agency)
success = True
else:
success = False

View File

@ -15,8 +15,8 @@ import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
#BASE_URL = "https://digitale-agentur.com/"
BASE_URL = "http://localhost:8000/"
BASE_URL = "https://digitale-agentur.com/"
#BASE_URL = "http://localhost:8000/"
CRONAPIKEY = "gCddsaz6NOnE9QbXZM5LasdEk122D"
# FOR SUMMERNOTE ORIGIN
@ -174,20 +174,13 @@ GRAPPELLI_CLEAN_INPUT_TYPES = False
# EMAILs
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
'''
EMAIL_HOST = 'smtp.strato.de'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = "support@digitale-agentur.com"
EMAIL_HOST_PASSWORD = "aPx9m3!7x3m@8o!t"
DEFAULT_FROM_EMAIL = "support@digitale-agentur.com"
'''
EMAIL_HOST = 'gymhum.de'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = "holger.trampe@gymhum.de"
EMAIL_HOST_PASSWORD = "Motte2016_!"
DEFAULT_FROM_EMAIL = "holger.trampe@gymhum.de"
# FOR DATEPICKER

View File

@ -8,12 +8,12 @@ from cloud.models import DataFile
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)
#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)
oncomment = models.ForeignKey("StandardComments", on_delete=models.CASCADE)
class StandardComments(models.Model):
standard = models.ForeignKey("Standards", on_delete=models.CASCADE)

View File

@ -4,9 +4,13 @@
<div class="content-section col-12">
<h2>{{standard.name}}
{% checkifsharedstandardinagency request.user.profile.agency standard as isshared %}
{% if isshared == False %}
{% if isshared == False and standard.agency != request.user.profile.agency %}
<span style="float: right">
<button style="float: right" class="btn btn-secondary btn-sm 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></button>
<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 in meine Agentur übernehmen</button>
</span>
{% elif standard.agency == request.user.profile.agency %}
<span style="float: right; padding-top:16px; font-size: 16pt;">
<small>Standard ist aus ihrer Agentur</small>
</span>
{% else %}
<span style="float: right; padding-top:16px; font-size: 16pt;">
@ -67,7 +71,7 @@
</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}} mal geteilt.
Erstellt in Agentur <b>{{standard.agency.name}}</b> und zuletzt bearbeitet am {{ standard.last_modified_on}}. Der Standard wurde bereits {{standard.agencynetworkcounter}} mal übernommen.
</small>
</div>
<hr>
@ -77,20 +81,41 @@
<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">
{% getifuserdidcomment standard request.user as userdidcomment%}
{% if userdidcomment == False %}
<input maxlength="199" type="text" class="form-control" id="newcomment" placeholder="Mein Kommentar zum Standard {{standard.name}}">
{% else %}
Sie haben diesen Standard bereits kommentiert.
{% endif %}
</div>
<button type="button" class="btn btn-primary" onclick="javascript:newComment()">Kommentieren</button>
{% if userdidcomment == False %}
<button type="button" id="newcommentbtn" class="btn btn-primary" onclick="javascript:newComment()">Kommentieren</button>
{% endif %}
</div>
<hr>
<div id="commentsection">
{% for comment in comments %}
{% for comment in comments %}
{% getcommentstat_user comment.pk request.user as cstat %}
<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>&nbsp;
<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>&nbsp;
<button type="button" id="comment_{{comment.pk}}_rate_down" class="btn btn-sm {% if cstat == 0 %} btn-primary {% elif cstat == 'nostat' %} btn-secondary {% endif %}" {% if comment.comment_by == request.user %} disabled="true" {% endif %} onclick="javascript:rateComment({{comment.pk}}, 0)">
<i class="far fa-thumbs-down"></i>
</button>&nbsp;
{% getcommentsdown comment.pk as cdown %}
{% if cdown > 0 %}{{cdown}}&nbsp;&nbsp;&nbsp;{% endif %}
<button type="button" id="comment_{{comment.pk}}_rate_up" class="btn btn-sm {% if cstat == 1 %} btn-primary {% elif cstat == 'nostat' %} btn-secondary {% endif %}" {% if comment.comment_by == request.user %} disabled="true" {% endif %} onclick="javascript:rateComment({{comment.pk}}, 1)">
<i class="far fa-thumbs-up"></i>
</button>&nbsp;
{% getcommentsup comment.pk as cup %}
{% if cup > 0 %}{{cup}}{% endif %}
{% if comment.comment_by == request.user or standard.created_standard_by == request.user or standard.last_modified_by == request.user %}
<span style="float: right;">
@ -159,13 +184,30 @@
$("#comments_word").html("Kommentr")
}
$("#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>&nbsp;<button type="button" class="btn btn-sm btn-secondary" disabled="true"><i class="far fa-thumbs-up"></i></button>&nbsp;<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>&nbsp;<button type="button" class="btn btn-sm btn-secondary" disabled="true" ><i class="far fa-thumbs-up"></i></button>&nbsp;<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("");
$("#newcomment").remove();
$("#newcommentbtn").remove();
}
});
}
var workingid = "";
function rateComment(commentid, newstat){
$.ajax({
url: "{% url 'update_standard_by_ajax_agn' standard.pk %}",
data: {
action : 'update_comment_rate',
id : commentid,
newstat : newstat
},
success: function (data) {
location.reload();
}
});
}
function delComment(id){
workingid = id;
$.ajax({
@ -178,11 +220,11 @@
comments_counter = comments_counter - 1;
$("#comments_counter").html(comments_counter);
if(comments_counter < 2){
$("#comments_word").html("Kommentr")
$("#comments_word").html("Kommentar")
}
else{
$("#comments_word").html("Kommentr")
}s
$("#comments_word").html("Kommentare")
}
$("#comment_" + workingid).remove();
}
});

View File

@ -181,6 +181,7 @@
{% ifaginadminagn agn.pk request.user.profile.agency.pk as is_admin %}
{% ifsharemember agn.pk request.user.profile.agency.pk as is_sharemember %}
{% ifstandardinagn agn.pk standard.pk as standard_in_agn %}
{% if is_admin or is_sharemember %}
<div class="custom-control custom-checkbox mb-2">
<input type="checkbox" class="custom-control-input groupclass" onclick="javascript:standardAgn({{agn.pk}}, this.checked)" name="agn_{{agn.pk}}" id="agn_{{agn.pk}}" {% if standard_in_agn %} checked {% endif %} >

View File

@ -1,7 +1,7 @@
from django import template
from django.contrib.auth.models import Group, User
from users.models import AgencyGroup, Agency, AgencyNetwork, AgencyNetworkPreperation
from standards.models import Standards
from standards.models import Standards, StandardCommentRate, StandardComments
from message.models import Message
import os
register = template.Library()
@ -171,3 +171,47 @@ def checkifsharedstandardinagency(agency, standard):
if len(checkstandard) > 0:
in_agency = True
return in_agency
@register.simple_tag
def getcommentsdown(comment):
comment_ratings = StandardCommentRate.objects.filter(oncomment_id=comment)
counter_down = len(StandardCommentRate.objects.filter(oncomment=comment, rate_stats=0))
return counter_down
@register.simple_tag
def getcommentsup(comment):
comment_ratings = StandardCommentRate.objects.filter(oncomment_id=comment)
counter_up = len(StandardCommentRate.objects.filter(oncomment=comment, rate_stats=1))
return counter_up
@register.simple_tag
def getcommentstat_user(comment, user):
comment_rating = list(StandardCommentRate.objects.filter(oncomment_id=comment, rated_by=user))
stat = "nostat"
if len(comment_rating) == 1:
stat = comment_rating[0].rate_stats
return stat
@register.simple_tag
def getifuserdidcomment(standard, user):
comment = list(StandardComments.objects.filter(standard=standard, comment_by=user))
didcomment = False
if len(comment) > 0:
didcomment = True
return didcomment

View File

@ -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, StandardComments
from .models import Standards, StandardComments, StandardCommentRate
from django.contrib import messages
from django.http import HttpResponse, JsonResponse
from .forms import StandardAddStandard, StandardAddStandardEditor, StandardUpdateStandard, StandardUpdateStandardEditor
@ -515,10 +515,7 @@ def updatesbyajax(request, pk):
@login_required
def StandardFromAgn(request, pk):
agn = AgencyNetwork.objects.get(pk=pk)
print(agn.standards.all())
context = {
'active_link':'standards',
'standards_of_agency_network' : agn.standards.all(),
@ -551,6 +548,25 @@ def updatesbyajax_agn(request, pk):
elif(request.GET["action"] == "del_comment"):
StandardComments.objects.get(pk=request.GET.get("id")).delete()
return JsonResponse({})
elif(request.GET["action"] == "update_comment_rate"):
user = request.user
comment = StandardComments.objects.get(pk=request.GET.get("id"))
rate = list(StandardCommentRate.objects.filter(oncomment=comment, rated_by=request.user))
if len(rate) == 0:
new_s_c_rate = StandardCommentRate(oncomment=comment, rated_by=request.user, rate_stats=request.GET.get("newstat"))
new_s_c_rate.save()
else:
s_c_rate = StandardCommentRate.objects.get(pk=rate[0].pk)
s_c_rate.rate_stats=request.GET.get("newstat")
s_c_rate.save()
counter_up = len(StandardCommentRate.objects.filter(oncomment=comment, rate_stats=1))
counter_down = len(StandardCommentRate.objects.filter(oncomment=comment, rate_stats=0))
return JsonResponse({"up" : counter_up, "down" : counter_down})

View File

@ -1,8 +1,12 @@
from django.contrib import admin
from .models import Profile, Agency, AgencyGroup, AgencyJob, AgencyNetwork, AgencyNetworkPreperation
from .priomodel import Prio
from standards.models import StandardCommentRate, StandardComments
from django.contrib.auth.models import Permission
from message.models import Message
admin.site.register(StandardComments)
admin.site.register(StandardCommentRate)
admin.site.register(Permission)
admin.site.register(Profile)
admin.site.register(Agency)

View File

@ -205,7 +205,7 @@
<a style="color: #999; text-decoration: none;" href="{% url 'impressumda' %}">Impressum</a>
</div>
<div style="margin-top: 10px; margin-bottom: 5px;" class="sidebar-heading">
Version 0.8.2
Version 0.8.3
</div>
</div>
</ul>

View File

@ -45,7 +45,7 @@
<!-- Divider -->
<hr class="sidebar-divider my-0">
<div style="bottom: 10px; position: absolute;" class="sidebar-heading">
Version 0.8.2
Version 0.8.3
</div>
<div style="bottom: 40px; position: absolute;" class="sidebar-heading">
<a style="color: #999; text-decoration: none;" href="{% url 'datenschutzda' %}">Datenschutz</a><br />