diff --git a/dasettings/templates/dasettings/agencynetwork_content.html b/dasettings/templates/dasettings/agencynetwork_content.html index c758f8e..3cdb819 100644 --- a/dasettings/templates/dasettings/agencynetwork_content.html +++ b/dasettings/templates/dasettings/agencynetwork_content.html @@ -40,7 +40,7 @@ {{agn.creator.first_name }} {{agn.creator.last_name }} {{agn.created_on }} {{agn.lastactivity}} - {% if is_adminag %}   {% endif %} {% if outstanding %} {% endif %}  {{agsum}}{% if is_adminag %}{% endif %} + {% if is_adminag %} {% endif %} {% if outstanding %} {% endif %}{{agsum}}{% if is_adminag %}{% endif %} {{agn.standards.all|length}} {% if is_adminag %} diff --git a/dasettings/views.py b/dasettings/views.py index 4c80b18..d46655c 100644 --- a/dasettings/views.py +++ b/dasettings/views.py @@ -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 diff --git a/digitaleagentur/__pycache__/settings.cpython-38.pyc b/digitaleagentur/__pycache__/settings.cpython-38.pyc index 40c547c..1661d7a 100644 Binary files a/digitaleagentur/__pycache__/settings.cpython-38.pyc and b/digitaleagentur/__pycache__/settings.cpython-38.pyc differ diff --git a/digitaleagentur/settings.py b/digitaleagentur/settings.py index eeaede3..0995162 100644 --- a/digitaleagentur/settings.py +++ b/digitaleagentur/settings.py @@ -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 diff --git a/standards/models.py b/standards/models.py index e4938bb..4e5d840 100644 --- a/standards/models.py +++ b/standards/models.py @@ -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) diff --git a/standards/templates/standards/standards_single_agn.html b/standards/templates/standards/standards_single_agn.html index 56ce8d4..6d94a33 100644 --- a/standards/templates/standards/standards_single_agn.html +++ b/standards/templates/standards/standards_single_agn.html @@ -4,9 +4,13 @@

{{standard.name}} {% checkifsharedstandardinagency request.user.profile.agency standard as isshared %} - {% if isshared == False %} + {% if isshared == False and standard.agency != request.user.profile.agency %} - + + + {% elif standard.agency == request.user.profile.agency %} + + Standard ist aus ihrer Agentur {% else %} @@ -67,7 +71,7 @@

- Erstellt in Agentur {{standard.agency.name}} und zuletzt bearbeitet am {{ standard.last_modified_on}}. Der Standard wurde bereits {{standard.agencynetworkcounter}} mal geteilt. + Erstellt in Agentur {{standard.agency.name}} und zuletzt bearbeitet am {{ standard.last_modified_on}}. Der Standard wurde bereits {{standard.agencynetworkcounter}} mal übernommen.

@@ -77,20 +81,41 @@

{{comments|length}} {% if comments|length < 2 %} Kommentar {% else %} Kommentare {% endif %}

+ {% getifuserdidcomment standard request.user as userdidcomment%} + + {% if userdidcomment == False %} + {% else %} + Sie haben diesen Standard bereits kommentiert. + {% endif %}
- + {% if userdidcomment == False %} + + {% endif %}

- {% for comment in comments %} + + {% for comment in comments %} + {% getcommentstat_user comment.pk request.user as cstat %}
Von {{comment.comment_by.first_name}} {{comment.comment_by.last_name}} am {{comment.last_modified_on|date:"d.m.Y H:i"}}
{{comment.content}}
-   -   +   + {% getcommentsdown comment.pk as cdown %} + {% if cdown > 0 %}{{cdown}}   {% endif %} + + +   + {% 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 %} @@ -159,13 +184,30 @@ $("#comments_word").html("Kommentr") } - $("#commentsection").prepend('
Von '+data['sc_user'] +' am '+data['sc_date'] +'
'+data['sc_c'] +'
  

'); + $("#commentsection").prepend('
Von '+data['sc_user'] +' am '+data['sc_date'] +'
'+data['sc_c'] +'
  

'); - $("#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(); } }); diff --git a/standards/templates/standards/standards_update.html b/standards/templates/standards/standards_update.html index 0866f13..f182c67 100644 --- a/standards/templates/standards/standards_update.html +++ b/standards/templates/standards/standards_update.html @@ -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 %}
diff --git a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc index 43b55d5..403e47e 100644 Binary files a/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc and b/standards/templatetags/__pycache__/counter_tag.cpython-38.pyc differ diff --git a/standards/templatetags/counter_tag.py b/standards/templatetags/counter_tag.py index 7d59f05..fbb2b63 100644 --- a/standards/templatetags/counter_tag.py +++ b/standards/templatetags/counter_tag.py @@ -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 + + diff --git a/standards/views.py b/standards/views.py index 00249f7..7965b58 100644 --- a/standards/views.py +++ b/standards/views.py @@ -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}) diff --git a/users/admin.py b/users/admin.py index 1d94d65..3cabb90 100644 --- a/users/admin.py +++ b/users/admin.py @@ -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) diff --git a/users/templates/users/base.html b/users/templates/users/base.html index 26de9b3..dfb00df 100644 --- a/users/templates/users/base.html +++ b/users/templates/users/base.html @@ -205,7 +205,7 @@ Impressum
diff --git a/users/templates/users/publicbase.html b/users/templates/users/publicbase.html index cdce693..959851f 100644 --- a/users/templates/users/publicbase.html +++ b/users/templates/users/publicbase.html @@ -45,7 +45,7 @@