Skip to content
Snippets Groups Projects
Commit 4627f766 authored by dcz's avatar dcz
Browse files

Leksykograf can send note to the user.

parent 682eec59
No related merge requests found
......@@ -8,34 +8,42 @@ from semantics.models import Frame, FrameOpinion
from entries.polish_strings import POS as POS_names, STATUS, SCHEMA_OPINION, FRAME_OPINION
@login_required
def dictionary_statistics(request):
ALL = _('wszystkie')
# ENTRIES
entries = Entry.objects.filter(import_error=False)
pos_names = POS_names()
status_names = STATUS()
entry_statuses = list(Status.objects.all())
all_pos = ['verb', 'noun', 'adj', 'adv']
entry_stats = { ALL : [entries.count()] + [entries.filter(pos__tag=pos).count() for pos in all_pos] }
entry_stats = {ALL: [entries.count()] + [entries.filter(pos__tag=pos).count() for pos in all_pos]}
used_statuses = set()
for status in entry_statuses:
c = entries.filter(status=status).count()
if c:
used_statuses.add(status)
entry_stats[status_names[status.key]] = [entries.filter(status=status).count()] + [entries.filter(status=status, pos__tag=pos).count() for pos in all_pos]
entry_stats[status_names[status.key]] = [entries.filter(status=status).count()] + [
entries.filter(status=status, pos__tag=pos).count() for pos in all_pos]
all_statuses = [ALL] + [status_names[status.key] for status in entry_statuses if status in used_statuses]
all_pos = [ALL] + [pos_names[pos] for pos in all_pos]
# SCHEMATA
schemata = Schema.objects.filter(subentries__entry__import_error=False)
schema_opinions = SCHEMA_OPINION()
schema_stats = [(ALL, 'all', schemata.count())] + [(schema_opinions[opinion.key], opinion.key, schemata.filter(opinion=opinion).count()) for opinion in SchemaOpinion.objects.all()]
schema_stats = [(ALL, 'all', schemata.count())] + [
(schema_opinions[opinion.key], opinion.key, schemata.filter(opinion=opinion).count()) for opinion in
SchemaOpinion.objects.all()]
# FRAMES
frames = Frame.objects.all() #filter(arguments__argument_connections__schema_connections__subentry__entry__import_error=False)
frames = Frame.objects.all() # filter(arguments__argument_connections__schema_connections__subentry__entry__import_error=False)
frame_opinions = FRAME_OPINION()
frame_stats = [(ALL, 'all', frames.count())] + [(frame_opinions[opinion.key], opinion.key, frames.filter(opinion=opinion).count()) for opinion in FrameOpinion.objects.all()]
return render(request, 'dictionary_statistics.html', { 'all_statuses' : all_statuses, 'all_pos' : all_pos, 'entry_stats' : entry_stats, 'schema_stats' : schema_stats, 'frame_stats' : frame_stats })
frame_stats = [(ALL, 'all', frames.count())] + [
(frame_opinions[opinion.key], opinion.key, frames.filter(opinion=opinion).count()) for opinion in
FrameOpinion.objects.all()]
return render(request, 'dictionary_statistics.html',
{'all_statuses': all_statuses, 'all_pos': all_pos, 'entry_stats': entry_stats,
'schema_stats': schema_stats, 'frame_stats': frame_stats})
......@@ -25,7 +25,7 @@ from semantics.models import Frame, PredefinedSelectionalPreference, SelectivePr
from common.decorators import ajax_required, ajax
from unifier.models import UnifiedFrame
from users.models import Assignment
from django.conf import settings
from .forms import (
EntryForm,
......@@ -73,6 +73,7 @@ def entries(request):
@login_required
def unification(request):
user = request.user
return render(
request,
'unification.html',
......@@ -83,6 +84,7 @@ def unification(request):
'frames_form': FrameFormFactory.get_form(as_subform=False),
'schemata_form': SchemaFormFactory.get_form(as_subform=False),
'unified_frames_form': UnifiedFrameFormFactory.get_form(as_subform=False),
'is_superlexicograf': user.groups.filter(name=settings.SUPER_LEXICOGRAPHS_GROUP_NAME).exists()
},
)
......
......@@ -9,7 +9,12 @@
</div>
<div class="d-flex">
<div class="flex-grow-1 mr-3">
Superleksykograf <input id="super" name="super" type="checkbox" title="{% trans 'Notatka widoczna dla superleksykografa' %}" />
{% if is_superlexicograf %}
Użytkownik
{% else %}
Superleksykograf
{% endif %}
<input id="super" name="super" type="checkbox" title="{% if is_superlexicograf %} {% trans 'Notatka widoczna dla użytkownika' %} {% else %} {% trans 'Notatka widoczna dla superleksykografa' %} {% endif %}" />
<input id="title" name="title" class="form-control mb-2" placeholder="{% trans 'Tytuł notatki' %}" />
<textarea id="note" name="note" class="form-control" placeholder="{% trans 'Treść notatki' %}"></textarea>
</div>
......
......@@ -12,6 +12,7 @@ from common.decorators import ajax
from users.forms import UserForm, UserProfileForm, NoteForm
from users.models import Note
from users.utils import send_new_user_email
from django.conf import settings
@permission_required('users.view_user')
......@@ -83,7 +84,11 @@ def get_notes(request, model, pk, type):
def add_note(request, model, pk, type=None):
model = apps.get_model(*model.split('.'))
subject = get_object_or_404(model, pk=pk)
note = Note(author=request.user, subject=subject)
user = request.user
if request.POST.get('super', 'off') == 'on' \
and user.groups.filter(name=settings.SUPER_LEXICOGRAPHS_GROUP_NAME).exists():
user = subject.assignments.first().user
note = Note(author=user, subject=subject)
if type:
note.type = type
form = NoteForm(instance=note, data=request.POST)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment