From d5f718fbba47e9f804a7704b0a01b0dc89082daf Mon Sep 17 00:00:00 2001 From: Pierre-antoine Comby <comby@crans.org> Date: Sun, 1 Mar 2020 17:16:38 +0100 Subject: [PATCH] start activity view and urls --- apps/activity/urls.py | 15 ++++++++++++ apps/activity/views.py | 33 +++++++++++++++++++++++++++ note_kfet/urls.py | 3 ++- templates/activity/activity_list.html | 26 +++++++++++++++++++++ templates/base.html | 2 +- 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 apps/activity/urls.py create mode 100644 apps/activity/views.py create mode 100644 templates/activity/activity_list.html diff --git a/apps/activity/urls.py b/apps/activity/urls.py new file mode 100644 index 00000000..125ac7af --- /dev/null +++ b/apps/activity/urls.py @@ -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'), +] diff --git a/apps/activity/views.py b/apps/activity/views.py new file mode 100644 index 00000000..7ea61d2e --- /dev/null +++ b/apps/activity/views.py @@ -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 + diff --git a/note_kfet/urls.py b/note_kfet/urls.py index 303e229a..79b6dba6 100644 --- a/note_kfet/urls.py +++ b/note_kfet/urls.py @@ -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), diff --git a/templates/activity/activity_list.html b/templates/activity/activity_list.html new file mode 100644 index 00000000..7f682d4c --- /dev/null +++ b/templates/activity/activity_list.html @@ -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 %} diff --git a/templates/base.html b/templates/base.html index 6814bedf..c0d4c43b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -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> -- GitLab