From 6fc1958626aafcd3c8b1ecdad63bacf04738de4a Mon Sep 17 00:00:00 2001 From: "holger.trampe" Date: Mon, 13 Apr 2020 20:38:41 +0200 Subject: [PATCH] QS Commit 0.8.3 --- .../dasettings/agencynetwork_content.html | 2 +- dasettings/views.py | 17 +++-- .../__pycache__/settings.cpython-38.pyc | Bin 3838 -> 3860 bytes digitaleagentur/settings.py | 13 +--- standards/models.py | 6 +- .../standards/standards_single_agn.html | 66 ++++++++++++++---- .../templates/standards/standards_update.html | 1 + .../__pycache__/counter_tag.cpython-38.pyc | Bin 4440 -> 5450 bytes standards/templatetags/counter_tag.py | 46 +++++++++++- standards/views.py | 24 +++++-- users/admin.py | 4 ++ users/templates/users/base.html | 2 +- users/templates/users/publicbase.html | 2 +- 13 files changed, 146 insertions(+), 37 deletions(-) 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 40c547c72435ddb350d5e0dd9b17f1ded29727a1..1661d7aeb90118846cfb5407ea1de0a73dc2c7af 100644 GIT binary patch delta 167 zcmew-J4KE!l$V!_0SK0EoD!EHx{>b=ldNn;Nl8JmmA-yTW_o5xVos`VVtQ&`NokQ@ za(?b6W?l{#zT(`H0=?prqQsJXy_D2UZzcwYDw*Qaf`a^_5(jMBsss`PDlBu270oM* qa~&-56-zcdald9_W@2HQY{0i!nu&!G4q2HPnEtb{GBJW^rvCtkdNAt% delta 124 zcmbOt_fM8Dl$V!_0SMOgO^DMG+sJo^NlYxGq@=(~Uq2^5IWZ?AzqrK8!oa{_GdnXc zhbd=zWo|}ku3k!NrZ*D+c&?YB-O~k&@5hYa|HKm UCT3<9#>sAcn;AJL|KgJZ02SUP)Bpeg 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 43b55d537fd286516fc7a8b65a47b2392e5ac219..403e47ec127203f0ba2b5f82fc2cee0eca84d350 100644 GIT binary patch literal 5450 zcmcgwOLN@D5yk-6CwG^WNQsn0J*^k?pl!vrVkeczmLl1S%}QBPB|&I!z#VXjC4glH zSUF5BPfAsC(Iw?$4q{a zPn*rUfoJ(IUw*#7U>N@*V*If{+(S$LDGWmzQiMh%Tp?&|hGt~BR%E+2(^goD%5FKT zxRt2tR->9*W4;~MqZxN5YPgN4={A{H3R}^vJImv8IOop!;^nbD!#yqyZ(dfs1^;;O zgsjTi?~LcdJ;_vE&M>veR6{nIS^{-Sw&d&!A?IX^d8c{BF?pP+Gfd6P1*VpnIw4Oo zb(Y^=uC$dQDzt z>NTdW$g50UX6l-}&eRpA9C?GOt4!ULx0t%d)NQ%K)ODs_mv1oTF!iRq!_*C?z9Zja z>Lycf%XgT%#nfH-U8Zi!@?*n!_bc+XBXl+OqwUa3eaFc!GiGSTzJ@P0pv{5bs-AJlVG z%mm_8KJk;p>-wt?JAmEjp)s}lXh{{_(C`4s$Hu<7s*Qc2#X7puGcO$Y`-YmwimxBv ze{YR6N!C8>hh1N-J?M7^^zmfv(MM0#WY7&#FZA)TI31|9q!4zkut@54leJEN5U0Ls zgIL+#(dEQXpLwcDa@gn$%NFVc{&$ENe@5ccveba6VpYvz%+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lh}t>vgZgd@XQQi>A0jB@RH$=5VQ|Ol8$Gjs_kjx)(Tg_XVWJdI;9Vx3Stpm0x3L*p|q|@4SIkF5Q$9 zp6nA8jQ=OQ9)@)(`0A(+i^EGugGR5D8cF+d?zFY>V-!Edb#_J8xxE9IWWX_Hs8`&? z-(}#kw5bBTEUk`exuYYU$o*xa&bBf4&Hu}dBcK5tlRNIdZGicV^!JiY@n`(C+t2PB z2kl4YwWY@|4^r}@A;pg5qcJhp4_U6&pJ;zmYq1-`(Yk3mITib)Yod!MT4mz2)YJ;w z6=zbfvQ6<}s-7J!!vGAG2fQgBrAxZXsMj*haXDa06i%0oxs$(9=JTdR{ht-!?DcV{l)WkYH(6WC`(m{?=c~ CQgDF) 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 @@