Merge branch 'cart' of git.2li.ch:ibz/web_AI-5 into cart

* 'cart' of git.2li.ch:ibz/web_AI-5:
  some corrections to comply with PEP8
  remove the inline pictures from the Article admin page
  add surround the submit button with a P Tag
  add another use case
  fix a typo
  add a entry about testing
  correct the bib entries
  correct spelling mistakes
  wrap the jinja template in a sexylisting environment
  remove todo tag
  add empty lines for better visibiliy
  remove whitespace
  add a source for fixtures
This commit is contained in:
Ivan Hörler 2018-02-18 21:59:04 +01:00
commit 29e99e49c0
6 changed files with 140 additions and 64 deletions

View File

@ -32,17 +32,16 @@ class PictureInline(admin.StackedInline):
class OptionAdmin(admin.ModelAdmin):
model = Option
list_display = ('name', 'description',)
readonly_fields = ('name','description',)
readonly_fields = ('name', 'description',)
def get_actions(self, request):
#Disable delete
# Disable delete
actions = super(OptionAdmin, self).get_actions(request)
del actions['delete_selected']
return actions
def has_delete_permission(self, request, obj=None):
#Disable delete
# Disable delete
return False
def has_add_permission(self, request):
@ -53,10 +52,6 @@ class UserAdmin(BaseUserAdmin):
inlines = (PersonInline,)
class ArticleAdmin(admin.ModelAdmin):
inlines = (PictureInline,)
class OrderPositionInline(admin.StackedInline):
model = OrderPosition
can_delete = False
@ -81,7 +76,7 @@ class OrderOfGoodsAdmin(admin.ModelAdmin):
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
admin.site.register(Article, ArticleAdmin)
admin.site.register(Article)
admin.site.register(Order, OrderAdmin)
admin.site.register(Picture, PictureAdmin)
admin.site.register(City)

View File

@ -7,11 +7,13 @@
<p><b>Status:</b> {{ article.status }}</p>
<p><b>Price:</b> {{ article.price_in_chf }} {{ currency_name }}</p>
{% if user.is_authenticated %}
<p>
<form id="amount" action="" method="POST" novalidate>
{{ amount.as_p }}
<input type="submit" value="Add to Cart" />
{% csrf_token %}
</form>
</p>
{% else %}
<p> please login to fill your basket...</p>
{% endif %}

View File

@ -1,7 +1,7 @@
@misc{djangoextensions,
month = {{01}},
note = {{\url{https://github.com/django-extensions/django-extensions}}},
Urldate = {{2018-01-05}},
Urldate = {2018-01-05},
author = {django-extensions},
title = {{Django Extensions Source Code}},
year = {2018},
@ -10,7 +10,7 @@
@book{djangobook,
Note = {{\url{https://djangobook.com/}}},
publisher = {{leanpub.com}},
Urldate = {{2018-01-08}},
Urldate = {2018-01-08},
author = {Nigel George},
title = {{Mastering Django: Core}},
year = {2016},
@ -19,7 +19,7 @@
@misc{removeadd,
month = {{01}},
note = {{\url{https://stackoverflow.com/a/21454467/7723859}}},
Urldate = {{2018-01-15}},
Urldate = {2018-01-15},
author = {Avinash Garg},
title = {{How to remove Add button in Django admin, for specific Model?}},
year = {2014},
@ -28,7 +28,7 @@
@misc{removedelete,
month = {{08}},
note = {{\url{https://stackoverflow.com/a/7031093/7723859}}},
Urldate = {{2018-01-15}},
Urldate = {2018-01-15},
author = {Jonathan R.},
title = {{In Django Admin how do I disable the Delete link}},
year = {2011},
@ -37,7 +37,7 @@
@misc{readonly,
month = {{09}},
note = {{\url{https://stackoverflow.com/a/46124159/7723859}}},
Urldate = {{2018-01-15}},
Urldate = {2018-01-15},
author = {gdlmx},
title = {{Display a model field as readonly in Django admin}},
year = {2017},
@ -46,7 +46,7 @@
@misc{timezone,
month = {{07}},
note = {{\url{https://stackoverflow.com/a/38239673}}},
Urldate = {{2018-01-15}},
Urldate = {2018-01-15},
author = {Antoine Pinsard},
title = {{Django: timezone.now vs timezone.now()}},
year = {2016},
@ -55,7 +55,7 @@
@misc{usermodel,
month = {{07}},
note = {{\url{https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html}}},
Urldate = {{2018-01-15}},
Urldate = {2018-01-15},
author = {Vitor Freitas},
title = {{How to Extend Django User Model}},
year = {2016},
@ -64,7 +64,7 @@
@misc{djangogirls,
month = {{10}},
note = {{\url{https://tutorial.djangogirls.org/en/}}},
Urldate = {{2018-01-15}},
Urldate = {2018-01-15},
author = {DjangoGirls},
title = {{Django Girls Tutorial}},
year = {2017},
@ -73,7 +73,7 @@
@misc{images,
month = {{08}},
note = {{\url{https://stackoverflow.com/a/1235542}}},
Urldate = {{2018-01-15}},
Urldate = {2018-01-15},
author = {steve},
title = {{How do I include image files in Django templates?}},
year = {2009},
@ -82,7 +82,7 @@
@misc{djangodoc,
month = {{01}},
note = {{\url{https://docs.djangoproject.com/en/1.11/}}},
Urldate = {{2018-01-15}},
Urldate = {2018-01-15},
author = {Django Foundation},
title = {{Django documentation}},
year = {2018},
@ -91,7 +91,7 @@
@misc{upload,
month = {{12}},
note = {{\url{https://stackoverflow.com/a/8542030}}},
Urldate = {{2018-01-15}},
Urldate = {2018-01-15},
author = {Akseli Pal{\'{e}}n},
title = {{Need a minimal Django file upload example [closed]}},
year = {2011},
@ -100,7 +100,7 @@
@misc{tree,
month = {{11}},
note = {{\url{https://stackoverflow.com/a/8177290/7723859}}},
Urldate = {{2018-01-15}},
Urldate = {2018-01-15},
author = {Acorn},
title = {{Django hierarchical model list}},
year = {2011},
@ -109,9 +109,19 @@
@misc{snb,
month = {{01}},
note = {{\url{https://www.snb.ch/selector/de/mmr/exfeed/rss}}},
Urldate = {{2018-02-01}},
Urldate = {2018-02-01},
author = {Schweizerische National Bank},
title = {{SNB Devisenkurse}},
year = {2018},
}
@misc{fixtures,
month = {{02}},
note = {{\url{https://docs.djangoproject.com/en/2.0/howto/initial-data/}}},
Url = {{https://docs.djangoproject.com/en/2.0/howto/initial-data/}},
Urldate = {2018-02-18},
author = {Django Foundation},
title = {{Providing initial data for models}},
year = {2018},
}

View File

@ -9,7 +9,7 @@
@misc{ansible,
month = {{01}},
note = {{\url{https://www.ansible.com/}}},
Urldate = {{2018-01-03}},
Urldate = {2018-01-03},
author = {Ansible, Red Hat},
title = {{Ansible - IT Automation Software}},
year = {2018},
@ -26,7 +26,7 @@
@misc{latex,
month = {{01}},
note = {{\url{https://www.latex-project.org/}}},
Urldate = {{2018-01-03}},
Urldate = {2018-01-03},
author = {Leslie Lamport},
title = {{LaTeX - A document preparation system}},
year = {2018},
@ -35,7 +35,7 @@
@misc{debian,
month = {{01}},
note = {{\url{https://www.debian.org/}}},
Urldate = {{2018-01-03}},
Urldate = {2018-01-03},
author = {Debian Project},
title = {{Debian {--} The Universal Operating System}},
year = {2018},
@ -44,7 +44,7 @@
@misc{gplv3,
month = {{01}},
note = {{\url{https://www.gnu.org/licenses/gpl-3.0.en.html}}},
Urldate = {{2018-01-03}},
Urldate = {2018-01-03},
author = {Free Software Foundation},
title = {{GPLv3}},
year = {2018},
@ -53,7 +53,7 @@
@misc{usecase,
month = {{01}},
note = {{\url{https://de.wikipedia.org/wiki/Anwendungsfall}}},
Urldate = {{2018-01-04}},
Urldate = {2018-01-04},
author = {Wikipedia},
title = {{Anwendungsfall {--} Wikipedia}},
year = {2018},
@ -62,7 +62,7 @@
@misc{usecasediagramm,
month = {{01}},
note = {{\url{https://de.wikipedia.org/wiki/Anwendungsfalldiagramm}}},
Urldate = {{2018-01-04}},
Urldate = {2018-01-04},
author = {Wikipedia},
title = {{Anwendungsfalldiagramm {--} Wikipedia}},
year = {2018},
@ -71,7 +71,7 @@
@misc{django,
month = {{01}},
note = {{\url{https://www.djangoproject.com/}}},
Urldate = {{2018-01-04}},
Urldate = {2018-01-04},
author = {Django Project},
title = {{Django Framework}},
year = {2018},
@ -80,7 +80,7 @@
@misc{apache,
month = {{01}},
note = {{\url{https://httpd.apache.org/}}},
Urldate = {{2018-01-04}},
Urldate = {2018-01-04},
author = {Apache Foundation},
title = {{The Apache HTTP Server Project}},
year = {2018},
@ -89,7 +89,7 @@
@misc{mariadb,
month = {{01}},
note = {{\url{https://mariadb.org/}}},
Urldate = {{2018-01-04}},
Urldate = {2018-01-04},
author = {Mariadb Foundation},
title = {{MariaDB}},
year = {2018},
@ -98,7 +98,7 @@
@misc{emacs,
month = {{01}},
note = {{\url{https://www.gnu.org/software/emacs/}}},
Urldate = {{2018-01-04}},
Urldate = {2018-01-04},
author = {GNU Project},
title = {{GNU Emacs}},
year = {2018},
@ -107,7 +107,7 @@
@misc{atom,
month = {{01}},
note = {{\url{https://atom.io/}}},
Urldate = {{2018-01-04}},
Urldate = {2018-01-04},
author = {GitHub Inc.},
title = {{Atom Editor}},
year = {2018},
@ -116,7 +116,7 @@
@misc{mariadbgov,
month = {{01}},
note = {{\url{https://mariadb.org/about/governance/}}},
Urldate = {{2018-01-04}},
Urldate = {2018-01-04},
author = {MariaDB Foundation},
title = {{Governance}},
year = {2018},
@ -125,7 +125,7 @@
@misc{inkscape,
month = {{01}},
note = {{\url{https://inkscape.org/en/}}},
Urldate = {{2018-01-05}},
Urldate = {2018-01-05},
author = {Inkscape Developers},
title = {{Inkscape}},
year = {2018},
@ -134,7 +134,7 @@
@misc{orgmode,
month = {{01}},
note = {{\url{https://orgmode.org/}}},
Urldate = {{2018-01-05}},
Urldate = {2018-01-05},
author = {Carsten Dominik},
title = {{Org mode for Emacs}},
year = {2018},
@ -143,7 +143,7 @@
@misc{virtualbox,
month = {{01}},
note = {{\url{https://www.virtualbox.org/}}},
Urldate = {{2018-01-05}},
Urldate = {2018-01-05},
author = {Oracle},
title = {{Oracle VM VirtualBox}},
year = {2018},
@ -152,7 +152,7 @@
@misc{dia,
month = {{02}},
note = {{\url{http://dia-installer.de/}}},
Urldate = {{2018-02-06}},
Urldate = {2018-02-06},
author = {Macke, Steffen},
title = {{Dia draws your structured diagrams: Free Windows, Mac OS X and Linux version of the popular open source program}},
year = {2018},

View File

@ -12,7 +12,7 @@
Day = {20},
Month = {09},
Note = {\url{https://www.swr.de/blog/1000antworten/antwort/10380/woher-kommt-der-name-didgeridoo/}},
Urldate = {2011-09-11},
Urldate = {2018-02-17},
author = {Desirée Kuthe},
title = {Wie kommt das Didgeridoo zu seinem Namen?},
year = {2011},

View File

@ -336,21 +336,22 @@ Am ende des Projekts die nicht lauffähigen teile ausgrenzen. :-)
* Projektmanagement
** Organigram
#+CAPTION: Organigram
#+NAME: fig:Organigram
#+BEGIN_EXPORT latex
\begin{tikzpicture}[
auto,
node distance = 0.4cm,
auto,
node distance = 0.4cm,
thick,
every node/.style = {
rectangle,
font = \sffamily,
rectangle,
font = \sffamily,
white,
top color = green!90!black,
top color = green!90!black,
bottom color = green!60!black,
text width = 2.4cm,
align = center,
text width = 2.4cm,
align = center,
minimum height = 1cm
}
]
@ -361,11 +362,11 @@ Am ende des Projekts die nicht lauffähigen teile ausgrenzen. :-)
\node (AZ) [below = of CV] {\textbf{AZ}\\Andreas Zweili};
\node (IH) [left = of AZ] {\textbf{IH}\\Ivan Hörler};
\draw [green!60!black,thick]
(CH) -- (Mitte)
(CH) -- (Mitte)
(CV) -- (Mitte) -- (Unten) -| (IH)
(Unten) -| (IH)
(Unten) -| (AZ);
\end{tikzpicture}
\end{tikzpicture}
#+END_EXPORT
** Projektstrukturplan
** Varianten
@ -709,7 +710,7 @@ Die Klassen Diagramme haben wir mit der Django Erweiterung
"Django-Extensions"\footcite{django_extensions} erstellt.
Django-Extensions ist freie Software unter der MIT Lizenz.
** TODO Spezifikation
** Spezifikation
*** User Stories
User Stories sind eine in Alltagssprache geschriebenen
@ -816,7 +817,7 @@ aus, die Use Cases mit den Nummern wurden dabei im Detail ausgearbeitet:
| - [[Checkout][3.2 Checkout]] | - [[Bestellung %C3%A4ndern/korrigieren][7.0 Bestellung ändern/korrigieren (Admin Funktion)]] |
| - [[User Passwort %C3%A4ndern][4.0 User Passwort ändern (Admin Funktion)]] | - Bestellung löschen (Admin Funktion) |
| - [[Artikel erfassen][5.0 Artikel erfassen (Admin Funktion)]] | - [[max_pictures Option anpassen][6.0 max_pictures Option anpassen (Admin Funktion)]] |
| - Artikel ändern (Admin Funktion) | - max_pictures Option deaktivieren (Admin Funktion) |
| - [[Artikel %C3%A4ndern][5.1 Artikel ändern (Admin Funktion)]] | - max_pictures Option deaktivieren (Admin Funktion) |
| - Artikel löschen (Admin Funktion) | - User erfassen (Admin Funktion) |
| - Materialbestellung erfassen (Admin Funktion) | - User/Personen Daten ändern (Admin Funktion) |
| - Materialbestellung ändern/korrigieren (Admin Funktion) | - User löschen (Admin Funktion) |
@ -1155,7 +1156,7 @@ aus, die Use Cases mit den Nummern wurden dabei im Detail ausgearbeitet:
|---------------------+--------------------------------|
| *Preconditions* | Account mit Administrationsrechten vorhanden. |
|---------------------+--------------------------------|
| *Postconditions* | Der Artikel wir im Webshop angezeigt. |
| *Postconditions* | Der Artikel wird im Webshop angezeigt. |
|---------------------+--------------------------------|
| *Normal Flow* | 1. Der Administrator loggt sich unter https://didgeridoo.ml/admin ein. |
| | 2. Admin klickt neben "Articles" auf "+ Add". |
@ -1174,6 +1175,7 @@ aus, die Use Cases mit den Nummern wurden dabei im Detail ausgearbeitet:
| *Notes* | - |
|---------------------+--------------------------------|
| *UC History* | 1.0 Darft erstellt durch AZ |
| | 1.1 AZ Rechtschreibung korrigiert |
|---------------------+--------------------------------|
| *Author* | A. Zweili & I. Hörler |
|---------------------+--------------------------------|
@ -1181,6 +1183,48 @@ aus, die Use Cases mit den Nummern wurden dabei im Detail ausgearbeitet:
|---------------------+--------------------------------|
#+LATEX:}
***** Artikel ändern
#+LATEX:{\footnotesize
#+CAPTION: 5.1 Artikel ändern
#+ATTR_LATEX: :environment longtable :align |>{\columncolor[HTML]{EFEFEF}}p{.25\textwidth}|p{.7\textwidth}| :placement [H]
#+NAME: tab:create_article
|---------------------+--------------------------------|
| | <30> |
| *Identifier + Name* | 5.1 Artikel ändern |
|---------------------+--------------------------------|
| *Description* | Ein Administrator ändert den Status eines Artikels. |
|---------------------+--------------------------------|
| *Actors* | Verwaltung |
|---------------------+--------------------------------|
| *Status* | Freigeben |
|---------------------+--------------------------------|
| *Includes* | - |
|---------------------+--------------------------------|
| *Trigger* | Ein Artikel wird vorübergehend aus dem Sortiment genommen. |
|---------------------+--------------------------------|
| *Preconditions* | Account mit Administrationsrechten vorhanden. |
|---------------------+--------------------------------|
| *Postconditions* | Der Artikel wird im Webshop nicht mehr angezeigt. |
|---------------------+--------------------------------|
| *Normal Flow* | 1. Der Administrator loggt sich unter https://didgeridoo.ml/admin ein. |
| | 2. Admin wählte in der Kategorie Articles einen "Artikel" aus. |
| | 3. Der Admin ändert den Artikel Status von "active" auf "hidden". |
| | 4. Klickt unten rechts auf "Save". |
| | 5. Die Website speichert den Artikel in der Datenbank. |
|---------------------+--------------------------------|
| *Alternative Flow* | - |
|---------------------+--------------------------------|
| *Notes* | - |
|---------------------+--------------------------------|
| *UC History* | 1.0 Darft erstellt durch AZ |
|---------------------+--------------------------------|
| *Author* | A. Zweili & I. Hörler |
|---------------------+--------------------------------|
| *Date* | 18.02.2018 |
|---------------------+--------------------------------|
#+LATEX:}
***** max_pictures Option anpassen
#+LATEX:{\footnotesize
@ -1592,32 +1636,35 @@ die Datenbank mit zusätzlichen Anfragen belastet werden kann.
*** Frontend Umsetzung
Die Umsetztung des Frontends mittels Django integrierter Template
funktionen sind geprägt vom einstmalig eigenständigen Jinja Template
framework das auch in Python programmiert wurde. Mittlerweile ist es
integrierter bestandteil vom django Framework.
Dieses snipet erklärt deren Nutzung:
#+CAPTION: jinja Code Block
#+BEGIN_SRC python
Funktionen sind geprägt vom einstmalig eigenständigen Jinja Template
Framework das auch in Python programmiert wurde. Mittlerweile ist es
integrierter Bestandteil vom Django Framework. Dieses Snippet erklärt
deren Nutzung:
#+BEGIN_EXPORT latex
\begin{sexylisting}{Jinja Code Block}
{% extends 'base.html' %} --> Dieser codeblock wird im base.html eingefügt.
{% block title %}Memberlist{% endblock %} --> Titel wird in den tag
title eingefügt.
{% block content %} --> wird in den block mit dem tag ''content'' eingefügt.
<ul> --> standard unordered List item von HTML.
{% for user in users %} --> schleifenkopf
{% for user in users %} --> schleifenkopf
<li>
<a href="{{ user.url }}">{{ user.username }}</a> --> für
jeden Benutzer wird eine listitem erstellt und der Username als text eingefügt.
</li>
</li>
{% endfor %}
</ul>
{% endblock %}
#+END_SRC
\end{sexylisting}
#+END_EXPORT
*** Backend Umsetzung
Django ist ein Modelbasiertes Framework das die Programmierung der
Django ist ein modelbasiertes Framework das die Programmierung der
Datenbank gleich selbst regelt. Dadurch lässt sich backendseitig
durchgängig in Python arbeiten.
Die Umsetzung gliedert sich vereinfacht in 3 Bereiche:
durchgängig in Python arbeiten. Die Umsetzung gliedert sich
vereinfacht in 3 Bereiche:
1. Einem Frontend dass für den Benutzer gemacht ist und das mehrere
submodule wie Cathegories oder Wahrenkorb beinhaltet.
2. Ein Backend welches zum Bearbeiten/Erstellen von Produkten dient.
@ -1625,7 +1672,29 @@ Die Umsetzung gliedert sich vereinfacht in 3 Bereiche:
** Testing
*** Fixtures
Um die Funktionalität des Webshops sicherzustellen haben wir
Die Applikation kontinuierlich gemäss den Testfällen unter [[Testfälle]]
getestet und geprüft. Auch sehr hilfreich war das Admin Interface von
Django. Damit konnten wir die Modells sehr gut auf ihre Funktionalität
überprüfen bevor wir sie im Frontend verwendeten.
*Fixtures*
Django hat ein Funktion\footcite{fixtures} genannt "Fixtures" welche
es einem erlaubt fixe Daten in die Datenbank zu schreiben. Dabei
werden die Daten in YAML Syntax in eine .yaml Datei geschrieben und
mittels folgendem Befehl dann in die Datenbank geladen:
#+BEGIN_EXPORT latex
\begin{sexylisting}{Fixtures in Datenbank laden.}
python3 /vagrant/django/didgeridoo/manage.py loaddata webshop
\end{sexylisting}
#+END_EXPORT
Wir haben diese Funktion verwendet um Testdaten in der Datenbank zu
speichern. Somit mussten wir etwa nicht von Hand Artikel oder User
erfassen. Zumindest nicht mehr sobald wir sicher waren das die
dazugehörige Funktionen korrekt funktionieren.
#+LATEX:\newpage
#+LATEX:\begin{landscape}