Commit 3cce5769 authored by Pierre-antoine Comby's avatar Pierre-antoine Comby

add basic club management

parent 4dead7ed
Pipeline #1429 passed with stage
in 2 minutes and 49 seconds
......@@ -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__'
......@@ -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):
"""
......
......@@ -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/<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.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
......@@ -31,7 +31,7 @@
<a class="nav-link" href="#"><i class="fa fa-coffee"></i>Consos</a>
</li>
<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 class="nav-item active">
<a class="nav-link" href="#"><i class="fa fa-calendar"></i> Activités</a>
......
{% 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 %}
{% 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 %}
{% 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 %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment