Skip to content

Commit

Permalink
Merge pull request #99 from rl-institut/release/v0.6.0
Browse files Browse the repository at this point in the history
Release/v0.6.0
  • Loading branch information
henhuy authored Mar 6, 2020
2 parents c3b783b + 34d985f commit 95fc739
Show file tree
Hide file tree
Showing 70 changed files with 3,699 additions and 138 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project tries to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.0] - 2020-02-19
### Added
- Environment page.
- english language support
- Score can be saved and shared via link.
- Score animation on dashboard.

### Changed
- leaf footer links
- onboard animation speed (slowed down)
- answer page layout fixed
- dashboard icons
- trophy icons
- removed back arrow on dashboard

## [0.5.0] - 2020-02-05
### Added
- Legal page
Expand All @@ -17,9 +32,9 @@ and this project tries to adhere to [Semantic Versioning](https://semver.org/spe
### Added
- Category finished page.
- Score animation when answering a question.
- Environment page.
- "Choose your route" text.
- Popup at first-time-visit on dashboard.

### Changed
- Color variables (BVG original)

Expand Down
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# In Windows, this must be set to your system time zone.
TIME_ZONE = "UTC"
# https://docs.djangoproject.com/en/dev/ref/settings/#language-code
LANGUAGE_CODE = "en-us"
LANGUAGE_CODE = "de"
# https://docs.djangoproject.com/en/dev/ref/settings/#site-id
SITE_ID = 1
# https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n
Expand Down
35 changes: 21 additions & 14 deletions config/urls.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
from django.conf import settings
from django.urls import include, path
from django.conf.urls.i18n import i18n_patterns
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic import TemplateView
from django.views import defaults as default_views

urlpatterns = [
path(
"datenschutz",
TemplateView.as_view(template_name="pages/dgstvo.html"),
name="dgstvo",
),
path(
"kontakt",
TemplateView.as_view(template_name="pages/contact.html"),
name="contact",
),
path(settings.ADMIN_URL, admin.site.urls),
path("", include("e_metrobus.navigation.urls", namespace="navigation")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns = (
[
path(
"datenschutz",
TemplateView.as_view(template_name="pages/dgstvo.html"),
name="dgstvo",
),
path(
"kontakt",
TemplateView.as_view(template_name="pages/contact.html"),
name="contact",
),
path(settings.ADMIN_URL, admin.site.urls),
]
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+ i18n_patterns(
path("", include("e_metrobus.navigation.urls", namespace="navigation")),
prefix_default_language=False
)
)

if settings.DEBUG:
# This allows the error pages to be debugged during development, just visit
Expand Down
22 changes: 22 additions & 0 deletions e_metrobus/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 2.2.5 on 2020-01-22 13:00

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Score',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('score', models.IntegerField()),
('hash', models.CharField(max_length=32)),
],
),
]
Empty file.
9 changes: 6 additions & 3 deletions e_metrobus/navigation/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
OFFSET = 1
SIZE = MARGIN - 2 * OFFSET
TEXTSIZE = 5
TROPHY_OFFSET = 20

Sizes = namedtuple("Sizes", ["margin", "offset", "size", "textsize"])

Expand Down Expand Up @@ -70,16 +71,18 @@ def get_mobility_figure(values):
color = "black"
fig.add_layout_image(
go.layout.Image(
source=f"/static/images/icons/i_{icon}_{color}.svg", x=i, y=-sizes.offset
source=f"/static/images/icons/i_{icon}_{color}.svg",
x=i,
y=-sizes.offset,
)
)
# Trophy Icons:
for i in range(3):
fig.add_layout_image(
go.layout.Image(
source="/static/images/icons/i_trophy.svg",
source=f"/static/images/icons/i_trophy_{i+1}_{'black' if i == 2 else 'gray'}.svg",
x=i,
y=values[i] + sizes.textsize + sizes.size + sizes.offset,
y=values[i] + sizes.textsize + sizes.size + sizes.offset + TROPHY_OFFSET,
)
)

Expand Down
13 changes: 11 additions & 2 deletions e_metrobus/navigation/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import math
from collections import namedtuple

ELLIPSE_RADIUS = 43
ELLIPSE_X_OFFSET = 7
Expand All @@ -22,7 +22,16 @@ def __init__(self, share):
angle = share * 2 * math.pi
self.large = 0 if share <= 0.5 else 1
self.x = ELLIPSE_X_OFFSET + ELLIPSE_RADIUS + ELLIPSE_RADIUS * math.sin(angle)
self.y = ELLIPSE_Y_OFFSET + ELLIPSE_RADIUS + ELLIPSE_RADIUS * math.cos(angle + math.pi)
self.y = (
ELLIPSE_Y_OFFSET
+ ELLIPSE_RADIUS
+ ELLIPSE_RADIUS * math.cos(angle + math.pi)
)

def __str__(self):
return f"M {ELLIPSE_RADIUS + ELLIPSE_X_OFFSET} {ELLIPSE_Y_OFFSET} A {ELLIPSE_RADIUS} {ELLIPSE_RADIUS} 0 {self.large} 1 {self.x} {self.y}"


Consumption = namedtuple(
"Consumption", ["distance", "fuel", "co2", "nitrogen", "fine_dust"]
)
16 changes: 16 additions & 0 deletions e_metrobus/navigation/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

import uuid
from django.db import models

from e_metrobus.navigation import questions


class Score(models.Model):
score = models.IntegerField()
hash = models.CharField(max_length=32)

@classmethod
def save_score(cls, session):
score = cls(score=questions.get_total_score(session), hash=uuid.uuid4().hex)
score.save()
return score
6 changes: 3 additions & 3 deletions e_metrobus/navigation/questions.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[e_metrobus]
label = "E-Metrobus"
icon = "images/icons/Icon_E_Bus_Front.svg"
icon = "images/icons/i_e_bus_black.svg"
[[questions]]
[[[loading_time]]]
label = "Ladezeiten"
Expand Down Expand Up @@ -35,7 +35,7 @@

[politics]
label = "Politk"
icon = "images/icons/i_info_black.svg"
icon = "images/icons/i_government_black.svg"
[[questions]]
[[[ebus_time]]]
label = "Zeitplan"
Expand All @@ -46,7 +46,7 @@

[personal]
label = "Ich"
icon = "images/icons/i_user_black.svg"
icon = "images/icons/i_person_black.svg"
[[questions]]
[[[advantages]]]
label = "Vorteile"
Expand Down
14 changes: 14 additions & 0 deletions e_metrobus/navigation/questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from configobj import ConfigObj

from django.conf import settings
from django.utils.translation import gettext as _


QUESTION_TEMPLATE_FOLDER = "questions"
Expand All @@ -24,13 +25,19 @@ class Question:
template: str
category: str

def get_label(self):
return _(self.label)


@dataclass
class Category:
label: str
icon: str
questions: Dict[str, Question]

def get_label(self):
return _(self.label)


question_config = ConfigObj(
os.path.join(settings.APPS_DIR, "navigation", "questions.cfg")
Expand Down Expand Up @@ -113,3 +120,10 @@ def get_question_from_name(question_name):
if question_name in category.questions:
return category.questions[question_name]
raise KeyError(f'Question "{question_name}" not found.')


def all_questions_answered(session):
for category in QUESTIONS:
if get_category_done_share(category, session) != 1.0:
return False
return True
11 changes: 11 additions & 0 deletions e_metrobus/navigation/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
path("route/", view=views.RouteView.as_view(), name="route"),
path("display_route/", view=views.DisplayRouteView.as_view(), name="display_route"),
path("comparison/", view=views.ComparisonView.as_view(), name="comparison"),
path("environment/", view=views.EnvironmentView.as_view(), name="environment"),
path("dashboard/", view=views.DashboardView.as_view(), name="dashboard"),
path("quiz/<str:category>/", view=views.QuestionView.as_view(), name="question"),
path("answer/", view=views.AnswerView.as_view(), name="answer"),
Expand All @@ -16,6 +17,16 @@
view=views.CategoryFinishedView.as_view(),
name="category_finished",
),
path(
"finished/",
view=views.QuizFinishedView.as_view(),
name="finished_quiz",
),
path(
"score/<str:hash>/",
view=views.QuizFinishedView.as_view(),
name="score",
),
path(
"questions_as_text/",
view=views.QuestionsAsTextView.as_view(),
Expand Down
Loading

0 comments on commit 95fc739

Please sign in to comment.