diff --git a/common/templates/base.html b/common/templates/base.html index 216fea5020993f34c2b10fd05bf015b44ad4a2ef..67269a9dac5fcb33d3ab60256a6d59f41b71b259 100644 --- a/common/templates/base.html +++ b/common/templates/base.html @@ -76,6 +76,13 @@ </a> </li> {% endif %} + {% if perms.users.view_statement %} + <li class="nav-item" id="nav-fin-statements"> + <a class="nav-link text-light" href="{% url 'financial_settlement:statement_list' %}"> + {% trans "Umowy" %} + </a> + </li> + {% endif %} </ul> {% endif %} </div> diff --git a/docker-compose.yml b/docker-compose.yml index 8120daf026084c3a254af05d4e25af49ef7e907f..a24472339c6439bbf579bb23fac49b09830fa375 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,7 @@ services: postgresql: container_name: shellvalier-postgresql image: postgres:14.2 + shm_size: 1gb environment: POSTGRES_USER: "shellvalier" POSTGRES_DB: "shellvalier" @@ -33,7 +34,7 @@ services: volumes: - .:/app ports: - - "8000:8000" + - "80:8000" frontend: container_name: shellvalier-frontend diff --git a/entries/templates/entries_base.html b/entries/templates/entries_base.html index 3bcc6b76ba32b30906818afc92a4164c430082f2..0d1501ea98f2367e7c6a45fe23b7feadb5b8352e 100644 --- a/entries/templates/entries_base.html +++ b/entries/templates/entries_base.html @@ -17,7 +17,7 @@ {% block scripts %} <!-- https://www.cssscript.com/split-view/ --> - <script src="https://unpkg.com/split.js/dist/split.min.js"></script> + <script src="{% static 'common/js/split.min.js' %}"></script> <!-- https://datatables.net/ --> <script type="text/javascript" src="https://cdn.datatables.net/v/bs4/dt-1.12.1/sc-2.0.3/datatables.min.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/plug-ins/1.12.1/features/scrollResize/dataTables.scrollResize.min.js"></script> diff --git a/financial_settlement/__init__.py b/financial_settlement/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/financial_settlement/apps.py b/financial_settlement/apps.py new file mode 100644 index 0000000000000000000000000000000000000000..c0221a0ae8702a3c7fd88d92ad3b80cef7acc4d7 --- /dev/null +++ b/financial_settlement/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class FinStatementConfig(AppConfig): + name = 'financial_settlement' diff --git a/financial_settlement/forms.py b/financial_settlement/forms.py new file mode 100644 index 0000000000000000000000000000000000000000..5d3cc2e5d822f3c66e13d44f5767af14864c8040 --- /dev/null +++ b/financial_settlement/forms.py @@ -0,0 +1,131 @@ +from django import forms +from django.contrib.auth.models import Group, User +from django.urls import reverse_lazy +from django.utils.text import format_lazy +from django.utils.translation import gettext_lazy as _ + +from crispy_forms.helper import FormHelper +from crispy_forms.layout import HTML, Layout, Fieldset, ButtonHolder, Submit + +from financial_settlement.models import FinStatement +from users.models import Note + + +class FinStatementForm(forms.ModelForm): + + start_date = forms.DateTimeField(input_formats=['%d-%m-%Y'], + widget = forms.DateTimeInput( + format ='%d-%m-%Y', + attrs= {'class':'form-control'})) + end_date = forms.DateTimeField(input_formats=['%d-%m-%Y'], + widget = forms.DateTimeInput( + format ='%d-%m-%Y', + attrs= {'class':'form-control'})) + + user = forms.ModelChoiceField(queryset=User.objects.all(), label=_('Użytkownik')) + + is_active = forms.CheckboxInput() + + class Meta: + model = FinStatement + fields = [ + 'statement_id', + 'title', + 'start_date', + 'end_date', + 'payment', + 'last_statement_payment', + 'price_per_unified_frame', + 'user', + 'is_active' + ] + + def __init__(self, *args, instance, **kwargs): + super().__init__(*args, instance=instance, **kwargs) + self.helper = FormHelper() + self.helper.layout = Layout( + Fieldset('', 'statement_id', 'title', 'start_date', 'end_date', 'payment', 'price_per_unified_frame', 'last_statement_payment', 'user', 'is_active'), + ButtonHolder( + Submit('submit', _('Zapisz'), css_class='btn btn-sm btn-success'), + HTML(format_lazy('<a class="btn btn-sm btn-light" href="{}">{}</a>', reverse_lazy('financial_settlement:statement_list'), _('Wróć'))), + ), + ) + for field in ['statement_id', 'title', 'start_date', 'end_date', 'payment', 'price_per_unified_frame', 'user']: + self.fields[field].required = True + + if instance.pk: + self.initial['user'] = instance.user + self.initial['is_active'] = instance.is_active + else: + self.initial['is_active'] = False + + def save(self, commit=True): + instance = super().save(commit=commit) + return instance + + +# class UserProfileForm(forms.ModelForm): +# class Meta: +# model = User +# fields = [ +# 'first_name', +# 'last_name', +# 'email', +# ] +# +# def __init__(self, *args, instance, **kwargs): +# super().__init__(*args, instance=instance, **kwargs) +# self.helper = FormHelper() +# self.helper.layout = Layout( +# Fieldset('', 'first_name', 'last_name', 'email'), +# ButtonHolder( +# Submit('submit', _('Zapisz'), css_class='btn btn-sm btn-success'), +# HTML(format_lazy('<a class="btn btn-sm btn-light" href="{}">{}</a>', reverse_lazy('users:password_change'), _('Zmień swoje hasło'))), +# HTML(format_lazy('<a class="btn btn-sm btn-light" href="{}">{}</a>', reverse_lazy('dash'), _('Wróć'))), +# ), +# ) +# for field in ['first_name', 'last_name', 'email']: +# self.fields[field].required = True +# +# +# login_form_helper = FormHelper() +# login_form_helper.layout = Layout( +# Fieldset('', 'username', 'password'), +# ButtonHolder( +# Submit('submit', _('Zaloguj się'), css_class='btn btn-sm btn-success'), +# HTML(format_lazy('<a class="btn btn-sm btn-light" href="{}">{}</a>', reverse_lazy('users:password_reset'), _('Nie pamiętam hasła'))), +# ), +# ) +# +# password_reset_form_helper = FormHelper() +# password_reset_form_helper.layout = Layout( +# Fieldset('', 'email'), +# ButtonHolder( +# Submit('submit', _('Zresetuj hasło'), css_class='btn btn-sm btn-success'), +# HTML(format_lazy('<a class="btn btn-sm btn-light" href="{}">{}</a>', reverse_lazy('users:login'), _('Wróć'))), +# ) +# ) +# +# password_change_form_helper = FormHelper() +# password_change_form_helper.layout = Layout( +# Fieldset('', 'old_password', 'new_password1', 'new_password2'), +# ButtonHolder( +# Submit('submit', _('Zmień hasło'), css_class='btn btn-sm btn-success'), +# HTML(format_lazy('<a class="btn btn-sm btn-light" href="{}">{}</a>', reverse_lazy('users:user_profile'), _("Wróć"))), +# ) +# ) +# +# password_reset_set_password_form_helper = FormHelper() +# password_reset_set_password_form_helper.layout = Layout( +# Fieldset('', 'new_password1', 'new_password2'), +# ButtonHolder( +# Submit('submit', _('Ustaw hasło'), css_class='btn btn-sm btn-success'), +# HTML(format_lazy('<a class="btn btn-sm btn-light" href="{}">{}</a>', reverse_lazy('dash'), _("Wróć"))), +# ) +# ) +# +# +# class NoteForm(forms.ModelForm): +# class Meta: +# model = Note +# fields = ["title", "note"] diff --git a/financial_settlement/migrations/__init__.py b/financial_settlement/migrations/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/financial_settlement/models.py b/financial_settlement/models.py new file mode 100644 index 0000000000000000000000000000000000000000..d6bbd83fe938b37ebe6a074ac6a08e64fca04b1e --- /dev/null +++ b/financial_settlement/models.py @@ -0,0 +1,17 @@ +from django.contrib.auth.models import User +from django.db import models + +class FinStatement(models.Model): + + statement_id = models.PositiveIntegerField(null=False) + title = models.CharField(max_length=200, default=None, blank=True, null=True) + start_date = models.DateField(null=False) + end_date = models.DateField(null=False) + payment = models.DecimalField(null=False, default=0, max_digits = 10,decimal_places=3) + price_per_unified_frame = models.DecimalField(null=False, default=0, max_digits = 10,decimal_places=3) + last_statement_payment = models.DecimalField(null=False, default=0, max_digits = 10,decimal_places=3) + user = models.ForeignKey(User, on_delete=models.PROTECT, default=None, blank=True, null=True) + is_active = models.BooleanField(default=False) + + def __str__(self): + return '%s: %s' % (self.statement_id, self.title) diff --git a/financial_settlement/templates/fin_statement_details.html b/financial_settlement/templates/fin_statement_details.html new file mode 100644 index 0000000000000000000000000000000000000000..f46bdbf6542896a860bd26472e093ecad2176fb5 --- /dev/null +++ b/financial_settlement/templates/fin_statement_details.html @@ -0,0 +1,45 @@ +{% extends 'base-margins.html' %} + +{% load i18n %} + +{% block title %}{% trans 'Szczegóły umowy' %}{% endblock %} + +{% block content2 %} +<div class="mt-3"> + <h5 class="float-left mt-2">{% trans 'Szczegóły umowy' %}</h5> +</div> +<table class="table" style="display: inline-flex;"> + <tbody> + <tr> + <td>{% trans 'Nr umowy' %}</td><td>{{ statement.statement_id }}</td> + </tr> + <tr> + <td>{% trans 'Tytuł umowy' %}</td><td>{{ statement.title }}</td> + </tr> + <tr> + <td>{% trans 'Użytkownik' %}</td><td>{{ statement.user.username }}</td> + </tr> + <tr> + <td>{% trans 'Od' %}</td><td>{{ statement.start_date }}</td> + </tr> + <tr> + <td>{% trans 'Do' %}</td><td>{{ statement.end_date }}</td> + </tr> + <tr> + <td>{% trans 'Kwota' %}</td><td>{{ statement.payment }}</td> + </tr> + <tr> + <td>{% trans 'Koszt anotacji' %}</td><td>{{ statement.price_per_unified_frame }}</td> + </tr> + <tr> + <td>{% trans 'Liczba wykonanych anotacji' %}</td><td>{{ unified_frame_count }}</td> + </tr> + <tr> + <td>{% trans 'Kwota wykorzystana' %}</td><td>{{ current_cost }}</td> + </tr> + <tr> + <td>{% trans 'Kwota z poprzedniej umowy' %}</td><td>{{ statement.last_statement_payment }}</td> + </tr> + </tbody> +</table> +{% endblock %} diff --git a/financial_settlement/templates/fin_statement_form.html b/financial_settlement/templates/fin_statement_form.html new file mode 100644 index 0000000000000000000000000000000000000000..25d2a4624a39c08205b8fd7302782a91ac4429cb --- /dev/null +++ b/financial_settlement/templates/fin_statement_form.html @@ -0,0 +1,13 @@ +{% extends 'base-margins.html' %} + +{% load i18n %} + +{% load crispy_forms_filters %} + +{% block title %}{{ title }}{% endblock %} + +{% block content2 %} + <h5 class="mt-4 mb-4">{{ title }}</h5> + + {% crispy form %} +{% endblock %} diff --git a/financial_settlement/templates/fin_statements_list.html b/financial_settlement/templates/fin_statements_list.html new file mode 100644 index 0000000000000000000000000000000000000000..0d46af3ca1524e4bc8b48793a9e68d6732d31cf0 --- /dev/null +++ b/financial_settlement/templates/fin_statements_list.html @@ -0,0 +1,46 @@ +{% extends 'base-margins.html' %} + +{% load i18n %} + +{% block title %}{% trans 'Umowy' %}{% endblock %} + +{% block content2 %} +<div class="mt-3"> + <h5 class="float-left mt-2">{% trans 'Umowy' %}</h5> + <div class="mb-4 float-right"> + {% if perms.users.add_user %} + <a href="{% url 'financial_settlement:statement_add' %}" class="btn btn-sm btn-outline-dark">+ {% trans 'Dodaj umowę' %}</a> + {% endif %} + </div> +</div> +<table class="table"> + <thead> + <tr> + <th>{% trans 'Nr umowy' %}</th> + <th>{% trans 'Tytuł umowy' %}</th> + <th>{% trans 'Uzytkownik' %}</th> +<!-- <th>{% trans 'Kwota' %}</th>--> +<!-- <th>{% trans 'Koszt anotacji' %}</th>--> +<!-- <th>{% trans 'Liczba wykonanych anotacji' %}</th>--> +<!-- <th>{% trans 'Kwota wykorzystana' %}</th>--> + </tr> + </thead> + <tbody> + {% for statement in statements %} + <tr> + <td>{{ statement.statement_id }}</td> + <td>{{ statement.title }}</td> + <td>{{ statement.user.username }}</td> +<!-- <td>{{ statement.payment }}</td>--> +<!-- <td>{{ statement.price_per_unified_frame }}</td>--> +<!-- <td>{{ statement.unified_frame_count }}</td>--> +<!-- <td>{{ statement.current_cost }}</td>--> + <td> + <a href="{% url 'financial_settlement:statement_detail' pk=statement.pk %}" class="btn btn-xs btn-outline-dark">{% trans 'Szczegóły' %}</a> + <a href="{% url 'financial_settlement:statement_edit' pk=statement.pk %}" class="btn btn-xs btn-outline-dark">{% trans 'Edytuj' %}</a> + </td> + </tr> + {% endfor %} + </tbody> +</table> +{% endblock %} diff --git a/financial_settlement/urls.py b/financial_settlement/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..94cf71b443f3e145d0630d95b980bc803a1c0590 --- /dev/null +++ b/financial_settlement/urls.py @@ -0,0 +1,12 @@ +from django.urls import path + +from . import views + +app_name = 'financial_settlement' + +urlpatterns = [ + path('', views.statement_list, name='statement_list'), + path('add/', views.statement_add, name='statement_add'), + path('<int:pk>/edit/', views.statement_edit, name='statement_edit'), + path('<int:pk>/detail/', views.statement_detail, name='statement_detail'), +] diff --git a/financial_settlement/views.py b/financial_settlement/views.py new file mode 100644 index 0000000000000000000000000000000000000000..8da1ea20e78acfa83c1dae115265dde4b259ca70 --- /dev/null +++ b/financial_settlement/views.py @@ -0,0 +1,56 @@ +from django.apps import apps +from django.contrib.auth.decorators import login_required, permission_required +from django.contrib.auth.models import User +from django.contrib.contenttypes.models import ContentType +from django.contrib.sites.shortcuts import get_current_site +from django.http import JsonResponse +from django.shortcuts import get_object_or_404, render, redirect +from django.utils.translation import gettext_lazy as _ +from django.views.decorators.http import require_http_methods + +from financial_settlement.forms import FinStatementForm +from financial_settlement.models import FinStatement +from unifier.choices import UnifiedFrameStatus +from unifier.models import UnifiedFrame +from users.forms import UserForm, UserProfileForm, NoteForm + +@permission_required('finstatement.list_statement') +def statement_list(request): + statements = FinStatement.objects.order_by('statement_id') + for statement in statements: + statement.unified_frame_count = statement.unified_frame.count() + statement.current_cost = statement.unified_frame.count() * statement.price_per_unified_frame + return render(request, 'fin_statements_list.html', {'statements': statements}) + +@permission_required('finstatement.add_statement') +def statement_add(request): + if request.method == 'POST': + form = FinStatementForm(instance=FinStatement(), data=request.POST) + if form.is_valid(): + statement = form.save() + return redirect('financial_settlement:statement_list') + else: + form = FinStatementForm(instance=FinStatement()) + return render(request, 'fin_statement_form.html', {'form': form, 'title': _('Dodaj umowę')}) + +@permission_required('finstatement.change_statement') +def statement_edit(request, pk): + statement = get_object_or_404(FinStatement, pk=pk) + if request.method == 'POST': + form = FinStatementForm(instance=statement, data=request.POST) + if form.is_valid(): + form.save() + return redirect('financial_settlement:statement_list') + else: + form = FinStatementForm(instance=statement) + return render(request, 'fin_statement_form.html', {'form': form, 'title': _('Edytuj umowę')}) + +@permission_required('finstatement.detail_statement') +def statement_detail(request, pk): + statement = get_object_or_404(FinStatement, pk=pk) + unified_frames = statement.unified_frame; + + return render(request, 'fin_statement_details.html', + {'statement': statement, + 'unified_frame_count': unified_frames.count(), + 'current_cost': unified_frames.count() * statement.price_per_unified_frame}) diff --git a/frontend/src/components/unification/Unification/LexicalUnitEdit.vue b/frontend/src/components/unification/Unification/LexicalUnitEdit.vue index 9cee053faf99a0f6551ff337f47655fe57904dad..32f59691f6f09b6885016ff7d9b39460e3085237 100644 --- a/frontend/src/components/unification/Unification/LexicalUnitEdit.vue +++ b/frontend/src/components/unification/Unification/LexicalUnitEdit.vue @@ -522,7 +522,13 @@ Object.assign(LexicalUnitEdit, { } $.prompt(duplicate_popup); }, - changeUnifiedFrameStatusToReady() { + changeUnifiedFrameStatusToReadyOrVerified() { + if (this.isSuperLeksykograf()) + this.changeUnifiedFrameStatusToReadyOrVerifiedByPath('change_unified_frame_status_to_verified_by_superleksykograf'); + else + this.changeUnifiedFrameStatusToReadyOrVerifiedByPath('change_unified_frame_status_to_ready') + }, + changeUnifiedFrameStatusToReadyOrVerifiedByPath(url_path) { let foundNotVerifiedFrame = this.frames.find(frame => frame.status !== 'G' && frame.status !== 'S'); if (foundNotVerifiedFrame) { alert(gettext("Wszystkie podpięte ramy powinny być zweryfikowane.")); @@ -544,13 +550,13 @@ Object.assign(LexicalUnitEdit, { const data = {'unified_frame_id': this.unified_frame.id}; $.ajax({ type: 'post', - url: '/' + lang + '/unifier/change_unified_frame_status_to_ready/', + url: '/' + lang + '/unifier/' + url_path + '/', dataType: 'json', data: data, timeout: 60000, success: function (response) { show_info('Status ramy został zmieniony'); - this.$emit('goToDisplay') + this.loadFrame(); }.bind(this), error: function (request, errorType, errorMessage) { show_error(errorType + ' (' + errorMessage + ')'); @@ -927,28 +933,28 @@ export default LexicalUnitEdit; <td id="change-title" @click="changeTitle" style="padding: 10px 15px 10px 15px; color: #000000;">Zmień nazwę</td> <td id="add-arg" @click="addArgument" style="padding: 10px 15px 10px 15px; color: #000000;">Dodaj argum.</td> <td style="padding: 10px 15px 10px 15px; color: #000000;" @click="addSelectivePreference">Dodaj prefer.</td> - <td style="padding: 10px 15px 10px 15px; color: #000000;" @click="changeUnifiedFrameStatusToReady">{{isSuperLeksykograf() ? 'Sprawdzone' : 'Gotowe'}}</td> + <td style="padding: 10px 15px 10px 15px; color: #000000;" @click="changeUnifiedFrameStatusToReadyOrVerified">{{isSuperLeksykograf() ? 'Sprawdzone' : 'Gotowe'}}</td> <td id="duplicates" @click="duplicate" style="padding: 10px 15px 10px 15px; color: #000000;">Duplikuj</td> </tr> <tr style="background-color: white;"> <td id="change-role" @click="changeRole" style="padding: 10px 15px 10px 15px; color: #000000;">Zmień rolę</td> <td id="remove-arg" @click="removeArgument" style="padding: 10px 15px 10px 15px; color: #000000;">Usuń argum.</td> - <td id="change-windows" style="padding: 10px 15px 10px 15px; color: #000000;" @click="removeSelectionalPreference">Usuń prefer.</td> + <td id="remove-sel-pref" style="padding: 10px 15px 10px 15px; color: #000000;" @click="removeSelectionalPreference">Usuń prefer.</td> <td id="change-windows" style="padding: 10px 15px 10px 15px; color: #000000;" @click="swapUnifiedFrames">Zamień okna</td> - <td v-if="frames.length == 0 || isSuperLeksykograf()" id="change-windows" style="padding: 10px 15px 10px 15px; color: #000000;" @click="deleteUnifiedFrames">Usuń ramę</td> + <td v-if="frames.length == 0 || isSuperLeksykograf()" id="delete-frame" style="padding: 10px 15px 10px 15px; color: #000000;" @click="deleteUnifiedFrames">Usuń ramę</td> </tr> </table> <table v-if="!readOnly && isReadOnlyForSuperLeksykograf()" class="table-button-menu sticky-top" style="width: 100px;" cellspacing="1"> <tr style="background-color: white;"> - <td v-if="frames.length == 0 || isSuperLeksykograf()" id="change-windows" style="padding: 10px 15px 10px 15px; color: #000000;" @click="deleteUnifiedFrames">Usuń ramę</td> + <td v-if="frames.length == 0 || isSuperLeksykograf()" id="delete-frame-ro" style="padding: 10px 15px 10px 15px; color: #000000;" @click="deleteUnifiedFrames">Usuń ramę</td> </tr> </table> <spinner /> <div align="center"> <div align="left" style="display: table;"> - <div class="unifiedFrame mt-3" v-bind:data-frame_id="unified_frame.id" id="lexical-unit" v-html="unified_frame_title"></div> + <div class="unifiedFrame mt-3" v-bind:data-frame_id="unified_frame.id" id="unified-frame-title" v-html="unified_frame_title"></div> <table v-if="unified_frame.id" id="unified-frame" class="m-0 table-borderless border border-secondary text-dark frame active"> <tbody> <tr> @@ -998,7 +1004,7 @@ export default LexicalUnitEdit; <div v-else class="preference py-2 px-1 preference-bold">{{ preference.str }}</div> </li> </ul> - <ul class="ul-preference"> + <ul class="ul-preference" v-if="unified_frame.status !== 'S'"> <li v-for="preference in slowal_frames2selecional_preferencies_mapping[argument.id]"> <span v-if="preference.url != null" class="preference py-2 px-1"> <a class="synset-plwn" v-bind:href="preference.url" target="_blank">{{ preference.str }}</a> diff --git a/shellvalier/settings.py b/shellvalier/settings.py index d127d89dfa6896ac2d62b32fe2c28bd8803df611..2f4ba078f2f1e64253a5c2513c8b59d02125284f 100644 --- a/shellvalier/settings.py +++ b/shellvalier/settings.py @@ -66,6 +66,7 @@ INSTALLED_APPS = [ 'django_extensions', 'django_vite', 'unifier.apps.UnifierConfig', + 'financial_settlement.apps.FinStatementConfig', ] CRISPY_TEMPLATE_PACK = 'bootstrap4' @@ -185,3 +186,5 @@ EMAIL_USE_TLS = get_environment('EMAIL_USE_TLS', mapper=boolean_mapper) EMAIL_USE_SSL = get_environment('EMAIL_USE_SSL', mapper=boolean_mapper) SUPER_LEXICOGRAPHS_GROUP_NAME = 'Super Leksykografowie' + +DATE_INPUT_FORMATS = ['%d-%m-%Y'] diff --git a/shellvalier/urls.py b/shellvalier/urls.py index 9f5e11f22bdd76b9a2f319160ef0d955a0bc62b4..7c5415600a71e0dff16bcea039653622e0c88b4b 100644 --- a/shellvalier/urls.py +++ b/shellvalier/urls.py @@ -18,6 +18,7 @@ urlpatterns = i18n_patterns( path('admin/', admin.site.urls, name='admin'), path('semantics/', include('semantics.urls')), path('unifier/', include('unifier.urls')), + path('financial_settlement/', include('financial_settlement.urls')), path('', dash, name='dash'), # uncomment to leave default (Polish) urls unchanged #prefix_default_language=False, diff --git a/unifier/models.py b/unifier/models.py index 67000411312dad1fc018bcc9ecd3c8372a6370e3..53c7013bef1d90444374060dadb82e5affb3a5b0 100644 --- a/unifier/models.py +++ b/unifier/models.py @@ -5,6 +5,7 @@ from typing import List, Optional from django.db import models, transaction +from financial_settlement.models import FinStatement from meanings.models import LexicalUnit, Synset from semantics.models import PredefinedSelectionalPreference, RelationalSelectionalPreference, ArgumentRole, \ RoleType, Argument, Frame, SelectionalPreferenceRelation @@ -33,6 +34,8 @@ class UnifiedFrame(models.Model): objects = models.Manager.from_queryset(UnifiedFrameQueryset)() + fin_statement = models.ForeignKey(FinStatement, on_delete=models.PROTECT, blank=True, default=None, null=True, related_name='unified_frame') + def sorted_arguments(self): # TODO: zaimplementowac wlasciwe sortowanie return UnifiedFrameArgument.objects.filter(unified_frame=self) diff --git a/unifier/urls.py b/unifier/urls.py index 899f02c912882ba96f0dd14226175829183474ac..bf8476ecd3c83034373a9088331f86bc5b05d132 100644 --- a/unifier/urls.py +++ b/unifier/urls.py @@ -24,5 +24,7 @@ urlpatterns = [ path('build_unified_frame_xml/', views.build_unified_frame_xml, name='build_unified_frame_xml'), path('frame_assign/', views.frame_assign, name='frame_assign'), path('delete_unified_frame/<int:unified_frame_id>/', views.delete_unified_frame, name='delete_unified_frame'), + path('change_unified_frame_status_to_verified_by_superleksykograf/', views.change_unified_frame_status_to_verified_by_superleksykograf, name='change_unified_frame_status_to_verified_by_superleksykograf'), + ] diff --git a/unifier/views.py b/unifier/views.py index 1c842b1cc47fc1973b11df53be4366376708870d..fe251b14feac78b203eb7146434edf710b42ec85 100644 --- a/unifier/views.py +++ b/unifier/views.py @@ -11,6 +11,7 @@ from common.decorators import ajax_required, ajax from entries.polish_strings import EXAMPLE_SOURCE, EXAMPLE_OPINION from entries.views import get_scroller_params, get_alternations, get_prefs_list, schema2dict, frame2dict, collect_forms, \ get_filtered_objects, get_local_schema_filter_form, get_local_frame_filter_form +from financial_settlement.models import FinStatement from importer.unification.UnificationPreprocessXML import UnificationPreprocessHandler from meanings.models import LexicalUnit from semantics.choices import FrameStatus @@ -85,7 +86,7 @@ def get_unified_frames(request): errors_dict = dict() - if request.session['unified_frame_form']: + if 'unified_frame_form' in request.session: forms = collect_forms(request.session['unified_frame_form'], errors_dict) unifiedFrames = get_filtered_objects(forms).filter() else: @@ -451,6 +452,23 @@ def change_unified_frame_status_to_ready(request): unifiedFrame.save() return JsonResponse({}) +@ajax_required +@transaction.atomic +def change_unified_frame_status_to_verified_by_superleksykograf(request): + if request.method == 'POST': + unified_frame_id = request.POST['unified_frame_id'] + unifiedFrame = UnifiedFrame.objects.get(pk=unified_frame_id) + unifiedFrame.status = choices.UnifiedFrameStatus.VERIFIED + + #save fin statement info for current active fin statement + fin_statements = FinStatement.objects.filter(is_active=True) + if fin_statements.count() == 1: + active_fin_statement = fin_statements[0] + unifiedFrame.fin_statement = active_fin_statement; + + unifiedFrame.save() + return JsonResponse({}) + def create_unified_frame(lu_id): response = requests.post('http://127.0.0.1:8000/en/unifier/build_unified_frame_xml/?lu_id='+str(lu_id)) diff --git a/users/management/commands/create_groups_and_permissions.py b/users/management/commands/create_groups_and_permissions.py index 437bac3a98cc66c0d3a17ed1a5bd3c47cc788b05..dcf96dac872c18d98e003bf30d851849573a50bf 100644 --- a/users/management/commands/create_groups_and_permissions.py +++ b/users/management/commands/create_groups_and_permissions.py @@ -3,6 +3,7 @@ from django.contrib.auth.models import Group, Permission, User from django.contrib.contenttypes.models import ContentType from django.core.management.base import BaseCommand +from financial_settlement.models import FinStatement from semantics.models import Frame from users.models import Assignment, Note @@ -28,6 +29,8 @@ class Command(BaseCommand): self._get_permission(Assignment, 'view_assignment'), self._get_permission(Note, 'view_all_notes'), self._get_permission(Frame, 'manage_invalid_lexical_units'), + self._get_permission(FinStatement, 'view_statement'), + self._get_permission(FinStatement, 'add_statement'), ) lexicographs, __ = Group.objects.get_or_create(name='Leksykografowie') lexicographs.permissions.add(