diff --git a/apps/member/forms.py b/apps/member/forms.py index 9747afd0..e024ee84 100644 --- a/apps/member/forms.py +++ b/apps/member/forms.py @@ -6,7 +6,7 @@ from django.contrib.auth.forms import UserChangeForm, UserCreationForm from django.contrib.auth.models import User from django import forms -from .models import Profile +from .models import Profile, Club class ProfileForm(forms.ModelForm): """ @@ -16,3 +16,8 @@ class ProfileForm(forms.ModelForm): model = Profile fields = '__all__' exclude = ['user'] + +class ClubForm(forms.ModelForm): + class Meta: + model = Club + fields ='__all__' diff --git a/apps/member/models.py b/apps/member/models.py index d2fe75c2..90fb7839 100644 --- a/apps/member/models.py +++ b/apps/member/models.py @@ -7,7 +7,7 @@ from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver from django.utils.translation import gettext_lazy as _ - +from django.urls import reverse class Profile(models.Model): """ @@ -93,6 +93,9 @@ class Club(models.Model): def __str__(self): return self.name + def get_absolute_url(self): + return reverse('member:club_detail', args=(self.pk,)) + class Role(models.Model): """ diff --git a/apps/member/urls.py b/apps/member/urls.py index dbb71374..b5a972a3 100644 --- a/apps/member/urls.py +++ b/apps/member/urls.py @@ -10,5 +10,8 @@ from . import views app_name = 'member' urlpatterns = [ - path('signup/',views.SignUp.as_view(),name="signup") + path('signup/',views.SignUp.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") ] diff --git a/apps/member/views.py b/apps/member/views.py index cc2d2b3f..55fd2fc2 100644 --- a/apps/member/views.py +++ b/apps/member/views.py @@ -5,12 +5,13 @@ from django.contrib.auth.mixins import LoginRequiredMixin from django.utils.translation import gettext_lazy as _ -from django.views.generic.edit import CreateView +from django.views.generic import CreateView, ListView, DetailView from django.http import HttpResponseRedirect from django.contrib.auth.forms import UserCreationForm from django.urls import reverse_lazy -from .models import Profile -from .forms import ProfileForm + +from .models import Profile, Club +from .forms import ProfileForm, ClubForm class SignUp(CreateView): """ @@ -36,3 +37,25 @@ class SignUp(CreateView): user_profile.user = user user_profile.save() return super().form_valid(form) + + +class ClubCreateView(LoginRequiredMixin,CreateView): + """ + Create Club + """ + model = Club + form_class = ClubForm + + def form_valid(self,form): + return super().form_valid(form) + +class ClubListView(LoginRequiredMixin,ListView): + """ + List TransactionsTemplates + """ + model = Club + form_class = ClubForm +class ClubDetailView(LoginRequiredMixin,DetailView): + """ + """ + model = Club diff --git a/templates/base.html b/templates/base.html index 49a46dc8..8e6a2b0e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -31,7 +31,7 @@ Consos