From a0c32890a9ecb113df76c31051fe662f4208654c Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby Date: Mon, 12 Aug 2019 00:30:29 +0200 Subject: [PATCH] add basic profile page --- apps/member/models.py | 2 ++ apps/member/urls.py | 5 +++-- apps/member/views.py | 8 +++++++- templates/base.html | 2 +- templates/member/profile_detail.html | 19 +++++++++++++++++++ 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 templates/member/profile_detail.html diff --git a/apps/member/models.py b/apps/member/models.py index 90fb7839..70f8ccf7 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -48,6 +48,8 @@ class Profile(models.Model): verbose_name = _('user profile') verbose_name_plural = _('user profile') + def get_absolute_url(self): + return reverse('user_detail',args=(self.pk,)) class Club(models.Model): """ diff --git a/apps/member/urls.py b/apps/member/urls.py index b5a972a3..7b179b56 100644 --- a/apps/member/urls.py +++ b/apps/member/urls.py @@ -10,8 +10,9 @@ from . import views app_name = 'member' urlpatterns = [ - path('signup/',views.SignUp.as_view(),name="signup"), + path('signup/',views.UserCreateView.as_view(),name="signup"), path('club/',views.ClubListView.as_view(),name="club_list"), path('club//',views.ClubDetailView.as_view(),name="club_detail"), - path('club/create/',views.ClubCreateView.as_view(),name="club_create") + path('club/create/',views.ClubCreateView.as_view(),name="club_create"), + path('user/',views.UserDetailView.as_view(),name="user_detail") ] diff --git a/apps/member/views.py b/apps/member/views.py index 55fd2fc2..37c47212 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -13,7 +13,7 @@ from django.urls import reverse_lazy from .models import Profile, Club from .forms import ProfileForm, ClubForm -class SignUp(CreateView): +class UserCreateView(CreateView): """ Une vue pour inscrire un utilisateur et lui créer un profile @@ -39,6 +39,11 @@ class SignUp(CreateView): return super().form_valid(form) + +class UserDetailView(LoginRequiredMixin,DetailView): + model = Profile + + class ClubCreateView(LoginRequiredMixin,CreateView): """ Create Club @@ -55,6 +60,7 @@ class ClubListView(LoginRequiredMixin,ListView): """ model = Club form_class = ClubForm + class ClubDetailView(LoginRequiredMixin,DetailView): """ """ diff --git a/templates/base.html b/templates/base.html index 8e6a2b0e..87f292ad 100644 --- a/templates/base.html +++ b/templates/base.html @@ -48,7 +48,7 @@ {{ user.username }}