Skip to content

Commit

Permalink
Merge branch 'crud-cds-websites' of https://github.com/UniversitaDell…
Browse files Browse the repository at this point in the history
…aCalabria/storage.portale into crud-cds-websites
  • Loading branch information
revelis-vincenzo committed Nov 23, 2023
2 parents 5d13d76 + 81bc13c commit 5f13521
Show file tree
Hide file tree
Showing 48 changed files with 1,499 additions and 801 deletions.
2 changes: 1 addition & 1 deletion crud/cds/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ class CRUDCdsConfig(AppConfig):

def ready(self):
# Signals
import crud.cds.signals
from . import signals
7 changes: 6 additions & 1 deletion crud/cds/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ def new_func(*original_args, **original_kwargs):

departments = []

for myoffice in original_kwargs['my_offices']:
my_offices = OrganizationalStructureOfficeEmployee.objects.filter(employee=request.user,
office__name=OFFICE_CDS,
office__is_active=True,
office__organizational_structure__is_active=True)
# for myoffice in original_kwargs['my_offices']:
for myoffice in my_offices:
if myoffice.office.organizational_structure.unique_code not in departments:
departments.append(
myoffice.office.organizational_structure.unique_code)
Expand Down
39 changes: 38 additions & 1 deletion crud/cds/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
from django.conf import settings

from ricerca_app.models import (
DidatticaCds, DidatticaCdsAltriDati, DidatticaCdsAltriDatiUfficio)
DidatticaCds, DidatticaCdsAltriDati,
DidatticaCdsAltriDatiUfficio, DidatticaCdsGruppi,
DidatticaCdsGruppiComponenti)

from .. utils.forms import ChoosenPersonForm
from .. utils.settings import CMS_STORAGE_ROOT_API


Expand Down Expand Up @@ -68,3 +71,37 @@ class Meta:
"manifesto_studi": _("Study manifesto"),
"regolamento_didattico": _("Didactic regulation"),
}


class DidatticaCdsGruppoForm(forms.ModelForm):
class Meta:
model = DidatticaCdsGruppi
fields = ['visibile', 'descr_breve_it', 'descr_breve_en', 'descr_lunga_it',
'descr_lunga_en', 'ordine']
# labels = {
# "manifesto_studi": _("Study manifesto"),
# "regolamento_didattico": _("Didactic regulation"),
# }
widgets = {'descr_breve_it': forms.Textarea(attrs={'rows': 2}),
'descr_breve_en': forms.Textarea(attrs={'rows': 2}),
'descr_lunga_it': forms.Textarea(attrs={'rows': 2}),
'descr_lunga_en': forms.Textarea(attrs={'rows': 2})}



class Media:
js = ('js/textarea-autosize.js',)


class DidatticaCdsGruppoComponenteForm(forms.ModelForm):
class Meta:
model = DidatticaCdsGruppiComponenti
fields = ['visibile', 'nome', 'cognome', 'funzione_it',
'funzione_en', 'ordine']


class ChoosenPersonForm(ChoosenPersonForm, forms.ModelForm):

class Meta:
model = DidatticaCdsGruppiComponenti
fields = ['visibile', 'funzione_it', 'funzione_en', 'ordine']
6 changes: 3 additions & 3 deletions crud/cds/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def pre_save_manifesto_studi(sender, instance, *args, **kwargs):
""" instance old image file will delete from os """
try:
old = instance.__class__.objects.get(id=instance.id).manifesto_studi.path
old = instance.__class__.objects.get(pk=instance.pk).manifesto_studi.path
try:
new = instance.manifesto_studi.path
except:
Expand All @@ -25,7 +25,7 @@ def pre_save_manifesto_studi(sender, instance, *args, **kwargs):
def pre_save_regolamento_didattico(sender, instance, *args, **kwargs):
""" instance old image file will delete from os """
try:
old = instance.__class__.objects.get(id=instance.id).regolamento_didattico.path
old = instance.__class__.objects.get(pk=instance.pk).regolamento_didattico.path
try:
new = instance.regolamento_didattico.path
except:
Expand All @@ -40,7 +40,7 @@ def pre_save_regolamento_didattico(sender, instance, *args, **kwargs):
def pre_save_ordinamento_didattico(sender, instance, *args, **kwargs):
""" instance old image file will delete from os """
try:
old = instance.__class__.objects.get(id=instance.id).ordinamento_didattico.path
old = instance.__class__.objects.get(pk=instance.pk).ordinamento_didattico.path
try:
new = instance.ordinamento_didattico.path
except:
Expand Down
213 changes: 85 additions & 128 deletions crud/cds/templates/cds_detail.html

Large diffs are not rendered by default.

135 changes: 135 additions & 0 deletions crud/cds/templates/cds_group.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{% extends "storage_crud_base.html" %}

{% load i18n %}
{% load static %}


{% block centered_container %}
<p style="font-weight: lighter;" class="h3 mb-4">
{% if group %}
{% trans "Edit" %} {{ group.descr_breve_it }}
{% else %}
{% trans "New cds group" %}
{% endif %}
</p>
<div class="card-wrapper card-space">
<div class="card card-bg no-after">
<div class="card-body">
<form method="post" novalidate>
{% include "form_template.html" with form=form %}
{% include "includes/form_submit.html" %}
</form>
</div>
</div>
</div>

{% if group %}
<div class="card-wrapper card-space">
<div class="card card-bg no-after">
<div class="card-body">
<p style="font-weight: lighter;" class="mb-4 h3">
{% trans "Members" %}
</p>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>#</th>
<th>{% trans "Name" %}</th>
<th>{% trans "Function" %}</th>
<th>{% trans "Visible" %}</th>
<th></th>
</tr>
</thead>
<tbody>
{% for member in group.didatticacdsgruppicomponenti_set.all %}
<tr>
<td>{{ member.ordine }}</td>
<td>
{{ member.cognome }} {{ member.nome }}
{% if member.matricola %}
<br>
({% trans "Link to" %}: {{ member.matricola|default:"-" }})
{% endif %}
</td>
<td>{{ member.funzione_it|default:"-" }}</td>
<td>
{% if member.visibile %}
<svg class="icon icon-sm icon-success">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-check-circle"></use>
</svg>
{% else %}
<svg class="icon icon-sm icon-danger">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-close-circle"></use>
</svg>
{% endif %}
</td>
<td class="text-right">
<a href="{% url 'crud_cds:cds_group_member_edit' regdid_id=regdid.pk group_id=group.pk member_id=member.pk %}" class="btn btn-primary btn-xs">
<svg class="icon icon-xs icon-white">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-pencil"></use>
</svg> {% trans "Edit" %}
</a>

<a href="" class="btn btn-danger btn-xs"
data-toggle="modal"
data-target="#delete_cds_group_member_{{ member.pk }}">
<svg class="icon icon-xs icon-white">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-delete"></use>
</svg> {% trans "Remove" %}
</a>
<div class="modal fade"
tabindex="-1"
role="dialog"
id="delete_cds_group_member_{{ member.pk }}">
<div class="modal-dialog modal-dialog-centered"
role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">
{% trans "Confirm" %}
</h5>
<button class="close"
type="button"
data-dismiss="modal"
aria-label="Close">
<svg class="icon">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-close"></use>
</svg>
</button>
</div>
<div class="modal-body">
<p>
{% trans "Do you want to delete member?" %}
</p>
</div>
<div class="modal-footer">
<a class="btn btn-success btn-sm" href="{% url 'crud_cds:cds_group_member_delete' regdid_id=regdid.pk group_id=group.pk member_id=member.pk %}">
{% trans 'Yes, proceed' %}
</a>
</div>
</div>
</div>
</div>






</td>
</tr>
{% endfor %}
</tbody>
</table>
<a href="{% url 'crud_cds:cds_group_members_new' regdid_id=regdid.pk group_id=group.pk %}" class="text-center btn btn-block btn-success btn-xs">
<svg class="icon icon-xs icon-white">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-plus-circle"></use>
</svg> {% trans "Add new" %}
</a>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock centered_container %}
19 changes: 19 additions & 0 deletions crud/cds/templates/cds_group_member.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "storage_crud_base.html" %}

{% load i18n %}
{% load static %}


{% block centered_container %}
<h3 style="font-weight: lighter;" class="mb-4">
{% if choosen_person %}{% trans "Edit member for" %}{% else %}{% trans "New member for" %}{% endif %} {{ group.descr_breve_it }}
</h3>
<div class="card-wrapper card-space">
<div class="card card-bg no-after">
<div class="card-body">

{% include "blocks/includes/teacher_tabs.html" %}
</div>
</div>
</div>
{% endblock centered_container %}
14 changes: 14 additions & 0 deletions crud/cds/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@
cds_doc_study_manifesto_delete, name='cds_doc_study_manifesto_delete'),
urlpatterns += path('cds/<str:regdid_id>/didactic-regulation/delete/',
cds_doc_didactic_regulation_delete, name='cds_doc_didactic_regulation_delete'),

# url groups
urlpatterns += path('cds/<str:regdid_id>/groups/new/',
cds_group_new, name='crud_cds_group_new'),
urlpatterns += path('cds/<str:regdid_id>/groups/<str:group_id>/',
cds_group, name='crud_cds_group'),
urlpatterns += path('cds/<str:regdid_id>/groups/<str:group_id>/delete/',
cds_group_delete, name='crud_cds_group_delete'),
urlpatterns += path('cds/<str:regdid_id>/groups/<str:group_id>/members/new/',
cds_group_members_new, name='cds_group_members_new'),
urlpatterns += path('cds/<str:regdid_id>/groups/<str:group_id>/members/<str:member_id>/edit/',
cds_group_member_edit, name='cds_group_member_edit'),
urlpatterns += path('cds/<str:regdid_id>/groups/<str:group_id>/members/<str:member_id>/delete/',
cds_group_member_delete, name='cds_group_member_delete'),
Loading

0 comments on commit 5f13521

Please sign in to comment.