diff --git a/ofu_app/apps/registration/urls.py b/ofu_app/apps/registration/urls.py index 224ec8b..3713395 100644 --- a/ofu_app/apps/registration/urls.py +++ b/ofu_app/apps/registration/urls.py @@ -2,7 +2,8 @@ from django.conf.urls import url from apps.registration import views as core_views urlpatterns = [ - url(r'^$', core_views.signup, name='signup'), + url(r'^$', core_views.account_view, name='account'), + url(r'^signup/$', core_views.signup, name='signup'), url(r'^account_activation_sent/$', core_views.account_activation_sent, name='account_activation_sent'), url(r'^activate/(?P[0-9A-Za-z_\-]+)/(?P[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', core_views.activate, name='activate'), diff --git a/ofu_app/apps/registration/views.py b/ofu_app/apps/registration/views.py index b3131c5..72b3a75 100644 --- a/ofu_app/apps/registration/views.py +++ b/ofu_app/apps/registration/views.py @@ -11,6 +11,7 @@ from django.utils.encoding import force_text from django.utils.http import urlsafe_base64_decode from django.core.mail import send_mail from django.shortcuts import HttpResponse +from apps.food.models import UserRating def signup(request): @@ -56,3 +57,16 @@ def activate(request, uidb64, token): def account_activation_sent(request): return render(request, 'registration/account_activation_sent.jinja', {}) + + +def account_view(request): + if request.user.is_authenticated: + user = request.user + food_ratings = UserRating.objects.filter(user=user).order_by('food__name') + + return render(request, 'registration/account_view.jinja', + {'name': user.username, 'email': user.email, 'date_joined': user.date_joined, + 'food_ratings': food_ratings, 'first_name': user.first_name, 'last_name': user.last_name, + 'last_login': user.last_login}) + else: + return HttpResponse(status=404) diff --git a/ofu_app/ofu_app/__pycache__/settings.cpython-35.pyc b/ofu_app/ofu_app/__pycache__/settings.cpython-35.pyc index 6899f04..194379e 100644 Binary files a/ofu_app/ofu_app/__pycache__/settings.cpython-35.pyc and b/ofu_app/ofu_app/__pycache__/settings.cpython-35.pyc differ diff --git a/ofu_app/templates/base.jinja b/ofu_app/templates/base.jinja index ea13208..0228788 100644 --- a/ofu_app/templates/base.jinja +++ b/ofu_app/templates/base.jinja @@ -44,7 +44,16 @@
{% if request.user.is_authenticated() %} - + {% else %} {% endif %} diff --git a/ofu_app/templates/registration/account_activation_invalid.jinja b/ofu_app/templates/registration/account_activation_invalid.jinja index 3a963c7..2f25926 100644 --- a/ofu_app/templates/registration/account_activation_invalid.jinja +++ b/ofu_app/templates/registration/account_activation_invalid.jinja @@ -3,9 +3,15 @@ {% block headline %}

BaStA Login

{% endblock %} {% block content %} -
-

Fail

-

Your user account couldn't be activated

-

Please try it again or inform the Administrator.

+
+

{{ name }}

+

E-Mail: {{ email }}

+
+

Date Joined: {{ date_joined }}

+
+

Your Food Ratings:

+ {% for rating in food_ratings %} +

{{ rating.food.name }}: {{ rating.rating }}

+ {% endfor %}
{% endblock %} \ No newline at end of file diff --git a/ofu_app/templates/registration/account_view.jinja b/ofu_app/templates/registration/account_view.jinja new file mode 100644 index 0000000..41e91b7 --- /dev/null +++ b/ofu_app/templates/registration/account_view.jinja @@ -0,0 +1,30 @@ +{% extends 'base.jinja' %} + +{% block headline %}

Account

{% endblock %} + +{% block content %} +
+
+
+

{{ name }}

+

Vorname: {{ first_name }}

+

Nachname: {{ last_name }}

+

E-Mail: {{ email }}

+
+
+
+
+

Your Food Ratings:

+ {% for rating in food_ratings %} +

{{ rating.food.name }}: {{ rating.rating }}

+ {% endfor %} +
+
+
+
+
+

Date joined: {{ date_joined.strftime("%d.%m.%Y") }}

+

Last Login: {{ last_login.strftime("%d.%m.%Y") }}

+
+
+{% endblock %} \ No newline at end of file