From 380e38519b4398c1a5cb2e7019bb3e29c237596d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 6 Oct 2019 19:59:07 +0200 Subject: [PATCH] New app: clubs - Clubs will be used both by the cof and the bds app. - For now, they are only visible in development. --- .gitlab-ci.yml | 4 +-- clubs/__init__.py | 0 clubs/admin.py | 5 ++++ clubs/apps.py | 5 ++++ clubs/migrations/0001_initial.py | 46 ++++++++++++++++++++++++++++++++ clubs/migrations/__init__.py | 0 clubs/models.py | 16 +++++++++++ clubs/views.py | 0 cof/settings/dev.py | 2 +- cof/settings/prod.py | 2 +- setup.cfg | 3 ++- 11 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 clubs/__init__.py create mode 100644 clubs/admin.py create mode 100644 clubs/apps.py create mode 100644 clubs/migrations/0001_initial.py create mode 100644 clubs/migrations/__init__.py create mode 100644 clubs/models.py create mode 100644 clubs/views.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0f150d07..a8f27b8f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -52,9 +52,9 @@ linters: - pip install --upgrade black isort flake8 script: - black --check . - - isort --recursive --check-only --diff bda bds cof events gestioncof kfet petitscours provisioning shared utils + - isort --recursive --check-only --diff bda bds clubs cof events gestioncof kfet petitscours provisioning shared utils # Print errors only - - flake8 --exit-zero bda bds cof events gestioncof kfet petitscours provisioning shared utils + - flake8 --exit-zero bda bds clubs cof events gestioncof kfet petitscours provisioning shared utils cache: key: linters paths: diff --git a/clubs/__init__.py b/clubs/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/clubs/admin.py b/clubs/admin.py new file mode 100644 index 00000000..8ff3cd00 --- /dev/null +++ b/clubs/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin + +from clubs.models import Club + +admin.site.register(Club) diff --git a/clubs/apps.py b/clubs/apps.py new file mode 100644 index 00000000..a7d4b8e0 --- /dev/null +++ b/clubs/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ClubsConfig(AppConfig): + name = "clubs" diff --git a/clubs/migrations/0001_initial.py b/clubs/migrations/0001_initial.py new file mode 100644 index 00000000..689b5d33 --- /dev/null +++ b/clubs/migrations/0001_initial.py @@ -0,0 +1,46 @@ +# Generated by Django 2.2.6 on 2019-10-06 17:57 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [migrations.swappable_dependency(settings.AUTH_USER_MODEL)] + + operations = [ + migrations.CreateModel( + name="Club", + fields=[ + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "name", + models.CharField( + max_length=1000, unique=True, verbose_name="nom du club" + ), + ), + ( + "description", + models.TextField(blank=True, verbose_name="description"), + ), + ( + "respos", + models.ManyToManyField( + blank=True, + to=settings.AUTH_USER_MODEL, + verbose_name="responsables du club", + ), + ), + ], + ) + ] diff --git a/clubs/migrations/__init__.py b/clubs/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/clubs/models.py b/clubs/models.py new file mode 100644 index 00000000..e407bbfd --- /dev/null +++ b/clubs/models.py @@ -0,0 +1,16 @@ +from django.contrib.auth import get_user_model +from django.db import models +from django.utils.translation import gettext_lazy as _ + +User = get_user_model() + + +class Club(models.Model): + name = models.CharField(_("nom du club"), max_length=1000, unique=True) + description = models.TextField(_("description"), blank=True) + respos = models.ManyToManyField( + User, verbose_name=_("responsables du club"), blank=True + ) + + def __str__(self): + return self.name diff --git a/clubs/views.py b/clubs/views.py new file mode 100644 index 00000000..e69de29b diff --git a/cof/settings/dev.py b/cof/settings/dev.py index db7a52cb..d287eab8 100644 --- a/cof/settings/dev.py +++ b/cof/settings/dev.py @@ -17,7 +17,7 @@ if TESTING: # As long as these apps are not ready for production, they are only available # in development mode -INSTALLED_APPS += ["events", "bds"] +INSTALLED_APPS += ["events", "bds", "clubs"] # --- diff --git a/cof/settings/prod.py b/cof/settings/prod.py index 8db28958..748abe73 100644 --- a/cof/settings/prod.py +++ b/cof/settings/prod.py @@ -13,7 +13,7 @@ DEBUG = False ALLOWED_HOSTS = ["cof.ens.fr", "www.cof.ens.fr", "dev.cof.ens.fr"] if TESTING: - INSTALLED_APPS.append("events") + INSTALLED_APPS += ["events", "clubs"] STATIC_ROOT = os.path.join( os.path.dirname(os.path.dirname(BASE_DIR)), "public", "gestion", "static" diff --git a/setup.cfg b/setup.cfg index 7695596d..100ddb22 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,6 +2,7 @@ source = bda bds + clubs cof events gestioncof @@ -36,7 +37,7 @@ default_section = THIRDPARTY force_grid_wrap = 0 include_trailing_comma = true known_django = django -known_first_party = bda,bds,cof,events,gestioncof,kfet,petitscours,shared,utils +known_first_party = bda,bds,clubs,cof,events,gestioncof,kfet,petitscours,shared,utils line_length = 88 multi_line_output = 3 not_skip = __init__.py