From: Aleksander Łukasz Date: Thu, 9 May 2013 11:10:10 +0000 (+0200) Subject: Merge tag categories feature into master X-Git-Url: https://git.mdrn.pl/prawokultury.git/commitdiff_plain/b9516daaa9f53a5bdbea02bd679fc9f89387d727?hp=341bba6a6521423f7d26115fe86195a551702cdc Merge tag categories feature into master --- diff --git a/prawokultury/settings.d/50-static.py b/prawokultury/settings.d/50-static.py index 1149c7e..0346e85 100644 --- a/prawokultury/settings.d/50-static.py +++ b/prawokultury/settings.d/50-static.py @@ -32,6 +32,12 @@ PIPELINE_CSS = { ), 'output_filename': 'compressed/base.css', }, + 'questions': { + 'source_filenames': ( + 'questions/tagcloud.scss', + ), + 'output_filename': 'compressed/questions.css' + } } PIPELINE_JS = { 'base': { @@ -42,6 +48,12 @@ PIPELINE_JS = { ), 'output_filename': 'compressed/base.js', }, + 'questions': { + 'source_filenames': ( + 'questions/tagcloud.js', + ), + 'output_filename': 'compressed/questions.js' + } } PIPELINE_COMPILERS = ( diff --git a/prawokultury/templates/base.html b/prawokultury/templates/base.html index 5ecc92d..c622f91 100755 --- a/prawokultury/templates/base.html +++ b/prawokultury/templates/base.html @@ -8,7 +8,7 @@ {% block "titleextra" %}{% endblock %}{% trans "Right to Culture" %} {% compressed_css 'base' %} - + {% block "extra_css" %}{% endblock %} @@ -119,5 +119,6 @@ {% compressed_js 'base' %} {{ piwik_tag|safe }} + {% block "extra_js" %}{% endblock %} diff --git a/questions/admin.py b/questions/admin.py index ec6d715..6427bbc 100755 --- a/questions/admin.py +++ b/questions/admin.py @@ -1,5 +1,5 @@ from django.contrib import admin -from .models import Question, Tag +from .models import Question, Tag, TagCategory class QuestionAdmin(admin.ModelAdmin): model = Question @@ -23,3 +23,4 @@ class QuestionAdmin(admin.ModelAdmin): admin.site.register(Question, QuestionAdmin) admin.site.register(Tag) +admin.site.register(TagCategory) diff --git a/questions/fixtures/first_tag_categories.json b/questions/fixtures/first_tag_categories.json new file mode 100644 index 0000000..ba9a806 --- /dev/null +++ b/questions/fixtures/first_tag_categories.json @@ -0,0 +1,1736 @@ +[ + { + "pk": 16, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "organizacje zbiorowego zarz\u0105dzania", + "slug": "organizacje-zbiorowego-zarzadzania" + } + }, + { + "pk": 18, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "ochrona postaci", + "slug": "ochrona-postaci" + } + }, + { + "pk": 23, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "naruszenie licencji CC", + "slug": "naruszenie-licencji-cc" + } + }, + { + "pk": 29, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "zakres ochrony", + "slug": "zakres-ochrony" + } + }, + { + "pk": 42, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "domena publiczna", + "slug": "domena-publiczna" + } + }, + { + "pk": 47, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "dozwolony u\u017cytek", + "slug": "dozwolony-uzytek" + } + }, + { + "pk": 88, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "licencje CC", + "slug": "licencje-cc" + } + }, + { + "pk": 26, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 1 pr. aut.", + "slug": "art-1-pr-aut" + } + }, + { + "pk": 49, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 115 pr. aut.", + "slug": "art-115-pr-aut" + } + }, + { + "pk": 60, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 12 pr. aut.", + "slug": "art-12-pr-aut" + } + }, + { + "pk": 28, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 2 pr. aut.", + "slug": "art-2-pr-aut" + } + }, + { + "pk": 81, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 23 pr. aut.", + "slug": "art-23-pr-aut" + } + }, + { + "pk": 19, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 25 pr. aut.", + "slug": "art-25-pr-aut" + } + }, + { + "pk": 89, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 27 pr. aut.", + "slug": "art-27-pr-aut" + } + }, + { + "pk": 58, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 29 pr. aut.", + "slug": "art-29-pr-aut" + } + }, + { + "pk": 39, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 3 pr. aut.", + "slug": "art-3-pr-aut" + } + }, + { + "pk": 46, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 34 pr. aut.", + "slug": "art-34-pr-aut" + } + }, + { + "pk": 83, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 35 pr. aut.", + "slug": "art-35-pr-aut" + } + }, + { + "pk": 100, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 4 pr. aut.", + "slug": "art-4-pr-aut" + } + }, + { + "pk": 66, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 43 pr. aut.", + "slug": "art-43-pr-aut" + } + }, + { + "pk": 7, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 44 pr. aut.", + "slug": "art-44-pr-aut" + } + }, + { + "pk": 97, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 49 ust. 2 pr. aut.", + "slug": "art-49-ust-2-pr-aut" + } + }, + { + "pk": 8, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 56 pr. aut.", + "slug": "art-56-pr-aut" + } + }, + { + "pk": 4, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 57 pr. aut.", + "slug": "art-57-pr-aut" + } + }, + { + "pk": 63, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 85 pr. aut.", + "slug": "art-85-pr-aut" + } + }, + { + "pk": 37, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 99^1 pr. aut.", + "slug": "art-991-pr-aut" + } + }, + { + "pk": 38, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 99^2 pr. aut.", + "slug": "art-992-pr-aut" + } + }, + { + "pk": 64, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "artystyczne wykonanie", + "slug": "artystyczne-wykonanie" + } + }, + { + "pk": 33, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "baza danych", + "slug": "baza-danych" + } + }, + { + "pk": 54, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "fotografia", + "slug": "fotografia" + } + }, + { + "pk": 57, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "interfejs", + "slug": "interfejs" + } + }, + { + "pk": 31, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "patent", + "slug": "patent" + } + }, + { + "pk": 59, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "programy komputerowe", + "slug": "programy-komputerowe" + } + }, + { + "pk": 71, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "rejestracje audiowizualne", + "slug": "rejestracje-audiowizualne" + } + }, + { + "pk": 72, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "utw\u00f3r audiowizualny", + "slug": "utwor-audiowizualny" + } + }, + { + "pk": 70, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "wideogram", + "slug": "wideogram" + } + }, + { + "pk": 91, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "wizerunek", + "slug": "wizerunek" + } + }, + { + "pk": 92, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "w\u0142asno\u015b\u0107", + "slug": "wlasnosc" + } + }, + { + "pk": 11, + "model": "questions.tag", + "fields": { + "category": 5, + "click_count": 0, + "name": "autorskie prawa osobiste", + "slug": "autorskie-prawa-osobiste" + } + }, + { + "pk": 35, + "model": "questions.tag", + "fields": { + "category": 5, + "click_count": 0, + "name": "prawa pokrewne", + "slug": "prawa-pokrewne" + } + }, + { + "pk": 40, + "model": "questions.tag", + "fields": { + "category": 5, + "click_count": 0, + "name": "prawo do pierwszych wyda\u0144", + "slug": "prawo-do-pierwszych-wydan" + } + }, + { + "pk": 50, + "model": "questions.tag", + "fields": { + "category": 5, + "click_count": 0, + "name": "prawo do wynagrodzenia", + "slug": "prawo-do-wynagrodzenia" + } + }, + { + "pk": 14, + "model": "questions.tag", + "fields": { + "category": 5, + "click_count": 0, + "name": "prawo do zezwalania na korzystanie z opracowa\u0144", + "slug": "prawo-do-zezwalania-na-korzystanie-z-opracowan" + } + }, + { + "pk": 52, + "model": "questions.tag", + "fields": { + "category": 5, + "click_count": 0, + "name": "uznanie autorstwa", + "slug": "uznanie-autorstwa" + } + }, + { + "pk": 74, + "model": "questions.tag", + "fields": { + "category": 6, + "click_count": 0, + "name": "CC-BY-NC", + "slug": "cc-by-nc" + } + }, + { + "pk": 53, + "model": "questions.tag", + "fields": { + "category": 6, + "click_count": 0, + "name": "CC-BY-ND", + "slug": "cc-by-nd" + } + }, + { + "pk": 43, + "model": "questions.tag", + "fields": { + "category": 6, + "click_count": 0, + "name": "CC-BY-SA", + "slug": "cc-by-sa" + } + }, + { + "pk": 22, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "cel informacyjny", + "slug": "cel-informacyjny" + } + }, + { + "pk": 1, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "edukacja", + "slug": "edukacja" + } + }, + { + "pk": 76, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "komercyjne wykorzystanie", + "slug": "komercyjne-wykorzystanie" + } + }, + { + "pk": 32, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "link", + "slug": "link" + } + }, + { + "pk": 20, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "mowy publiczne", + "slug": "mowy-publiczne" + } + }, + { + "pk": 13, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "nadawanie utworu", + "slug": "nadawanie-utworu" + } + }, + { + "pk": 104, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "nazwa", + "slug": "nazwa" + } + }, + { + "pk": 87, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "niekomercyjne wykorzystanie", + "slug": "niekomercyjne-wykorzystanie" + } + }, + { + "pk": 65, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "nieodp\u0142atne korzystanie", + "slug": "nieodplatne-korzystanie" + } + }, + { + "pk": 86, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "odp\u0142atne korzystanie", + "slug": "odplatne-korzystanie" + } + }, + { + "pk": 48, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "przedruk", + "slug": "przedruk" + } + }, + { + "pk": 107, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "publiczne wy\u015bwietlenie", + "slug": "publiczne-wyswietlenie" + } + }, + { + "pk": 77, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "reklama", + "slug": "reklama" + } + }, + { + "pk": 84, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "reprografia", + "slug": "reprografia" + } + }, + { + "pk": 105, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "rozpowszechnianie", + "slug": "rozpowszechnianie" + } + }, + { + "pk": 2, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "dozwolony cytat", + "slug": "dozwolony-cytat" + } + }, + { + "pk": 80, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "dozwolony u\u017cytek osobisty", + "slug": "dozwolony-uzytek-osobisty" + } + }, + { + "pk": 106, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "dozwolony u\u017cytek prywatny", + "slug": "dozwolony-uzytek-prywatny" + } + }, + { + "pk": 67, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "op\u0142aty rekompensacyjne", + "slug": "oplaty-rekompensacyjne" + } + }, + { + "pk": 78, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "pojedyncze egzemplarze", + "slug": "pojedyncze-egzemplarze" + } + }, + { + "pk": 82, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "s\u0142uszne interesy tw\u00f3rcy", + "slug": "sluszne-interesy-tworcy" + } + }, + { + "pk": 108, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "stosunek towarzyski", + "slug": "stosunek-towarzyski" + } + }, + { + "pk": 79, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "trzystopniowy test", + "slug": "trzystopniowy-test" + } + }, + { + "pk": 21, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "utw\u00f3r rozpowszechniony", + "slug": "utwor-rozpowszechniony" + } + }, + { + "pk": 98, + "model": "questions.tag", + "fields": { + "category": 9, + "click_count": 0, + "name": "integralno\u015b\u0107 utworu", + "slug": "integralnosc-utworu" + } + }, + { + "pk": 30, + "model": "questions.tag", + "fields": { + "category": 9, + "click_count": 0, + "name": "opracowanie", + "slug": "opracowanie" + } + }, + { + "pk": 36, + "model": "questions.tag", + "fields": { + "category": 9, + "click_count": 0, + "name": "zbi\u00f3r", + "slug": "zbior" + } + }, + { + "pk": 99, + "model": "questions.tag", + "fields": { + "category": 9, + "click_count": 0, + "name": "zmiany utworu", + "slug": "zmiany-utworu" + } + }, + { + "pk": 69, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "ci\u0119\u017car dowodu", + "slug": "ciezar-dowodu" + } + }, + { + "pk": 45, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "dochodzenie ochrony za granic\u0105", + "slug": "dochodzenie-ochrony-za-granica" + } + }, + { + "pk": 25, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "naruszenie autorskich praw osobistych", + "slug": "naruszenie-autorskich-praw-osobistych" + } + }, + { + "pk": 51, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "plagiat", + "slug": "plagiat" + } + }, + { + "pk": 44, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "wykazanie naruszenia", + "slug": "wykazanie-naruszenia" + } + }, + { + "pk": 102, + "model": "questions.tag", + "fields": { + "category": 11, + "click_count": 0, + "name": "materia\u0142y urz\u0119dowe", + "slug": "materialy-urzedowe" + } + }, + { + "pk": 41, + "model": "questions.tag", + "fields": { + "category": 11, + "click_count": 0, + "name": "wygasanie ochrony", + "slug": "wygasanie-ochrony" + } + }, + { + "pk": 3, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "odst\u0105pienie", + "slug": "odstapienie" + } + }, + { + "pk": 85, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "orygina\u0142", + "slug": "oryginal" + } + }, + { + "pk": 5, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "przenoszenie autorskich praw maj\u0105tkowych", + "slug": "przenoszenie-autorskich-praw-majatkowych" + } + }, + { + "pk": 15, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "spadkobiercy", + "slug": "spadkobiercy" + } + }, + { + "pk": 9, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "wypowiedzenie", + "slug": "wypowiedzenie" + } + }, + { + "pk": 6, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "zasada specyfikacji p\u00f3l eksploatacji", + "slug": "zasada-specyfikacji-pol-eksploatacji" + } + }, + { + "pk": 93, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "znajdowanie uprawnionego", + "slug": "znajdowanie-uprawnionego" + } + }, + { + "pk": 27, + "model": "questions.tag", + "fields": { + "category": 13, + "click_count": 0, + "name": "indywidualna tw\u00f3rczo\u015b\u0107", + "slug": "indywidualna-tworczosc" + } + }, + { + "pk": 61, + "model": "questions.tag", + "fields": { + "category": 13, + "click_count": 0, + "name": "utwory pracownicze", + "slug": "utwory-pracownicze" + } + }, + { + "pk": 95, + "model": "questions.tag", + "fields": { + "category": 13, + "click_count": 0, + "name": "utwory u\u017cytkowe", + "slug": "utwory-uzytkowe" + } + }, + { + "pk": 56, + "model": "questions.tag", + "fields": { + "category": 13, + "click_count": 0, + "name": "wynik dzia\u0142ania programu", + "slug": "wynik-dzialania-programu" + } + }, + { + "pk": 101, + "model": "questions.tag", + "fields": { + "category": 14, + "click_count": 0, + "name": "informacja publiczna", + "slug": "informacja-publiczna" + } + }, + { + "pk": 103, + "model": "questions.tag", + "fields": { + "category": 14, + "click_count": 0, + "name": "ponowne wykorzystanie informacji publicznej", + "slug": "ponowne-wykorzystanie-informacji-publicznej" + } + }, + { + "pk": 73, + "model": "questions.tag", + "fields": { + "category": 15, + "click_count": 0, + "name": "tabele wynagrodze\u0144", + "slug": "tabele-wynagrodzen" + } + }, + { + "pk": 154, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "publiczne udost\u0119pnianie", + "slug": "publiczne-udostepnianie" + } + }, + { + "pk": 155, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "50% koszty uzyskania przychodu", + "slug": "50-koszty-uzyskania-przychodu" + } + }, + { + "pk": 156, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "art. 18 pr. aut.", + "slug": "art-18-pr-aut" + } + }, + { + "pk": 157, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "egzekucja z praw autorskich", + "slug": "egzekucja-z-praw-autorskich" + } + }, + { + "pk": 158, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "ustawa o j\u0119zyku polskim", + "slug": "ustawa-o-jezyku-polskim" + } + }, + { + "pk": 159, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "j\u0119zyk umowy", + "slug": "jezyk-umowy" + } + }, + { + "pk": 160, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "art. 33 pr. aut.", + "slug": "art-33-pr-aut" + } + }, + { + "pk": 161, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "utwory osierocone", + "slug": "utwory-osierocone" + } + }, + { + "pk": 162, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "art. 77 pr. aut.", + "slug": "art-77-pr-aut" + } + }, + { + "pk": 130, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 28 pr. aut.", + "slug": "art-28-pr-aut" + } + }, + { + "pk": 62, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 31 pr. aut.", + "slug": "art-31-pr-aut" + } + }, + { + "pk": 147, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 32 pr. aut.", + "slug": "art-32-pr-aut" + } + }, + { + "pk": 10, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 47 pr. aut.", + "slug": "art-47-pr-aut" + } + }, + { + "pk": 145, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 51 pr. aut.", + "slug": "art-51-pr-aut" + } + }, + { + "pk": 114, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 81 pr. aut.", + "slug": "art-81-pr-aut" + } + }, + { + "pk": 123, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 9 pr. aut.", + "slug": "art-9-pr-aut" + } + }, + { + "pk": 96, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "dobra osobiste", + "slug": "dobra-osobiste" + } + }, + { + "pk": 152, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "praca dyplomowa", + "slug": "praca-dyplomowa" + } + }, + { + "pk": 121, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "Polskie Normy", + "slug": "polskie-normy" + } + }, + { + "pk": 109, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "utw\u00f3r", + "slug": "utwor" + } + }, + { + "pk": 94, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "wzory przemys\u0142owe", + "slug": "wzory-przemyslowe" + } + }, + { + "pk": 127, + "model": "questions.tag", + "fields": { + "category": 4, + "click_count": 0, + "name": "znaki towarowe", + "slug": "znaki-towarowe" + } + }, + { + "pk": 153, + "model": "questions.tag", + "fields": { + "category": 5, + "click_count": 0, + "name": "pierwsze\u0144stwo publikacji", + "slug": "pierwszenstwo-publikacji" + } + }, + { + "pk": 116, + "model": "questions.tag", + "fields": { + "category": 5, + "click_count": 0, + "name": "prawo do autorstwa", + "slug": "prawo-do-autorstwa" + } + }, + { + "pk": 34, + "model": "questions.tag", + "fields": { + "category": 5, + "click_count": 0, + "name": "prawo do wyda\u0144 naukowych i krytycznych", + "slug": "prawo-do-wydan-naukowych-i-krytycznych" + } + }, + { + "pk": 117, + "model": "questions.tag", + "fields": { + "category": 5, + "click_count": 0, + "name": "pseudonim", + "slug": "pseudonim" + } + }, + { + "pk": 131, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "biblioteka cyfrowa", + "slug": "biblioteka-cyfrowa" + } + }, + { + "pk": 138, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "cytat", + "slug": "cytat" + } + }, + { + "pk": 135, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "fragment utworu", + "slug": "fragment-utworu" + } + }, + { + "pk": 136, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "kola\u017c", + "slug": "kolaz" + } + }, + { + "pk": 143, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "koncert", + "slug": "koncert" + } + }, + { + "pk": 151, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "moda", + "slug": "moda" + } + }, + { + "pk": 146, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "publiczne wystawienie", + "slug": "publiczne-wystawienie" + } + }, + { + "pk": 129, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "terminale", + "slug": "terminale" + } + }, + { + "pk": 122, + "model": "questions.tag", + "fields": { + "category": 7, + "click_count": 0, + "name": "zwielokrotnienie", + "slug": "zwielokrotnienie" + } + }, + { + "pk": 128, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "dozwolony u\u017cytek biblioteczny", + "slug": "dozwolony-uzytek-biblioteczny" + } + }, + { + "pk": 90, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "dozwolony u\u017cytek edukacyjny", + "slug": "dozwolony-uzytek-edukacyjny" + } + }, + { + "pk": 110, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "dozwolony u\u017cytek naukowy", + "slug": "dozwolony-uzytek-naukowy" + } + }, + { + "pk": 137, + "model": "questions.tag", + "fields": { + "category": 8, + "click_count": 0, + "name": "wskazywanie \u017ar\u00f3d\u0142a", + "slug": "wskazywanie-zrodla" + } + }, + { + "pk": 133, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 14 u\u015bude", + "slug": "art-14-usude" + } + }, + { + "pk": 68, + "model": "questions.tag", + "fields": { + "category": 3, + "click_count": 0, + "name": "art. 20 pr. aut.", + "slug": "art-20-pr-aut" + } + }, + { + "pk": 126, + "model": "questions.tag", + "fields": { + "category": 9, + "click_count": 0, + "name": "cudze materia\u0142y", + "slug": "cudze-materialy" + } + }, + { + "pk": 120, + "model": "questions.tag", + "fields": { + "category": 9, + "click_count": 0, + "name": "niezale\u017cna tw\u00f3rczo\u015b\u0107", + "slug": "niezalezna-tworczosc" + } + }, + { + "pk": 113, + "model": "questions.tag", + "fields": { + "category": 9, + "click_count": 0, + "name": "t\u0142umaczenie", + "slug": "tlumaczenie" + } + }, + { + "pk": 148, + "model": "questions.tag", + "fields": { + "category": 9, + "click_count": 0, + "name": "utw\u00f3r inspirowany", + "slug": "utwor-inspirowany" + } + }, + { + "pk": 17, + "model": "questions.tag", + "fields": { + "category": 9, + "click_count": 0, + "name": "utw\u00f3r wsp\u00f3\u0142autorski", + "slug": "utwor-wspolautorski" + } + }, + { + "pk": 132, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "bezpieczna przysta\u0144", + "slug": "bezpieczna-przystan" + } + }, + { + "pk": 124, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "dochodzenie ochrony", + "slug": "dochodzenie-ochrony" + } + }, + { + "pk": 142, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "domniemanie niewinno\u015bci", + "slug": "domniemanie-niewinnosci" + } + }, + { + "pk": 24, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "naruszenie autorskich praw maj\u0105tkowych", + "slug": "naruszenie-autorskich-praw-majatkowych" + } + }, + { + "pk": 134, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "us\u0142ugi hostingowe", + "slug": "uslugi-hostingowe" + } + }, + { + "pk": 111, + "model": "questions.tag", + "fields": { + "category": 10, + "click_count": 0, + "name": "wykazanie autorstwa", + "slug": "wykazanie-autorstwa" + } + }, + { + "pk": 115, + "model": "questions.tag", + "fields": { + "category": 11, + "click_count": 0, + "name": "termin wyga\u015bni\u0119cia ochrony", + "slug": "termin-wygasniecia-ochrony" + } + }, + { + "pk": 139, + "model": "questions.tag", + "fields": { + "category": 11, + "click_count": 0, + "name": "proste informacje prasowe", + "slug": "proste-informacje-prasowe" + } + }, + { + "pk": 144, + "model": "questions.tag", + "fields": { + "category": 11, + "click_count": 0, + "name": "wyczerpanie prawa", + "slug": "wyczerpanie-prawa" + } + }, + { + "pk": 119, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "forma pisemna", + "slug": "forma-pisemna" + } + }, + { + "pk": 141, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "legalny posiadacz", + "slug": "legalny-posiadacz" + } + }, + { + "pk": 150, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "licencje", + "slug": "licencje" + } + }, + { + "pk": 149, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "sublicencje", + "slug": "sublicencje" + } + }, + { + "pk": 118, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "umowa wydawnicza", + "slug": "umowa-wydawnicza" + } + }, + { + "pk": 12, + "model": "questions.tag", + "fields": { + "category": 12, + "click_count": 0, + "name": "zgoda uprawnionego", + "slug": "zgoda-uprawnionego" + } + }, + { + "pk": 125, + "model": "questions.tag", + "fields": { + "category": 13, + "click_count": 0, + "name": "postacie", + "slug": "postacie" + } + }, + { + "pk": 112, + "model": "questions.tag", + "fields": { + "category": 13, + "click_count": 0, + "name": "utwory plastyczne", + "slug": "utwory-plastyczne" + } + }, + { + "pk": 140, + "model": "questions.tag", + "fields": { + "category": 15, + "click_count": 0, + "name": "wynagrodzenia niezbywalne", + "slug": "wynagrodzenia-niezbywalne" + } + }, + { + "pk": 164, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "utw\u00f3r nieuko\u0144czony", + "slug": "utwor-nieukonczony" + } + }, + { + "pk": 165, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "jednostki organizacyjne", + "slug": "jednostki-organizacyjne" + } + }, + { + "pk": 163, + "model": "questions.tag", + "fields": { + "category": null, + "click_count": 0, + "name": "pierwsze udost\u0119pnienie publiczno\u015bci", + "slug": "pierwsze-udostepnienie-publicznosci" + } + }, + { + "pk": 3, + "model": "questions.tagcategory", + "fields": { + "name": "przepisy prawa", + "slug": "przepisy-prawa" + } + }, + { + "pk": 4, + "model": "questions.tagcategory", + "fields": { + "name": "przedmioty ochrony", + "slug": "przedmioty-ochrony" + } + }, + { + "pk": 5, + "model": "questions.tagcategory", + "fields": { + "name": "rodzaje praw", + "slug": "rodzaje-praw" + } + }, + { + "pk": 6, + "model": "questions.tagcategory", + "fields": { + "name": "licencje CC", + "slug": "licencje-cc" + } + }, + { + "pk": 7, + "model": "questions.tagcategory", + "fields": { + "name": "sposoby wykorzystania", + "slug": "sposoby-wykorzystania" + } + }, + { + "pk": 8, + "model": "questions.tagcategory", + "fields": { + "name": "dozwolony u\u017cytek", + "slug": "dozwolony-uzytek" + } + }, + { + "pk": 9, + "model": "questions.tagcategory", + "fields": { + "name": "cudza tw\u00f3rczo\u015b\u0107", + "slug": "cudza-tworczosc" + } + }, + { + "pk": 10, + "model": "questions.tagcategory", + "fields": { + "name": "odpowiedzialno\u015b\u0107", + "slug": "odpowiedzialnosc" + } + }, + { + "pk": 11, + "model": "questions.tagcategory", + "fields": { + "name": "domena publiczna", + "slug": "domena-publiczna" + } + }, + { + "pk": 12, + "model": "questions.tagcategory", + "fields": { + "name": "umowy", + "slug": "umowy" + } + }, + { + "pk": 13, + "model": "questions.tagcategory", + "fields": { + "name": "zakres ochrony", + "slug": "zakres-ochrony" + } + }, + { + "pk": 14, + "model": "questions.tagcategory", + "fields": { + "name": "zasoby publiczne", + "slug": "zasoby-publiczne" + } + }, + { + "pk": 15, + "model": "questions.tagcategory", + "fields": { + "name": "organizacje zbiorowego zarz\u0105dzania", + "slug": "organizacje-zbiorowego-zarzadzania" + } + } +] \ No newline at end of file diff --git a/questions/migrations/0004_auto__add_tagcategory__add_field_tag_category__add_unique_tag_name.py b/questions/migrations/0004_auto__add_tagcategory__add_field_tag_category__add_unique_tag_name.py new file mode 100644 index 0000000..ebed00d --- /dev/null +++ b/questions/migrations/0004_auto__add_tagcategory__add_field_tag_category__add_unique_tag_name.py @@ -0,0 +1,86 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'TagCategory' + db.create_table('questions_tagcategory', ( + ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=100)), + ('slug', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=100)), + )) + db.send_create_signal('questions', ['TagCategory']) + + # Adding field 'Tag.category' + db.add_column('questions_tag', 'category', + self.gf('django.db.models.fields.related.ForeignKey')(to=orm['questions.TagCategory'], null=True, on_delete=models.SET_NULL, blank=True), + keep_default=False) + + # Adding unique constraint on 'Tag', fields ['name'] + db.create_unique('questions_tag', ['name']) + + + def backwards(self, orm): + # Removing unique constraint on 'Tag', fields ['name'] + db.delete_unique('questions_tag', ['name']) + + # Deleting model 'TagCategory' + db.delete_table('questions_tagcategory') + + # Deleting field 'Tag.category' + db.delete_column('questions_tag', 'category_id') + + + models = { + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'questions.question': { + 'Meta': {'ordering': "['-created_at']", 'object_name': 'Question'}, + '_answer_rendered': ('django.db.models.fields.TextField', [], {}), + 'answer': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True', 'blank': 'True'}), + 'answer_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), + 'answered': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), + 'answered_at': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'approved': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'changed_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'edited_question': ('django.db.models.fields.TextField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), + 'published_at': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'question': ('django.db.models.fields.TextField', [], {'db_index': 'True'}) + }, + 'questions.tag': { + 'Meta': {'object_name': 'Tag'}, + 'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['questions.TagCategory']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'questions.tagcategory': { + 'Meta': {'object_name': 'TagCategory'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'questions.tagitem': { + 'Meta': {'object_name': 'TagItem'}, + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'questions_tagitem_tagged_items'", 'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'object_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}), + 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'items'", 'to': "orm['questions.Tag']"}) + } + } + + complete_apps = ['questions'] \ No newline at end of file diff --git a/questions/migrations/0005_auto__add_field_tag_click_count.py b/questions/migrations/0005_auto__add_field_tag_click_count.py new file mode 100644 index 0000000..c2e6445 --- /dev/null +++ b/questions/migrations/0005_auto__add_field_tag_click_count.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'Tag.click_count' + db.add_column('questions_tag', 'click_count', + self.gf('django.db.models.fields.IntegerField')(default=0), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'Tag.click_count' + db.delete_column('questions_tag', 'click_count') + + + models = { + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'questions.question': { + 'Meta': {'ordering': "['-created_at']", 'object_name': 'Question'}, + '_answer_rendered': ('django.db.models.fields.TextField', [], {}), + 'answer': ('markupfield.fields.MarkupField', [], {'rendered_field': 'True', 'blank': 'True'}), + 'answer_markup_type': ('django.db.models.fields.CharField', [], {'default': "'textile_pl'", 'max_length': '30', 'blank': 'True'}), + 'answered': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), + 'answered_at': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'approved': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'changed_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'edited_question': ('django.db.models.fields.TextField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'published': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), + 'published_at': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'question': ('django.db.models.fields.TextField', [], {'db_index': 'True'}) + }, + 'questions.tag': { + 'Meta': {'object_name': 'Tag'}, + 'category': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['questions.TagCategory']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'}), + 'click_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'questions.tagcategory': { + 'Meta': {'object_name': 'TagCategory'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'questions.tagitem': { + 'Meta': {'object_name': 'TagItem'}, + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'questions_tagitem_tagged_items'", 'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'object_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}), + 'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'items'", 'to': "orm['questions.Tag']"}) + } + } + + complete_apps = ['questions'] \ No newline at end of file diff --git a/questions/models.py b/questions/models.py index ed86730..746ad84 100644 --- a/questions/models.py +++ b/questions/models.py @@ -12,6 +12,18 @@ from taggit_autosuggest.managers import TaggableManager from fnpdjango.utils.text.slughifi import slughifi +class TagCategory(models.Model): + name = models.CharField(verbose_name=_('Name'), unique = True, max_length = 100) + slug = models.SlugField(verbose_name=_('Slug'), unique = True, max_length = 100) + + class Meta: + verbose_name = _("Tag Category") + verbose_name_plural = _("Tag Categories") + + def __unicode__(self): + return self.name + + class Tag(TagBase): def slugify(self, tag, i=None): slug = slughifi(tag) @@ -19,6 +31,9 @@ class Tag(TagBase): slug += "_%d" % i return slug + category = models.ForeignKey(TagCategory, blank = True, null = True, on_delete = models.SET_NULL, related_name = 'tags') + click_count = models.IntegerField(null = False, default = 0) + class Meta: verbose_name = _("Tag") verbose_name_plural = _("Tags") diff --git a/questions/static/questions/tagcloud.js b/questions/static/questions/tagcloud.js new file mode 100644 index 0000000..992d573 --- /dev/null +++ b/questions/static/questions/tagcloud.js @@ -0,0 +1,21 @@ +$(function() { + var showTagsGroup = function(category_id) { + $('.questions-tags-group').hide(); + $('.questions-tags-group[data-category-id=' + category_id +']').show(); + } + $('#questions-categories a').click(function(e) { + e.preventDefault(); + var target = $(e.target); + if(target.hasClass('selected')) + return; + var category_id = target.attr('data-category-id'); + $('#questions-categories a').removeClass('selected'); + target.addClass('selected'); + showTagsGroup(category_id); + }); + var selected = $('#questions-categories a.selected'); + if(selected) { + var category_id = selected.attr('data-category-id'); + showTagsGroup(category_id); + } +}); \ No newline at end of file diff --git a/questions/static/questions/tagcloud.scss b/questions/static/questions/tagcloud.scss new file mode 100644 index 0000000..3147815 --- /dev/null +++ b/questions/static/questions/tagcloud.scss @@ -0,0 +1,19 @@ +#questions-filter { + div { + margin: 10px 0; + } +} +#questions-categories { + margin-bottom:10px; + display: inline; + a.selected { + cursor: default; + text-decoration: none; + color: black; + } +} + +.questions-tags-group { + display: none; +} + diff --git a/questions/templates/questions/question_list.html b/questions/templates/questions/question_list.html index c21f888..fb7c350 100755 --- a/questions/templates/questions/question_list.html +++ b/questions/templates/questions/question_list.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% load url from future %} {% load pagination_tags fnp_prevnext %} +{% load compressed %} {% block "titleextra" %}Pierwsza pomoc w prawie autorskim :: {% endblock %} {% block "body" %} @@ -27,16 +28,32 @@ autorem szeregu publikacji naukowych poświęconych korzystaniu z technologii informacyjno-komunikacyjnych oraz posiada wieloletnie doświadczenie doradcze w tej tematyce.

-Tematy: -{% if tag %}wszystkie -{% else %}wszystkie -{% endif %} +
+

Filtruj pytania

+ Wybierz kategorię tematów: +
+ bez kategorii + {% for category in tag_categories %} / + {{category}} + {% endfor %} +
-{% for atag in tags %} / - {% if atag == tag %}{{ atag }} - {% else %}{{ atag }} - {% endif %} -{% endfor %} +
+ {% for category_id, tag_list in tag_lists.items %} +
+ Wyświetl tylko na temat: + {% for atag in tag_list %} {% if not forloop.first %}/{% endif %} + {% if atag == tag %}{{ atag }} + {% else %}{{ atag }} + {% endif %} + {% endfor %} +
+ {% endfor %} +
+
+ {% if tag %}Pokaż wszystkie pytania{% endif %} +
+

Odpowiedzi na już zadane pytania {% if tag %}na temat: {{ tag }}{% endif %} @@ -57,3 +74,11 @@ Tematy: {% endblock %} + +{% block "extra_css" %} + {% compressed_css 'questions' %} +{% endblock %} + +{% block "extra_js" %} + {% compressed_js 'questions' %} +{% endblock %} diff --git a/questions/views.py b/questions/views.py index 9c75ac6..076a2e0 100644 --- a/questions/views.py +++ b/questions/views.py @@ -8,7 +8,7 @@ from django.shortcuts import get_object_or_404 from django.views.generic import ListView from django.views.generic.edit import FormView from .forms import QuestionForm -from .models import Question, Tag +from .models import Question, Tag, TagCategory class QuestionFormView(FormView): @@ -36,11 +36,34 @@ class QuestionListView(ListView): ).order_by('-published_at') if self.tag: qs = qs.filter(tags=self.tag) + self.tag.click_count += 1 + self.tag.save() return qs def get_context_data(self, *args, **kwargs): + def get_cloud_size(clicks, relate_to): + return '%.2f' % (0.7 + (float(clicks) / relate_to if relate_to != 0 else 0)) + context = super(QuestionListView, self).get_context_data(*args, **kwargs) - context['tags'] = Tag.objects.filter(items__question__published=True - ).annotate(c=models.Count('items__tag')).order_by('-c', 'slug') context['tag'] = self.tag + context['tag_categories'] = TagCategory.objects.all().annotate(click_count = models.Sum('tags__click_count')) + context['tag_lists'] = dict() + + annotated_categories = dict() + all_tags_click_count = Tag.objects.all().aggregate(models.Sum('click_count'))['click_count__sum'] + for category in context['tag_categories']: + annotated_categories[category.id] = category + category.cloud_size = get_cloud_size(category.click_count, all_tags_click_count) + + tags = Tag.objects.filter(items__question__published=True) \ + .annotate(c=models.Count('items__tag')).order_by('category__slug', '-c', 'slug') + uncategorized_tags_click_count = Tag.objects.filter(category=None).aggregate(models.Sum('click_count'))['click_count__sum'] + for tag in tags: + if tag.category: + category_click_count = annotated_categories[tag.category.id].click_count + else: + category_click_count = uncategorized_tags_click_count + tag.cloud_size = get_cloud_size(tag.click_count, category_click_count) + context['tag_lists'].setdefault(tag.category.id if tag.category else 0, []).append(tag) + return context