mirror of
https://gitlab.crans.org/bde/nk20
synced 2024-11-26 18:37:12 +00:00
add basic club management
This commit is contained in:
parent
4dead7edf2
commit
3cce57695d
@ -6,7 +6,7 @@ from django.contrib.auth.forms import UserChangeForm, UserCreationForm
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django import forms
|
from django import forms
|
||||||
|
|
||||||
from .models import Profile
|
from .models import Profile, Club
|
||||||
|
|
||||||
class ProfileForm(forms.ModelForm):
|
class ProfileForm(forms.ModelForm):
|
||||||
"""
|
"""
|
||||||
@ -16,3 +16,8 @@ class ProfileForm(forms.ModelForm):
|
|||||||
model = Profile
|
model = Profile
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
exclude = ['user']
|
exclude = ['user']
|
||||||
|
|
||||||
|
class ClubForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = Club
|
||||||
|
fields ='__all__'
|
||||||
|
@ -7,7 +7,7 @@ from django.db import models
|
|||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
class Profile(models.Model):
|
class Profile(models.Model):
|
||||||
"""
|
"""
|
||||||
@ -93,6 +93,9 @@ class Club(models.Model):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return reverse('member:club_detail', args=(self.pk,))
|
||||||
|
|
||||||
|
|
||||||
class Role(models.Model):
|
class Role(models.Model):
|
||||||
"""
|
"""
|
||||||
|
@ -10,5 +10,8 @@ from . import views
|
|||||||
|
|
||||||
app_name = 'member'
|
app_name = 'member'
|
||||||
urlpatterns = [
|
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/<int:pk>/',views.ClubDetailView.as_view(),name="club_detail"),
|
||||||
|
path('club/create/',views.ClubCreateView.as_view(),name="club_create")
|
||||||
]
|
]
|
||||||
|
@ -5,12 +5,13 @@
|
|||||||
|
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.utils.translation import gettext_lazy as _
|
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.http import HttpResponseRedirect
|
||||||
from django.contrib.auth.forms import UserCreationForm
|
from django.contrib.auth.forms import UserCreationForm
|
||||||
from django.urls import reverse_lazy
|
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):
|
class SignUp(CreateView):
|
||||||
"""
|
"""
|
||||||
@ -36,3 +37,25 @@ class SignUp(CreateView):
|
|||||||
user_profile.user = user
|
user_profile.user = user
|
||||||
user_profile.save()
|
user_profile.save()
|
||||||
return super().form_valid(form)
|
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
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
<a class="nav-link" href="#"><i class="fa fa-coffee"></i>Consos</a>
|
<a class="nav-link" href="#"><i class="fa fa-coffee"></i>Consos</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
<a class="nav-link" href="#"><i class="fa fa-users"></i> Membres</a>
|
<a class="nav-link" href="{% url 'member:club_list' %}"><i class="fa fa-users"></i> Membres</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
<a class="nav-link" href="#"><i class="fa fa-calendar"></i> Activités</a>
|
<a class="nav-link" href="#"><i class="fa fa-calendar"></i> Activités</a>
|
||||||
|
6
templates/member/club_detail.html
Normal file
6
templates/member/club_detail.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% block content %}
|
||||||
|
<p><a class="btn btn-default" href="{% url 'member:club_list' %}">Clubs</a></p>
|
||||||
|
<h5>{{ object.name }}</h5>
|
||||||
|
{% endblock %}
|
11
templates/member/club_form.html
Normal file
11
templates/member/club_form.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% block content %}
|
||||||
|
<p><a class="btn btn-default" href="{% url 'note:template_list' %}">Template Listing</a></p>
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{form|crispy}}
|
||||||
|
<button class="btn btn-primary" type="submit">Submit</button>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
17
templates/member/club_list.html
Normal file
17
templates/member/club_list.html
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<td>ID</td>
|
||||||
|
<td>name</td>
|
||||||
|
</tr>
|
||||||
|
{% for object in object_list %}
|
||||||
|
<tr>
|
||||||
|
<td>{{object.pk}}</td>
|
||||||
|
<td><a href="{{ object.get_absolute_url }}"> {{ object.name }}</a></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<a class="btn btn-primary" href="{% url 'member:club_create' %}">New Club</a>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user