Commit 9ea133935d7a162bf38f8d915b1d99e40b530c80

Authored by Katarzyna Krasnowska
1 parent 998a9b2c

stub stats page; css/html/translation fixes

common/static/common/js/init.js
... ... @@ -4,7 +4,7 @@ var lang;
4 4  
5 5 $(document).ready(function() {
6 6  
7   - $('.nav-item > a[href$="' + window.location.pathname + '"]').addClass('active');
  7 + $('.nav-item > a[href$="' + window.location.pathname + '"]').removeClass('text-light active').addClass('disabled');
8 8  
9 9 lang = $('html').attr('lang');
10 10  
... ...
common/templates/base.html
... ... @@ -35,7 +35,8 @@
35 35  
36 36 <div class="container-fluid h-100 d-flex flex-column p-0">
37 37  
38   - <nav class="navbar navbar-expand-lg sticky-top navbar-dark bg-dark font-weight-bold p-2">
  38 + <!--z-index 2 above sticky-top-->
  39 + <nav class="navbar navbar-expand-lg sticky-top navbar-dark bg-dark font-weight-bold p-2" style="z-index: 1022;">
39 40 <a class="navbar-brand" href="{% url 'dash' %}">Walenty [beta]</a>
40 41  
41 42 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
... ... @@ -44,16 +45,21 @@
44 45 <div class="collapse navbar-collapse" id="navbarNav">
45 46 <ul class="navbar-nav mr-auto">
46 47 <li class="nav-item" id="nav-entries">
47   - <a class="nav-link" href="{% url 'entries:entries' %}">
  48 + <a class="nav-link text-light" href="{% url 'entries:entries' %}">
48 49 {% trans "Hasła" %}
49 50 </a>
50 51 </li>
51 52 {% block additional-nav-items %}{% endblock %}
52 53 <li class="nav-item" id="nav-phrases">
53   - <a class="nav-link" href="{% url 'phrase_expansions:phrase_expansions' %}">
  54 + <a class="nav-link text-light" href="{% url 'phrase_expansions:phrase_expansions' %}">
54 55 {% trans "Typy fraz" %}
55 56 </a>
56 57 </li>
  58 + <li class="nav-item" id="nav-statistics">
  59 + <a class="nav-link text-light" href="{% url 'dictionary_statistics:dictionary_statistics' %}">
  60 + {% trans "Statystyki" %}
  61 + </a>
  62 + </li>
57 63 </ul>
58 64 </div>
59 65 <span id="import-status" class="navbar-text text-warning mr-3"></span>
... ...
common/templates/dash.html
... ... @@ -49,7 +49,7 @@
49 49 </div>
50 50 </div>
51 51  
52   -<div class="card mt-3">
  52 +<div class="card my-3">
53 53 <h5 class="card-header">{% trans "Pozostałe publikacje" %}</h5>
54 54 <div class="card-body">
55 55  
... ...
dictionary_statistics/templates/dictionary_statistics.html
... ... @@ -4,6 +4,8 @@
4 4  
5 5 {% load static %}
6 6  
  7 +{% load custom_templatetags %}
  8 +
7 9 {% block title %}{% trans "Statystyki" %}{% endblock %}
8 10  
9 11 {% block scripts %}
... ... @@ -12,10 +14,76 @@
12 14 {% block content2 %}
13 15  
14 16 <div class="card mt-3">
  17 + <h5 class="card-header">{% trans "Liczba haseł" %}</h5>
  18 + <div class="card-body">
  19 + <table class="table table-sm table-striped mb-0">
  20 + <thead>
  21 + <tr>
  22 + <th style="width: 13em;">{% trans "Status / część mowy" %}</th>
  23 + {% for pos in all_pos %}
  24 + <th style="width: 10em;" scope="col">{{ pos }}</th>
  25 + {% endfor %}
  26 + </tr>
  27 + </thead>
  28 + <tbody>
  29 + {% for status in all_statuses %}
  30 + <tr>
  31 + <th scope="row">{{ status }}</th>
  32 + {% for num in entry_stats|get_item:status %}
  33 + <td>{{ num }}</td>
  34 + {% endfor %}
  35 + </tr>
  36 + {% endfor %}
  37 + <tbody>
  38 + </table>
  39 + </div>
  40 +</div>
  41 +
  42 +<div class="card mt-3">
  43 + <h5 class="card-header">{% trans "Liczba schematów" %}</h5>
  44 + <div class="card-body">
  45 + <table class="table table-sm table-striped mb-0">
  46 + <thead>
  47 + <tr>
  48 + {% for opinion, opinion_key, n in schema_stats %}
  49 + <th style="width: 10em;" scope="col">
  50 + {% if opinion_key != "all" %}<img src="/static/entries/img/{{ opinion_key }}.svg" width="12" height="12" alt="{{ opinion }}"> {% endif %}{{ opinion }}
  51 + </th>
  52 + {% endfor %}
  53 + </tr>
  54 + </thead>
  55 + <tbody>
  56 + <tr>
  57 + {% for opinion, opinion_key, n in schema_stats %}
  58 + <td>{{ n }}</td>
  59 + {% endfor %}
  60 + </tr>
  61 + <tbody>
  62 + </table>
  63 + </div>
  64 +</div>
  65 +
  66 +<div class="card my-3">
  67 + <h5 class="card-header">{% trans "Liczba ram" %}</h5>
15 68 <div class="card-body">
16   - <p>
17   - Tutaj będą statystyki słownika.
18   - </p>
  69 + <table class="table table-sm table-striped mb-0">
  70 + <thead>
  71 + <tr>
  72 + {% for opinion, opinion_key, n in frame_stats %}
  73 + <th scope="col">
  74 + {% if opinion_key != "all" %}<img src="/static/entries/img/{{ opinion_key }}.svg" width="12" height="12" alt="{{ opinion }}"> {% endif %}{{ opinion }}
  75 + </th>
  76 + {% endfor %}
  77 + </tr>
  78 + </thead>
  79 + <tbody>
  80 + <tr>
  81 + {% for opinion, opinion_key, n in frame_stats %}
  82 + <td>{{ n }}</td>
  83 + {% endfor %}
  84 + </tr>
  85 + <tbody>
  86 + </table>
19 87 </div>
20 88 </div>
21 89  
... ...
dictionary_statistics/views.py
1 1 from django.shortcuts import render
  2 +from django.utils.translation import gettext as _
  3 +
  4 +from connections.models import Entry, POS, Status
  5 +from syntax.models import Schema, SchemaOpinion
  6 +from semantics.models import Frame, FrameOpinion
  7 +
  8 +from entries.polish_strings import POS as POS_names, STATUS, SCHEMA_OPINION, FRAME_OPINION
2 9  
3 10 def dictionary_statistics(request):
4   - return render(request, 'dictionary_statistics.html', { })
  11 + ALL = _('wszystkie')
  12 +
  13 + # ENTRIES
  14 + entries = Entry.objects.filter(import_error=False)
  15 + pos_names = POS_names()
  16 + status_names = STATUS()
  17 + entry_statuses = list(Status.objects.all())
  18 + all_pos = ['verb', 'noun', 'adj', 'adv']
  19 + entry_stats = { ALL : [entries.count()] + [entries.filter(pos__tag=pos).count() for pos in all_pos] }
  20 + used_statuses = set()
  21 + for status in entry_statuses:
  22 + c = entries.filter(status=status).count()
  23 + if c:
  24 + used_statuses.add(status)
  25 + entry_stats[status_names[status.key]] = [entries.filter(status=status).count()] + [entries.filter(status=status, pos__tag=pos).count() for pos in all_pos]
  26 + all_statuses = [ALL] + [status_names[status.key] for status in entry_statuses if status in used_statuses]
  27 + all_pos = [ALL] + [pos_names[pos] for pos in all_pos]
  28 +
  29 + # SCHEMATA
  30 + schemata = Schema.objects.filter(subentries__entry__import_error=False)
  31 + schema_opinions = SCHEMA_OPINION()
  32 + schema_stats = [(ALL, 'all', schemata.count())] + [(schema_opinions[opinion.key], opinion.key, schemata.filter(opinion=opinion).count()) for opinion in SchemaOpinion.objects.all()]
  33 +
  34 + # FRAMES
  35 + frames = Frame.objects.all() #filter(arguments__argument_connections__schema_connections__subentry__entry__import_error=False)
  36 + frame_opinions = FRAME_OPINION()
  37 + frame_stats = [(ALL, 'all', frames.count())] + [(frame_opinions[opinion.key], opinion.key, frames.filter(opinion=opinion).count()) for opinion in FrameOpinion.objects.all()]
  38 +
  39 + 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 })
... ...
entries/polish_strings.py
1 1 from django.utils.text import format_lazy
2 2 from django.utils.translation import gettext_lazy as _
3 3  
  4 +def STATUS():
  5 + return {
  6 + 'do obróbki' : _('do obróbki'),
  7 + 'w obróbce' : _('w obróbce'),
  8 + 'do usunięcia' : _('do usunięcia'),
  9 + 'gotowe' : _('gotowe'),
  10 + 'zalążkowe' : _('zalążkowe'),
  11 + 'sprawdzone' : _('sprawdzone'),
  12 + '(F) w obróbce' : _('(F) w obróbce'),
  13 + '(F) gotowe' : _('(F) gotowe'),
  14 + '(F) sprawdzone' : _('(F) sprawdzone'),
  15 + '(S) w obróbce' : _('(S) w obróbce'),
  16 + '(S) gotowe' : _('(S) gotowe'),
  17 + '(S) sprawdzone' : _('(S) sprawdzone'),
  18 + }
  19 +
4 20 def POS():
5 21 return {
6 22 'adj' : _('przymiotnik'),
... ... @@ -40,7 +56,7 @@ def FRAME_OPINION():
40 56 'col' : _('potoczna'),
41 57 'dat' : _('archaiczna'),
42 58 'bad' : _('zła'),
43   - 'unc' : _('niepewna'),
  59 + 'unc' : _('wątpliwa'),
44 60 'cer' : _('pewna'),
45 61 'rar' : _('sporadyczna'),
46 62 'dom' : _('dziedzinowa'),
... ...
entries/static/entries/css/entries.css
... ... @@ -90,55 +90,55 @@ legend {
90 90 }
91 91  
92 92 .form-depth-1 {
93   - background-color: #fefefe;
94   - border-color: #f3f4f5;
95   -}
96   -
97   -.form-depth-2 {
98 93 background-color: #f3f4f5;
99 94 border-color: #e8ebed;
100 95 }
101 96  
102   -.form-depth-3 {
  97 +.form-depth-2 {
103 98 background-color: #e8ebed;
104 99 border-color: #dee1e4;
105 100 }
106 101  
107   -.form-depth-4 {
  102 +.form-depth-3 {
108 103 background-color: #dee1e4;
109 104 border-color: #d3d7db;
110 105 }
111 106  
112   -.form-depth-5 {
  107 +.form-depth-4 {
113 108 background-color: #d3d7db;
114 109 border-color: #c8cdd2;
115 110 }
116 111  
117   -.form-depth-6 {
  112 +.form-depth-5 {
118 113 background-color: #c8cdd2;
119 114 border-color: #bdc3c9;
120 115 }
121 116  
122   -.form-depth-7 {
  117 +.form-depth-6 {
123 118 background-color: #bdc3c9;
124 119 border-color: #b2bac1;
125 120 }
126 121  
127   -.form-depth-8 {
  122 +.form-depth-7 {
128 123 background-color: #b2bac1;
129 124 border-color: #a7b0b8;
130 125 }
131 126  
132   -.form-depth-9 {
  127 +.form-depth-8 {
133 128 background-color: #a7b0b8;
134 129 border-color: #9da6af;
135 130 }
136 131  
137   -.form-depth-10 {
  132 +.form-depth-9 {
138 133 background-color: #9da6af;
139 134 border-color: #929ca6;
140 135 }
141 136  
  137 +.form-depth-10 {
  138 + background-color: #929ca6;
  139 + border-color: #87929e;
  140 +}
  141 +
142 142 .to-remove {
143 143 background-color: #f0b9b8;
144 144 }
... ...
entries/templates/entries.html
... ... @@ -30,7 +30,7 @@
30 30  
31 31 {% block additional-nav-items %}
32 32 <li class="nav-item dropdown">
33   - <a class="nav-link dropdown-toggle" href="#" id="nav-filters" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  33 + <a class="nav-link dropdown-toggle text-light" href="#" id="nav-filters" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
34 34 {% trans "Filtrowanie" %}
35 35 </a>
36 36 <div class="dropdown-menu" id="filters-visited-dropdown" aria-labelledby="nav-filters">
... ... @@ -46,7 +46,7 @@
46 46 </div>
47 47 </li>
48 48 <li class="nav-item dropdown">
49   - <a class="nav-link dropdown-toggle" href="#" id="nav-last" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  49 + <a class="nav-link dropdown-toggle text-light" href="#" id="nav-last" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
50 50 {% trans "Ostatnio oglądane" %}
51 51 </a>
52 52 <div class="dropdown-menu" id="last-visited-dropdown" aria-labelledby="nav-last">
... ... @@ -56,7 +56,7 @@
56 56 </div>
57 57 </li>
58 58 <li class="nav-item dropdown">
59   - <a class="nav-link dropdown-toggle" href="#" id="nav-options" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  59 + <a class="nav-link dropdown-toggle text-light" href="#" id="nav-options" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
60 60 {% trans "Opcje" %}
61 61 </a>
62 62 <div class="dropdown-menu px-1" id="options-dropdown" aria-labelledby="nav-options">
... ...