From 6363b110bc1e137a4d5dcc8e2f8e9bcbebf32402 Mon Sep 17 00:00:00 2001 From: "holger.trampe" Date: Sat, 25 Apr 2020 02:06:35 +0200 Subject: [PATCH] =?UTF-8?q?Zwischenpush=20f=C3=BCr=20Umbau=20Standards=20u?= =?UTF-8?q?nd=20Kleinkram?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dasettings/structure_content.html | 2 +- .../__pycache__/settings.cpython-38.pyc | Bin 3946 -> 3921 bytes digitaleagentur/settings.py | 31 +- orga/templates/orga/orga_single.html | 12 +- standards/forms.py | 4 + standards/models.py | 15 +- .../templates/standards/standards_add.html | 424 +++++++---- .../standards/standards_add_SAVE.html | 710 ++++++++++++++++++ .../templates/standards/standards_single.html | 135 +++- standards/views.py | 34 +- 10 files changed, 1206 insertions(+), 161 deletions(-) create mode 100644 standards/templates/standards/standards_add_SAVE.html diff --git a/dasettings/templates/dasettings/structure_content.html b/dasettings/templates/dasettings/structure_content.html index 39f5b6b..6ef1633 100644 --- a/dasettings/templates/dasettings/structure_content.html +++ b/dasettings/templates/dasettings/structure_content.html @@ -242,7 +242,7 @@ noclickeffect:active { border-style: outset !important;} {% endif %} diff --git a/standards/forms.py b/standards/forms.py index 4d58e72..c3b4b2d 100644 --- a/standards/forms.py +++ b/standards/forms.py @@ -65,6 +65,10 @@ class StandardAddStandard(forms.ModelForm): self.fields['added_files'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) self.fields['added_standards'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + self.fields['added_quicklinks'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + self.fields['added_contacts'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + self.fields['added_passwords'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) + self.fields['us_verant'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) self.fields['us_ex'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) self.fields['us_ver'] = forms.CharField(initial="", required=False, widget=forms.HiddenInput()) diff --git a/standards/models.py b/standards/models.py index 6320805..fc57ce2 100644 --- a/standards/models.py +++ b/standards/models.py @@ -6,6 +6,7 @@ from areas.models import Areas from tasks.models import Tasks from cloud.models import DataFile from users.models import AgencyGroup +from organizer.models import AGPassword, AGContacts, QuickLinks import datetime from django.utils import timezone @@ -24,8 +25,8 @@ class StandardComments(models.Model): class Standards(models.Model): agency = models.ForeignKey(Agency, on_delete=models.CASCADE) - area = models.ForeignKey(Areas, on_delete=models.CASCADE, blank=True, null=True) - task = models.ForeignKey(Tasks, on_delete=models.CASCADE, blank=True, null=True) + area = models.ForeignKey(Areas, on_delete=models.SET_NULL, blank=True, null=True) + task = models.ForeignKey(Tasks, on_delete=models.SET_NULL, blank=True, null=True) name = models.CharField(max_length=200, blank=False, default="") content = models.TextField(blank=True, verbose_name='Inhalt', default="") @@ -63,14 +64,20 @@ class Standards(models.Model): # VERLINKTE STANDARDS linked_standards = models.ManyToManyField('Standards', blank=True) # GORUPS - visibleby = models.ManyToManyField(AgencyGroup, blank=True) + visibleby = models.ManyToManyField(AgencyGroup, blank=True) + # Contacts + addedcontacts = models.ManyToManyField(AGContacts, blank=True) + # Passwords + addedpasswords = models.ManyToManyField(AGPassword, blank=True) + # Quicklinks + addedquicklinks = models.ManyToManyField(QuickLinks, blank=True, related_name="standard_quicklinks") #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') - parent_standard = models.ForeignKey("Standards", related_name='partentedstandard', on_delete=models.PROTECT, blank=True, null=True, default=None) + parent_standard = models.ForeignKey("Standards", related_name='partentedstandard', on_delete=models.SET_NULL, blank=True, null=True, default=None) shared_on = models.DateTimeField(default=timezone.now, blank=True) favoritfrom = models.ManyToManyField(User, blank=True, related_name="FavoritFrom") diff --git a/standards/templates/standards/standards_add.html b/standards/templates/standards/standards_add.html index 6df3c8d..4ddf249 100644 --- a/standards/templates/standards/standards_add.html +++ b/standards/templates/standards/standards_add.html @@ -32,7 +32,7 @@
-
+
- - -
+
+
+
+
+ +
+
+
+
+
+ +
+ +
+ + {% for s in standards %} + + {% endfor %} + +
+ Verlinkte Standards: + +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+ + {% if request.user.profile.agency.module_files %} +
+
+
+ +
+
+
+
+
+ +
+ +
+ + {% for f in files %} + + {% endfor %} + +
+ Verlinkte Dateien: + +
+ + + {% if user|usergperm:"filesmanager" %} + + {% endif %} + +
+
+
+ {% endif %} +
- - - - - - - - +
@@ -97,72 +172,7 @@
- {% if request.user.profile.agency.module_files %} -
-
-
- -
-
-
-
-
- -
- -
- - {% for f in files %} - - {% endfor %} - -
- Verlinkte Dateien: - -
- - - {% if user|usergperm:"filesmanager" %} - - {% endif %} - -
-
-
- {% endif %} -
-
-
- -
-
-
-
-
- -
- -
- - {% for s in standards %} - - {% endfor %} - -
- Verlinkte Standards: - -
-
-
-
-
+
@@ -353,6 +363,109 @@
+ + + + + + + + + + + + -{% if not perms.users.standard_management %} +{% if not perms.users.standardmanager %} + +{% if not perms.users.standard_management %} + + + +{% endif %} + +{% endblock content %} diff --git a/standards/templates/standards/standards_single.html b/standards/templates/standards/standards_single.html index 6cfd266..f1e8491 100644 --- a/standards/templates/standards/standards_single.html +++ b/standards/templates/standards/standards_single.html @@ -23,7 +23,7 @@
- {% 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 %} + {% 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 or standard.addedcontacts.all|length > 0 or standard.addedpasswords.all|length > 0 or standard.addedquicklinks.all|length > 0 %}
{% else %}
@@ -38,7 +38,7 @@
- {% if 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 %} + {% 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 or standard.addedcontacts.all|length > 0 or standard.addedpasswords.all|length > 0 or standard.addedquicklinks.all|length > 0 %}
@@ -106,6 +106,53 @@
{% endif %} + + + {% if standard.addedquicklinks.all|length > 0 %} +
+
+
Quicklinks
+

+ {% for ql in standard.addedquicklinks.all %} + {{ ql.link|truncatechars:30 }} + {% endfor %} +

+
+
+ {% endif %} + + + + {% if standard.addedcontacts.all|length > 0 %} +
+
+
Kontakte
+

+ {% for agc in standard.addedcontacts.all %} + {{agc.company}}
+ {% endfor %} +

+
+
+ {% endif %} + + + {% if standard.addedpasswords.all|length > 0 %} +
+
+
Passwörter
+

+ {% for s in standard.addedpasswords.all %} + {{s.name}}
+ {% endfor %} +

+
+
+ {% endif %} + + + + {% if standard.linked_standards.all|length > 0 %}
@@ -148,4 +195,88 @@
+ + +{% for pass in standard.addedpasswords.all %} + +{% endfor %} + + + +{% for agc in standard.addedcontacts.all %} + +{% endfor %} + {% endblock content %} \ No newline at end of file diff --git a/standards/views.py b/standards/views.py index a3a4c18..0c85d19 100644 --- a/standards/views.py +++ b/standards/views.py @@ -15,6 +15,7 @@ from cloud.models import DataFile, DataDir from django.contrib.auth.decorators import login_required import re from django.template import defaultfilters +from organizer.models import QuickLinks, AGContacts, AGPassword # ALLE STANDARDS EINER AGENTUR class StandardsManagement(LoginRequiredMixin, ListView): @@ -165,7 +166,6 @@ def StandardAdd(request): # ADD GROUPS groups = normalForm.cleaned_data['checked_groups'].split(",") - for g in groups: if(g.isdigit()): @@ -179,11 +179,29 @@ def StandardAdd(request): # ADD FILES files = normalForm.cleaned_data['added_files'].split(",") - for f in files: if(f.isdigit()): new_standard.addedfiles.add(DataFile.objects.get(pk=f)) + # ADD QUICKLINKS + quicklinks = normalForm.cleaned_data['added_quicklinks'].split(",") + for f in quicklinks: + if(f.isdigit()): + new_standard.addedquicklinks.add(QuickLinks.objects.get(pk=f)) + + # ADD PASSWORDS + addedpasswords = normalForm.cleaned_data['added_passwords'].split(",") + for f in addedpasswords: + if(f.isdigit()): + new_standard.addedpasswords.add(AGPassword.objects.get(pk=f)) + + # ADD CONTACTS + contacts = normalForm.cleaned_data['added_contacts'].split(",") + for f in contacts: + if(f.isdigit()): + new_standard.addedcontacts.add(AGContacts.objects.get(pk=f)) + + tempstandardname = normalForm.cleaned_data['name'] if(new_standard.public and request.user.has_perm('users.standardmanager')): messages.success(request, f'Standard {tempstandardname} hinzugefügt und veröffentlicht.') @@ -218,7 +236,10 @@ def StandardAdd(request): 'usersofagency' : User.objects.filter(profile__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) + 'standards' : Standards.objects.filter(agency=request.user.profile.agency, public=True), + 'quicklinks' : QuickLinks.objects.filter(agency=request.user.profile.agency), + 'contacts' : AGContacts.objects.filter(agency=request.user.profile.agency), + 'passwords' : AGPassword.objects.filter(agency=request.user.profile.agency), } return render(request, 'standards/standards_add.html', context) @@ -312,9 +333,14 @@ def StandardUpdate(request, id): if pv not in standard.representative.all(): possible_ver_final.append(pv) - agencynetworks = AgencyNetwork.objects.filter(creator_agency=request.user.profile.agency) | AgencyNetwork.objects.filter(adminagencys__in=[request.user.profile.agency.pk]) | AgencyNetwork.objects.filter(members__in=[request.user.profile.agency.pk]) | AgencyNetwork.objects.filter(sharemembers__in=[request.user.profile.agency.pk]) + #agencynetworks = AgencyNetwork.objects.filter(creator_agency=request.user.profile.agency) | AgencyNetwork.objects.filter(adminagencys__in=[request.user.profile.agency.pk]) | AgencyNetwork.objects.filter(members__in=[request.user.profile.agency.pk]) | AgencyNetwork.objects.filter(sharemembers__in=[request.user.profile.agency.pk]) + agencynetworks_all = AgencyNetwork.objects.all() + agencynetworks = [] + for a in agencynetworks_all: + if self.request.user.profile.agency in a.adminagencys.all() or self.request.user.profile.agency in a.members.all() or self.request.user.profile.agency in a.sharemembers.all(): + agencynetworks.append(a) context = { 'normalForm' : normalForm,