start activity view and urls

This commit is contained in:
Pierre-antoine Comby 2020-03-01 17:16:38 +01:00
parent f1cedc902e
commit d5f718fbba
5 changed files with 77 additions and 2 deletions

15
apps/activity/urls.py Normal file
View File

@ -0,0 +1,15 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from django.urls import path
from . import views
app_name = 'activity'
urlpatterns = [
path('', views.ActivityListView.as_view(),name='activity_list'),
path('<int:pk>/', views.ActivityDetailView.as_view(),name='activity_detail'),
path('<int:pk>/entry/', views.ActivityEntryView.as_view(),name='activity_entry'),
path('<int:pk>/update/', views.ActivityUpdateView.as_view(),name='activity_update'),
path('new/', views.ActivityCreateView.as_view(),name='activity_create'),
]

33
apps/activity/views.py Normal file
View File

@ -0,0 +1,33 @@
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
from dal import autocomplete
from django.contrib.auth.mixins import LoginRequiredMixin
from django.db.models import Q
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django.views.generic import CreateView, DetailView,\
ListView, UpdateView, TemplateView
from django_tables2.views import SingleTableView
from .models import Activity, ActivityType
class ActivityCreateView(CreateView):
model = Activity
template_name = 'activity_create.html'
class ActivityListView(SingleTableView):
model = Activity
template_name = 'activity_list.html'
class ActivityDetailView(DetailView):
model = Activity
template_name = 'activty_detail.html'
class ActivityUpdateView(UpdateView):
model = Activity
template_name = 'activity_update.html'
class ActivityEntryView(TemplateView):
pass

View File

@ -11,10 +11,11 @@ urlpatterns = [
# Include project routers
path('note/', include('note.urls')),
path('accounts/', include('member.urls')),
path('activity/', include('activity.urls')),
# Include Django Contrib and Core routers
path('i18n/', include('django.conf.urls.i18n')),
path('accounts/', include('member.urls')),
path('accounts/', include('django.contrib.auth.urls')),
path('admin/doc/', include('django.contrib.admindocs.urls')),
path('admin/', admin.site.urls),

View File

@ -0,0 +1,26 @@
{% extends "base.html" %}
{% load render_table from django_tables2 %}
{% load i18n crispy_forms_tags%}
{% block content %}
<a class="btn btn-primary" href="{% url 'activity:activity_create' %}">{% trans 'New activity' %}</a>
<div class="row">
<div id="replaceable-content" class="col-6">
{% render_table table %}
</div>
</div>
{% endblock %}
{% block extrajavascript %}
<script type="text/javascript">
$(document).ready(function($) {
$(".table-row").click(function() {
window.document.location = $(this).data("href");
});
});
</script>
{% endblock %}

View File

@ -73,7 +73,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<a class="nav-link" href="{% url 'member:club_list' %}"><i class="fa fa-users"></i> Clubs</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#"><i class="fa fa-calendar"></i> Activités</a>
<a class="nav-link" href="{% url 'activity:activity_list' %}"><i class="fa fa-calendar"></i> Activités</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="{% url 'note:template_list' %}"><i class="fa fa-coffee"></i> Bouton</a>