diff --git a/readMe.md b/README.md
similarity index 66%
rename from readMe.md
rename to README.md
index b50408a..0362734 100644
--- a/readMe.md
+++ b/README.md
@@ -33,3 +33,10 @@ Si il y a des erreurs BLACK, on peut lancer black pour linter le code :
```bash
black .
```
+
+## Architecture de l'application
+
+Les différentes applications Django créées sont :
+
+- Order, pour gérer tout ce qui tourne autour des commandes
+- Accounts, pour gérer la création de comptes. Pour la connexion, la déconnexion et le changement de mot de passe, on utilise l'application auth intégrée à Django.
diff --git a/conftest.py b/conftest.py
new file mode 100644
index 0000000..92a7127
--- /dev/null
+++ b/conftest.py
@@ -0,0 +1,3 @@
+pytest_plugins = [
+ "la_chariotte.helpers.fixtures",
+]
diff --git a/dev-requirements.txt b/dev-requirements.txt
index fb0b229..f9cc9c8 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -12,6 +12,12 @@ black==23.3.0
# via pytest-black
build==0.10.0
# via pip-tools
+chardet==4.0.0
+ # via diff-cover
+ # via flake8-black
+build==0.10.0
+ # via pip-tools
+ # via pytest-black
chardet==4.0.0
# via diff-cover
click==8.1.3
@@ -32,6 +38,16 @@ inflect==3.0.2
# via
# diff-cover
# jinja2-pluralize
+flake8==6.0.0
+ # via flake8-black
+flake8-black==0.3.6
+ # via la-chariotte (pyproject.toml)
+importlib-metadata==6.1.0
+ # via inflect
+inflect==3.0.2
+ # via
+ # diff-cover
+ # jinja2-pluralize
iniconfig==2.0.0
# via pytest
isort==5.12.0
@@ -44,6 +60,8 @@ jinja2-pluralize==0.3.0
# via diff-cover
markupsafe==2.1.2
# via jinja2
+mccabe==0.7.0
+ # via flake8
mypy-extensions==1.0.0
# via black
packaging==23.0
@@ -63,6 +81,13 @@ pluggy==1.0.0
# pytest
psycopg2-binary==2.9.6
# via la-chariotte (pyproject.toml)
+pygments==2.14.0
+ # via diff-cover
+ # via la-chariotte (pyproject.toml)
+pycodestyle==2.10.0
+ # via flake8
+pyflakes==3.0.1
+ # via flake8
pygments==2.14.0
# via diff-cover
pyproject-hooks==1.0.0
@@ -95,6 +120,14 @@ tomli==2.0.1
# pytest
wheel==0.40.0
# via pip-tools
+zipp==3.15.0
+ # via importlib-metadata
+ # coverage
+ # flake8-black
+ # pyproject-hooks
+ # pytest
+wheel==0.40.0
+ # via pip-tools
zipp==3.15.0
# via importlib-metadata
diff --git a/la_chariotte/accounts/__init__.py b/la_chariotte/accounts/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/la_chariotte/accounts/apps.py b/la_chariotte/accounts/apps.py
new file mode 100644
index 0000000..299b83e
--- /dev/null
+++ b/la_chariotte/accounts/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class AccountsConfig(AppConfig):
+ default_auto_field = "django.db.models.BigAutoField"
+ name = "la_chariotte.accounts"
diff --git a/la_chariotte/accounts/migrations/__init__.py b/la_chariotte/accounts/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/la_chariotte/accounts/models.py b/la_chariotte/accounts/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/la_chariotte/accounts/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/la_chariotte/accounts/templates/registration/login.html b/la_chariotte/accounts/templates/registration/login.html
new file mode 100644
index 0000000..dacc4b9
--- /dev/null
+++ b/la_chariotte/accounts/templates/registration/login.html
@@ -0,0 +1,14 @@
+{% extends 'base.html' %}
+
+{% block title %}Connexion{% endblock %}
+
+{% block content %}
+
Connexion
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/la_chariotte/accounts/templates/registration/signup.html b/la_chariotte/accounts/templates/registration/signup.html
new file mode 100644
index 0000000..c049920
--- /dev/null
+++ b/la_chariotte/accounts/templates/registration/signup.html
@@ -0,0 +1,13 @@
+{% extends 'base.html' %}
+
+{% block title %}Créer un compte{% endblock %}
+
+{% block content %}
+Créer un compte
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/la_chariotte/accounts/urls.py b/la_chariotte/accounts/urls.py
new file mode 100644
index 0000000..ebf4479
--- /dev/null
+++ b/la_chariotte/accounts/urls.py
@@ -0,0 +1,9 @@
+from django.urls import include, path
+
+from . import views
+
+app_name = "accounts"
+urlpatterns = [
+ path("inscription/", views.SignUpView.as_view(), name="signup"),
+ path("", include("django.contrib.auth.urls")),
+]
diff --git a/la_chariotte/accounts/views.py b/la_chariotte/accounts/views.py
new file mode 100644
index 0000000..bf85312
--- /dev/null
+++ b/la_chariotte/accounts/views.py
@@ -0,0 +1,9 @@
+from django.contrib.auth.forms import UserCreationForm
+from django.urls import reverse_lazy
+from django.views import generic
+
+
+class SignUpView(generic.CreateView):
+ form_class = UserCreationForm
+ success_url = reverse_lazy("accounts:login")
+ template_name = "registration/signup.html"
diff --git a/la_chariotte/helpers/fixtures.py b/la_chariotte/helpers/fixtures.py
new file mode 100644
index 0000000..2aa45d3
--- /dev/null
+++ b/la_chariotte/helpers/fixtures.py
@@ -0,0 +1,18 @@
+import pytest
+
+
+@pytest.fixture
+def client_log(client, django_user_model):
+ username = "test@user.fr"
+ password = "azertypassword"
+ user = django_user_model.objects.create_user(username=username, password=password)
+ client.login(username=username, password=password)
+ return client
+
+
+@pytest.fixture
+def other_user(django_user_model):
+ username = "other@user.fr"
+ password = "azertypassword"
+ user = django_user_model.objects.create_user(username=username, password=password)
+ return user
diff --git a/la_chariotte/order/migrations/0011_alter_groupedorder_orga.py b/la_chariotte/order/migrations/0011_alter_groupedorder_orga.py
new file mode 100644
index 0000000..626ff35
--- /dev/null
+++ b/la_chariotte/order/migrations/0011_alter_groupedorder_orga.py
@@ -0,0 +1,22 @@
+# Generated by Django 4.2 on 2023-04-18 13:08
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ("order", "0010_rename_grouped_order_groupedorder"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="groupedorder",
+ name="orga",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
+ ),
+ ),
+ ]
diff --git a/la_chariotte/order/models.py b/la_chariotte/order/models.py
index 4c4881f..7422571 100644
--- a/la_chariotte/order/models.py
+++ b/la_chariotte/order/models.py
@@ -1,10 +1,15 @@
+from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone
class GroupedOrder(models.Model):
- name = models.CharField(max_length=100, null=True) # optionnal
- orga = models.CharField(max_length=100) # a changer, utiliser ForeignKey de user
+ name = models.CharField(
+ max_length=100, null=True, verbose_name="Titre de la commande"
+ ) # optionnal
+ orga = models.ForeignKey(
+ User, on_delete=models.CASCADE, verbose_name="Organisateur·ice"
+ )
delivery_date = models.DateField("Date de livraison")
deadline = models.DateTimeField("Date limite de commande")
diff --git a/la_chariotte/order/templates/order/grouped_order_detail.html b/la_chariotte/order/templates/order/grouped_order_detail.html
index 09613de..8ad777f 100644
--- a/la_chariotte/order/templates/order/grouped_order_detail.html
+++ b/la_chariotte/order/templates/order/grouped_order_detail.html
@@ -11,7 +11,19 @@
Organisateur·ice : {{ grouped_order.orga }}
Date de livraison : {{ grouped_order.delivery_date }}
- les produits disponibles pour cette commande groupée :
+ {% if not user.is_authenticated %}
+ Vous êtes l'organisateur·ice de cette commande groupée ?
+
+ Connectez-vous pour accéder à la page de gestion
+
+ {% endif %}
+
+ {% if user == grouped_order.orga %}
+
+ Page de gestion de la commande groupée
+ {% endif %}
+
+ les produits disponibles pour cette commande groupée :
{% for item in grouped_order.item_set.all %}
diff --git a/la_chariotte/order/templates/order/grouped_order_orga.html b/la_chariotte/order/templates/order/grouped_order_overview.html
similarity index 90%
rename from la_chariotte/order/templates/order/grouped_order_orga.html
rename to la_chariotte/order/templates/order/grouped_order_overview.html
index 0cee30b..7a8f469 100644
--- a/la_chariotte/order/templates/order/grouped_order_orga.html
+++ b/la_chariotte/order/templates/order/grouped_order_overview.html
@@ -29,6 +29,6 @@
{% endfor %}
- Retour à la page de commande
+ Retour à la page de commande