Difference between revisions of "Artenquiz documentation"
From Biowikifarm Metawiki
m (+docu) |
|||
(25 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | (See also [[Django-Installation]]) | + | (See also [[Django-Installation]] and [https://docs.djangoproject.com/en/1.6/intro/overview/ Django at a glance]) |
− | + | == Artenquiz (Naturgucker) == | |
− | + | ||
− | An admin interface for django users having a special admin account | + | This is running under: |
− | + | ; http://artenquiz.de/ : projects run for naturgucker, e.g. [http://artenquiz.de/vögel/ vögel], [http://artenquiz.de/schmetterlinge/ schmetterlinge], [http://artenquiz.de/nachtrag_schmetterlinge/ nachtrag_schmetterlinge] | |
− | [[ | + | ; http://artenquiz.de/bestimmung/ : Test for identification based on data of Artenquiz. Additional keys: http://artenquiz.de/bestimmung_testen/ |
+ | ; http://artenquiz.de/mobile_bestimmung/ : Test with additional keys: http://artenquiz.de/mobile_bestimmung_testen/ | ||
+ | ; http://artenquiz.de/admin/ : An admin interface for django users having a special admin account | ||
+ | ; http://artenquiz.de/admin/doc/ : automatic documentation generated if Python's [http://docutils.sf.net/ docutils] | ||
+ | ; https://biowikifarm.net/svn/artenquiz/ : Subversion directory (you must be e registered user for svn to get access) | ||
+ | Schema diagram at: <br/>http://biowikifarm.net/v-artenquiz/django/doc/current_artenquiz_schema.png<br/>http://biowikifarm.net/v-artenquiz/django/doc/current_artenquiz_schema.pdf | ||
+ | |||
+ | See also: [[Artenquiz AnyObject cleanup]] | ||
+ | |||
+ | === Folder structure Artenquiz (Naturgucker) === | ||
/var/www/v-artenquiz/django/ | /var/www/v-artenquiz/django/ | ||
− | + | · {{comment gray | manage.py (manage file for the django app)}} | |
├ /artenbestimmung {{comment gray | (projects artenquiz + artenbestimmung) }} | ├ /artenbestimmung {{comment gray | (projects artenquiz + artenbestimmung) }} | ||
− | · http://artenquiz. | + | · http://artenquiz.de/ |
− | · http://artenquiz. | + | · http://artenquiz.de/mobile_bestimmung/ |
+ | · /accounts {{comment gray | (backend for user_name or email login) }} | ||
· /artenquiz | · /artenquiz | ||
· /management | · /management | ||
Line 19: | Line 28: | ||
· {{comment gray | cd /path-to/artenbestimmung }} | · {{comment gray | cd /path-to/artenbestimmung }} | ||
· {{comment gray | python manage.py help importtaxa }} | · {{comment gray | python manage.py help importtaxa }} | ||
− | · {{comment gray | python manage.py importtaxa datafile.csv }} | + | · {{comment gray | python manage.py importtaxa /path-to/datafile.csv }} |
+ | · /templatetags {{comment gray | (custom tags used in templates) }} | ||
+ | · /static {{comment gray | (static CSS styles, JavaScript files, icons) }} | ||
+ | · /tools {{comment gray | (python script tools) }} | ||
+ | · /local {{comment gray | (generated localization files and defined English translations) }} | ||
+ | · /register {{comment gray | (definitions of registration) }} | ||
+ | · /report {{comment gray | (simple reports of descriptions for admins) }} | ||
+ | · /templates {{comment gray | (all django XHTML-templates and page texts) }} | ||
+ | · /account_naturgucker {{comment gray |login, registration for [http://www.naturgucker.de naturgucker.de]}} | ||
+ | · /edit {{comment gray |in the future: templates for editing descriptions}} | ||
+ | · /registration {{comment gray |used for standard (Django) registration}} | ||
+ | · /report {{comment gray |reports for projects, e.g. score list}} | ||
+ | · /vögel {{comment gray |specific templates for project.code vögel. Name of folder should follow db entry of ‹project.code›}} | ||
+ | · /‹project.code› {{comment gray | specific templates for a project}} | ||
+ | · template-file.html {{comment gray |general template files for multiple projects or as fallback, if a project URL is called and the project-template folder doesn't exist yet}} | ||
├ /data {{comment gray| (data for import) }} | ├ /data {{comment gray| (data for import) }} | ||
− | └ /doc {{comment gray | (documentation) }} | + | └ /doc {{comment gray | (python + django documentation as [http://freemind.sourceforge.net/wiki/index.php/Main_Page freemind-mind-map]; current database schema)}} |
+ | |||
+ | === JSON of mobile bestimmung === | ||
+ | |||
+ | JSON data are retrieved by the projects label in saved in the data base, e.g. | ||
+ | * project.label “Häufige Schmetterlinge in Deutschland” → http://artenquiz.de/export_data/H%C3%A4ufige%20Schmetterlinge%20in%20Deutschland | ||
+ | |||
+ | == Artenquiz (Bayernflora) == | ||
+ | |||
+ | ; http://artenquiz.bayernflora.de/ : project web site | ||
+ | ; Schema diagram : http://diversityworkbench.net/Portal/DiversityDescriptions_Quiz_%28Artenquiz%29 contains the technical documentation | ||
+ | ; Identification module : does not work yet, needs rewrite to new database scheme of DiversityDescriptions | ||
+ | |||
+ | === Folder structure Artenquiz (Bayernflora) === | ||
+ | |||
+ | /var/www/v-diversitydescriptions/ | ||
+ | . | ||
+ | ├── django/ | ||
+ | · ├── diversitydescription/ | ||
+ | · · ├── accounts/ | ||
+ | · · · ├── backends.py | ||
+ | · · · └── view.py | ||
+ | · · ├── locale/ (translations) | ||
+ | · · · ├── de/ | ||
+ | · · · · └── LC_MESSAGES | ||
+ | · · · · ├── django.mo | ||
+ | · · · · └── django.po | ||
+ | · · · └── en/ | ||
+ | · · · └── LC_MESSAGES | ||
+ | · · · ├── django.mo | ||
+ | · · · └── django.po | ||
+ | · · ├── no_db_settings.py (debug settings) | ||
+ | · · ├── settings.py (project settings) | ||
+ | · · ├── quiz/ | ||
+ | · · · ├── admin.py (settings for admin site) | ||
+ | · · · ├── models.py (describing database model) | ||
+ | · · · ├── context_processors.py (serving static files) | ||
+ | · · · ├── management/ | ||
+ | · · · · └── commands/ | ||
+ | · · · ├── static (static files) | ||
+ | · · · · ├── css/ | ||
+ | · · · · ├── img/ | ||
+ | · · · · · ├── favicon.ico | ||
+ | · · · · · └── thumb/ (thumb images) | ||
+ | · · · · ├── js/ (jQuery, jQuery-UI) | ||
+ | · · · · ├── quiz.js (specific javascript for the quiz) | ||
+ | · · · · ├── register.js | ||
+ | · · · · ├── script.js (general javascript) | ||
+ | · · · · ├── style-bayernflorawiki.css (specific layout) | ||
+ | · · · · └── style.css (general layout) | ||
+ | · · · ├── templatetags/ (additional template tags) | ||
+ | · · · · └── tools.py | ||
+ | · · · ├── tools/ | ||
+ | · · · ├── urls.py (URL settings for quiz pages) | ||
+ | · · · └── views.py (viewing functions for pages defined in urls.py) | ||
+ | · · ├── register/ (registration) | ||
+ | · · · ├── forms.py | ||
+ | · · · ├── models.py | ||
+ | · · · ├── urls.py | ||
+ | · · · └── views.py | ||
+ | · · ├── report/ | ||
+ | · · · ├── models.py | ||
+ | · · · └── views.py | ||
+ | · · ├── templates/ (templates for all pages. Project-specific files must be in subfolders; subfolder corresponds to database project.code) | ||
+ | · · · ├── 404.html | ||
+ | · · · ├── 500.html | ||
+ | · · · ├── about.html | ||
+ | · · · ├── base.html | ||
+ | · · · ├── comma.html | ||
+ | · · · ├── heilpflanzen/ | ||
+ | · · · · └── panel_top_side.html | ||
+ | · · · ├── panel_right_side.html | ||
+ | · · · ├── panel_top_side.html | ||
+ | · · · ├── projects.html | ||
+ | · · · ├── quiz.html | ||
+ | · · · ├── welcome.html | ||
+ | · · · ├── registration/ | ||
+ | · · · · ├── … | ||
+ | · · · · └── user_top_menu.html | ||
+ | · · · └── report/ | ||
+ | · · · · ├── score_list.html | ||
+ | · · · · └── simple.html | ||
+ | · · ├── urls.py (URL settings for all pages) | ||
+ | · · └── wsgi.py | ||
+ | · └── manage.py | ||
+ | ├── doc/ | ||
+ | · ├── django.mm | ||
+ | · └── TODO | ||
+ | ├── robots.txt | ||
+ | ├── src/ | ||
+ | └── !This is the entire v-diversitydescriptions root, everything under svn control! | ||
+ | |||
+ | == Create a new project == | ||
+ | |||
+ | You can start a django app by: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | cd my-dj-project-folder | ||
+ | django-admin.py help startapp | ||
+ | django-admin.py startapp my-app-folder | ||
+ | # a it needs always __init__.py!!!! | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | To let a django application get to work, you need (in general) the following files: | ||
+ | __init__.py {{comment gray| (a 0Byte file needed by python) }} | ||
+ | [https://docs.djangoproject.com/en/1.6/topics/http/urls/ url.py] {{comment gray| (URL pattern definitions) }} | ||
+ | [https://docs.djangoproject.com/en/1.6/topics/db/models/ models.py] {{comment gray| (data-model definitions) }} | ||
+ | [https://docs.djangoproject.com/en/1.6/topics/http/views/ views.py] {{comment gray| (view layer: form request definitions, form processing) }} | ||
+ | [https://docs.djangoproject.com/en/1.6/topics/templates/ mytemplate.html] {{comment gray| (a template to process, see also [http://artenquiz.biowikifarm.net/admin/doc/ admin/doc/]) }} | ||
+ | |||
+ | == Create first model == | ||
+ | |||
+ | After setting the database a first autgenerated model can be obtained by | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | cd /artenquiz/django/artenbestimmung | ||
+ | python manage.py inspectdb | ||
+ | python manage.py inspectdb > models_autogenerated.py | ||
+ | mv --interactive models_autogenerated.py models.py | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | == Change translations == | ||
+ | (1) | ||
+ | <syntaxhighlight lang="html4strict"> | ||
+ | <!-- in /templates/mytemplate.html --> | ||
+ | {% trans "Short localised message" %} | ||
+ | {% blocktrans %}Localised message | ||
+ | spanning multiple lines{% endblocktrans %} | ||
+ | <!-- in /templates/mytemplate.html --> | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | (2) | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | # move to base directory of artenquiz app | ||
+ | cd /artenquiz/django/artenbestimmung | ||
+ | django-admin.py help makemessages # show the help | ||
+ | django-admin.py makemessages --no-wrap -l de --extension='.html,.txt' && django-admin.py makemessages --no-wrap -l en --extension='.html,.txt' | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | (3) | ||
+ | Add translations at least in | ||
+ | * <code>/artenbestimmung/locale/de/LC_MESSAGES/django.po</code> | ||
+ | * note that <code>#, fuzzy</code> becomes not translated, you may remove it and make sure you have an exact msgid or change it to <code>#, use-fuzzy</code> (?undocumented hack? because msgfmt has <code>msgfmt --use-fuzzy</code>) | ||
+ | |||
+ | (4) | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | # move to base directory of artenquiz app | ||
+ | cd /artenquiz/django/artenbestimmung | ||
+ | django-admin.py compilemessages | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | (5) (eventually) restart the server | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | sudo /etc/init.d/apache2 help | ||
+ | # [ ok ] Usage: /etc/init.d/apache2 {start|stop|graceful-stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean|status}. | ||
+ | sudo /etc/init.d/apache2 restart | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | == Install other modules == | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | sudo apt-get install python-xlrd # Excel sheet import | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | [[Category: Django]] | ||
+ | [[Category: Programming]] |
Latest revision as of 18:35, 12 January 2016
(See also Django-Installation and Django at a glance)
Contents
Artenquiz (Naturgucker)
This is running under:
- http://artenquiz.de/
- projects run for naturgucker, e.g. vögel, schmetterlinge, nachtrag_schmetterlinge
- http://artenquiz.de/bestimmung/
- Test for identification based on data of Artenquiz. Additional keys: http://artenquiz.de/bestimmung_testen/
- http://artenquiz.de/mobile_bestimmung/
- Test with additional keys: http://artenquiz.de/mobile_bestimmung_testen/
- http://artenquiz.de/admin/
- An admin interface for django users having a special admin account
- http://artenquiz.de/admin/doc/
- automatic documentation generated if Python's docutils
- https://biowikifarm.net/svn/artenquiz/
- Subversion directory (you must be e registered user for svn to get access)
Schema diagram at:
http://biowikifarm.net/v-artenquiz/django/doc/current_artenquiz_schema.png
http://biowikifarm.net/v-artenquiz/django/doc/current_artenquiz_schema.pdf
See also: Artenquiz AnyObject cleanup
Folder structure Artenquiz (Naturgucker)
/var/www/v-artenquiz/django/ · manage.py (manage file for the django app) ├ /artenbestimmung (projects artenquiz + artenbestimmung) · http://artenquiz.de/ · http://artenquiz.de/mobile_bestimmung/ · /accounts (backend for user_name or email login) · /artenquiz · /management · /commands (various import tools) · USAGE: · cd /path-to/artenbestimmung · python manage.py help importtaxa · python manage.py importtaxa /path-to/datafile.csv · /templatetags (custom tags used in templates) · /static (static CSS styles, JavaScript files, icons) · /tools (python script tools) · /local (generated localization files and defined English translations) · /register (definitions of registration) · /report (simple reports of descriptions for admins) · /templates (all django XHTML-templates and page texts) · /account_naturgucker login, registration for naturgucker.de · /edit in the future: templates for editing descriptions · /registration used for standard (Django) registration · /report reports for projects, e.g. score list · /vögel specific templates for project.code vögel. Name of folder should follow db entry of ‹project.code› · /‹project.code› specific templates for a project · template-file.html general template files for multiple projects or as fallback, if a project URL is called and the project-template folder doesn't exist yet ├ /data (data for import) └ /doc (python + django documentation as freemind-mind-map; current database schema)
JSON of mobile bestimmung
JSON data are retrieved by the projects label in saved in the data base, e.g.
- project.label “Häufige Schmetterlinge in Deutschland” → http://artenquiz.de/export_data/H%C3%A4ufige%20Schmetterlinge%20in%20Deutschland
Artenquiz (Bayernflora)
- http://artenquiz.bayernflora.de/
- project web site
- Schema diagram
- http://diversityworkbench.net/Portal/DiversityDescriptions_Quiz_%28Artenquiz%29 contains the technical documentation
- Identification module
- does not work yet, needs rewrite to new database scheme of DiversityDescriptions
Folder structure Artenquiz (Bayernflora)
/var/www/v-diversitydescriptions/ . ├── django/ · ├── diversitydescription/ · · ├── accounts/ · · · ├── backends.py · · · └── view.py · · ├── locale/ (translations) · · · ├── de/ · · · · └── LC_MESSAGES · · · · ├── django.mo · · · · └── django.po · · · └── en/ · · · └── LC_MESSAGES · · · ├── django.mo · · · └── django.po · · ├── no_db_settings.py (debug settings) · · ├── settings.py (project settings) · · ├── quiz/ · · · ├── admin.py (settings for admin site) · · · ├── models.py (describing database model) · · · ├── context_processors.py (serving static files) · · · ├── management/ · · · · └── commands/ · · · ├── static (static files) · · · · ├── css/ · · · · ├── img/ · · · · · ├── favicon.ico · · · · · └── thumb/ (thumb images) · · · · ├── js/ (jQuery, jQuery-UI) · · · · ├── quiz.js (specific javascript for the quiz) · · · · ├── register.js · · · · ├── script.js (general javascript) · · · · ├── style-bayernflorawiki.css (specific layout) · · · · └── style.css (general layout) · · · ├── templatetags/ (additional template tags) · · · · └── tools.py · · · ├── tools/ · · · ├── urls.py (URL settings for quiz pages) · · · └── views.py (viewing functions for pages defined in urls.py) · · ├── register/ (registration) · · · ├── forms.py · · · ├── models.py · · · ├── urls.py · · · └── views.py · · ├── report/ · · · ├── models.py · · · └── views.py · · ├── templates/ (templates for all pages. Project-specific files must be in subfolders; subfolder corresponds to database project.code) · · · ├── 404.html · · · ├── 500.html · · · ├── about.html · · · ├── base.html · · · ├── comma.html · · · ├── heilpflanzen/ · · · · └── panel_top_side.html · · · ├── panel_right_side.html · · · ├── panel_top_side.html · · · ├── projects.html · · · ├── quiz.html · · · ├── welcome.html · · · ├── registration/ · · · · ├── … · · · · └── user_top_menu.html · · · └── report/ · · · · ├── score_list.html · · · · └── simple.html · · ├── urls.py (URL settings for all pages) · · └── wsgi.py · └── manage.py ├── doc/ · ├── django.mm · └── TODO ├── robots.txt ├── src/ └── !This is the entire v-diversitydescriptions root, everything under svn control!
Create a new project
You can start a django app by:
cd my-dj-project-folder
django-admin.py help startapp
django-admin.py startapp my-app-folder
# a it needs always __init__.py!!!!
To let a django application get to work, you need (in general) the following files:
__init__.py (a 0Byte file needed by python) url.py (URL pattern definitions) models.py (data-model definitions) views.py (view layer: form request definitions, form processing) mytemplate.html (a template to process, see also admin/doc/)
Create first model
After setting the database a first autgenerated model can be obtained by
cd /artenquiz/django/artenbestimmung
python manage.py inspectdb
python manage.py inspectdb > models_autogenerated.py
mv --interactive models_autogenerated.py models.py
Change translations
(1)
<!-- in /templates/mytemplate.html -->
{% trans "Short localised message" %}
{% blocktrans %}Localised message
spanning multiple lines{% endblocktrans %}
<!-- in /templates/mytemplate.html -->
(2)
# move to base directory of artenquiz app
cd /artenquiz/django/artenbestimmung
django-admin.py help makemessages # show the help
django-admin.py makemessages --no-wrap -l de --extension='.html,.txt' && django-admin.py makemessages --no-wrap -l en --extension='.html,.txt'
(3) Add translations at least in
-
/artenbestimmung/locale/de/LC_MESSAGES/django.po
- note that
#, fuzzy
becomes not translated, you may remove it and make sure you have an exact msgid or change it to#, use-fuzzy
(?undocumented hack? because msgfmt hasmsgfmt --use-fuzzy
)
(4)
# move to base directory of artenquiz app
cd /artenquiz/django/artenbestimmung
django-admin.py compilemessages
(5) (eventually) restart the server
sudo /etc/init.d/apache2 help
# [ ok ] Usage: /etc/init.d/apache2 {start|stop|graceful-stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean|status}.
sudo /etc/init.d/apache2 restart
Install other modules
sudo apt-get install python-xlrd # Excel sheet import