diff --git a/README.md b/README.md
index 7a3a28e..600413e 100644
--- a/README.md
+++ b/README.md
@@ -24,13 +24,53 @@ Install the app in settings.py :
```python
INSTALLED_APPS = [
[...]
+ 'social_django',
+ 'crispy_forms',
'user_app',
]
```
-Then add the settings for `social-auth-app-django` package, for example :
+Specify static files and media files in settings :
```python
+STATIC_URL = '/static/'
+STATIC_ROOT = os.path.join(BASE_DIR, 'var/static/')
+MEDIA_URL = '/media/'
+MEDIA_ROOT = os.path.join(BASE_DIR, 'var/media/')
+```
+
+Then add the settings for `social-auth-app-django` and 'django-crispy-froms' packages, for example :
+
+```python
+CRISPY_TEMPLATE_PACK = 'bootstrap4'
+
+USER_APP_PROVIDERS = [
+ {
+ "provider": "google-oauth2",
+ "name": "Google",
+ "link": None,
+ "username": None,
+ },
+ {
+ "provider": "github",
+ "name": "Github",
+ "link": "https://github.com/{{ data.login }}",
+ "username": "{{ data.login }}",
+ },
+ {
+ "provider": "twitter",
+ "name": "Twitter",
+ "link": "https://twitter.com/{{ data.access_token.screen_name }}/",
+ "username": "@{{ data.access_token.screen_name }}",
+ },
+ {
+ "provider": "facebook",
+ "name": "Facebook",
+ "link": None,
+ "username": None,
+ },
+]
+
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'social_core.backends.google.GoogleOAuth2',
@@ -50,7 +90,7 @@ SOCIAL_AUTH_FACEBOOK_SECRET = ""
LOGIN_REDIRECT_URL = "/accounts/profile/"
SOCIAL_AUTH_URL_NAMESPACE = 'social'
-AUTH_PROFILE_MODULE = 'accounts.Profile'
+AUTH_PROFILE_MODULE = 'user_app.Profile'
SOCIAL_AUTH_PIPELINE = (
'social_core.pipeline.social_auth.social_details',
@@ -69,56 +109,32 @@ SOCIAL_AUTH_NEW_USER_REDIRECT_URL = '/accounts/profile/'
SOCIAL_AUTH_DISCONNECT_REDIRECT_URL = '/'
```
-And finally use the `base.html` template like :
-
-```html
-
-
-
-
-
-
-
- {% block title %}{% endblock title %}
- {% block head %}{% endblock head %}
-
-
-
-
-
-
-
-
-
- {% include 'nav.html' %}
-
- {% if success is True %}
-
- Les modifications ont bien été enregistrées.
-
- ×
-
-
- {% elif success is False %}
-
- Une erreur est survenue, les modifications n'ont pas été enregistrées.
-
- ×
-
-
- {% endif %}
- {% block content %}{% endblock content %}
-
-
-
-
+Then add the urls to the urlpattern of the project :
+
+```python
+from django.conf import settings
+from django.conf.urls.static import static
+#from django.contrib import admin
+from django.urls import path, include
+
+urlpatterns = [
+ #path('admin/', admin.site.urls),
+ path('accounts/', include('user_app.urls')),
+ path('accounts/', include('django.contrib.auth.urls')),
+ path('', include("social_django.urls", namespace="social")),
+] + static(
+ settings.STATIC_URL,
+ document_root=settings.STATIC_ROOT
+) + static(
+ settings.MEDIA_URL,
+ document_root=settings.MEDIA_ROOT
+)
+```
+
+And finally add the context_processor :
+
+```python
+user_app.context_processors.providers_settings
```
Then you have to migrate the database with `python3 manage.py migrate`
diff --git a/requirements.txt b/requirements.txt
index 1d73738..279c8ec 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,4 @@
-Django>=3.0.8
-Pillow>=7.2.0
\ No newline at end of file
+Django==3.0.8
+Pillow==7.2.0
+social-auth-app-django==4.0.0
+django-crispy-forms==1.9.2
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 0806b54..e5572bf 100644
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@
setuptools.setup(
name="django-user-app",
- version="0.0.5",
+ version="0.0.6",
license="MIT",
author="Couapy",
diff --git a/user_app/context_processors.py b/user_app/context_processors.py
new file mode 100644
index 0000000..04c715d
--- /dev/null
+++ b/user_app/context_processors.py
@@ -0,0 +1,7 @@
+from django.conf import settings
+
+
+def providers_settings(request):
+ return {
+ 'USER_APP_PROVIDERS': settings.USER_APP_PROVIDERS,
+ }
diff --git a/user_app/migrations/0001_initial.py b/user_app/migrations/0001_initial.py
index 648ad11..93350ac 100644
--- a/user_app/migrations/0001_initial.py
+++ b/user_app/migrations/0001_initial.py
@@ -1,6 +1,6 @@
# Generated by Django 3.0.4 on 2020-05-21 17:34
-import accounts.models
+import user_app.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
@@ -21,7 +21,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('biography', models.TextField(blank=True, help_text='300 caractères maximum.', max_length=300, null=True, verbose_name='Biographie')),
('website', models.URLField(blank=True, null=True, verbose_name='Site web')),
- ('avatar', models.ImageField(blank=True, null=True, upload_to=accounts.models.user_directory_path, verbose_name='Photo de profil')),
+ ('avatar', models.ImageField(blank=True, null=True, upload_to=user_app.models.user_directory_path, verbose_name='Photo de profil')),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
diff --git a/user_app/templates/base.html b/user_app/templates/base.html
new file mode 100644
index 0000000..4b699be
--- /dev/null
+++ b/user_app/templates/base.html
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+ {% block title %}{% endblock title %}
+ {% block head %}{% endblock head %}
+
+
+
+
+
+
+
+
+
+ {% include 'navbar.html' %}
+
+ {% if success is True %}
+
+ Les modifications ont bien été enregistrées.
+
+ ×
+
+
+ {% elif success is False %}
+
+ Une erreur est survenue, les modifications n'ont pas été enregistrées.
+
+ ×
+
+
+ {% endif %}
+ {% block content %}{% endblock content %}
+
+
+
+
\ No newline at end of file
diff --git a/user_app/templates/navbar.html b/user_app/templates/navbar.html
new file mode 100644
index 0000000..020f247
--- /dev/null
+++ b/user_app/templates/navbar.html
@@ -0,0 +1,30 @@
+{% load static %}
+
+ Django-Template
+
+
+
+
+
+
\ No newline at end of file
diff --git a/user_app/templates/registration/logged_out.html b/user_app/templates/registration/logged_out.html
new file mode 100644
index 0000000..2817b69
--- /dev/null
+++ b/user_app/templates/registration/logged_out.html
@@ -0,0 +1,16 @@
+{% extends 'base.html' %}
+{% load crispy_forms_tags %}
+
+
+{% block title %}Déconnecté{% endblock title %}
+
+{% block content %}
+Vous avez été déconnecté
+
+ Merci du temps que vous avez accordé à ce site. A bientôt !
+
+
+ Vous pouvez aussi vous reconnecter ici .
+ Ou simplement rester sur le site .
+
+{% endblock content %}
\ No newline at end of file
diff --git a/user_app/templates/registration/login.html b/user_app/templates/registration/login.html
new file mode 100644
index 0000000..73b333c
--- /dev/null
+++ b/user_app/templates/registration/login.html
@@ -0,0 +1,27 @@
+{% extends 'base.html' %}
+{% load crispy_forms_tags %}
+
+
+{% block title %}Connexion{% endblock title %}
+
+{% block content %}
+Connexion
+Se connecter avec un compte utilisateur
+
+Se connecter avec un service tiers
+
+{% endblock content %}
\ No newline at end of file
diff --git a/user_app/templates/registration/password_reset_complete.html b/user_app/templates/registration/password_reset_complete.html
new file mode 100644
index 0000000..ff1f3f9
--- /dev/null
+++ b/user_app/templates/registration/password_reset_complete.html
@@ -0,0 +1,11 @@
+{% extends 'base.html' %}
+
+
+{% block title %}Changement de mot de passe effectué{% endblock title %}
+
+{% block content %}
+Changement de mot de passe effectué
+
+ Votre mot de passe a bien été mis à jour. Vous pouvez vous connecter ici .
+
+{% endblock content %}
\ No newline at end of file
diff --git a/user_app/templates/registration/password_reset_confirm.html b/user_app/templates/registration/password_reset_confirm.html
new file mode 100644
index 0000000..d8d212b
--- /dev/null
+++ b/user_app/templates/registration/password_reset_confirm.html
@@ -0,0 +1,22 @@
+{% extends 'base.html' %}
+{% load crispy_forms_tags%}
+
+
+{% block title %}Mot de passe oublié{% endblock title %}
+
+{% block content %}
+{% if validlink %}
+Changement de mot de passe
+
+{% else %}
+
+ Le lien de réinitialisation du mot de passe n'était pas valide, peut-être parce qu'il a déjà été utilisé.
+ Veuillez demander une nouvelle réinitialisation du mot de passe.
+
+{% endif %}
+{% endblock %}
\ No newline at end of file
diff --git a/user_app/templates/registration/password_reset_done.html b/user_app/templates/registration/password_reset_done.html
new file mode 100644
index 0000000..ffc415c
--- /dev/null
+++ b/user_app/templates/registration/password_reset_done.html
@@ -0,0 +1,16 @@
+{% extends 'base.html' %}
+
+
+{% block title %}Message de réinitialisation du mot de passe envoyé{% endblock title %}
+
+{% block content %}
+Message de réinitialisation du mot de passe envoyé
+
+ Nous vous avons envoyé par courriel les instructions pour changer de mot de passe, pour autant qu’un compte existe avec
+ l’adresse que vous avez indiquée. Vous devriez recevoir rapidement ce message.
+
+
+ Si vous ne recevez pas de message, vérifiez que vous avez saisi l’adresse avec laquelle vous vous êtes enregistré et
+ contrôlez votre dossier de pourriels.
+
+{% endblock %}
\ No newline at end of file
diff --git a/user_app/templates/registration/password_reset_form.html b/user_app/templates/registration/password_reset_form.html
new file mode 100644
index 0000000..1b14854
--- /dev/null
+++ b/user_app/templates/registration/password_reset_form.html
@@ -0,0 +1,18 @@
+{% extends 'base.html' %}
+{% load crispy_forms_tags %}
+
+
+{% block title %}Mot de passe oublié{% endblock title %}
+
+{% block content %}
+Réinitialiser son mot de passe
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/user_app/templates/user_app/nav.html b/user_app/templates/user_app/nav.html
index 2adadfb..f933973 100644
--- a/user_app/templates/user_app/nav.html
+++ b/user_app/templates/user_app/nav.html
@@ -6,9 +6,9 @@
{% endif %}
{{ user.username }}
- Profil
- Utilisateur
- Mot de passe
- Connexions
+ Profil
+ Utilisateur
+ Mot de passe
+ Connexions
\ No newline at end of file
diff --git a/user_app/views.py b/user_app/views.py
index d8f0e8b..082bb37 100644
--- a/user_app/views.py
+++ b/user_app/views.py
@@ -1,3 +1,4 @@
+from django.conf import settings
from django.contrib import auth
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import (AdminPasswordChangeForm,
@@ -8,33 +9,6 @@
from .forms import ProfileForm, UserForm
-providers = [
- {
- "provider": "google-oauth2",
- "name": "Google",
- "link": None,
- "username": None,
- },
- {
- "provider": "github",
- "name": "Github",
- "link": "https://github.com/{{ data.login }}",
- "username": "{{ data.login }}",
- },
- {
- "provider": "twitter",
- "name": "Twitter",
- "link": "https://twitter.com/{{ data.access_token.screen_name }}/",
- "username": "@{{ data.access_token.screen_name }}",
- },
- {
- "provider": "facebook",
- "name": "Facebook",
- "link": None,
- "username": None,
- },
-]
-
def index(request):
return HttpResponseRedirect(reverse("user_app:profile"))
@@ -119,7 +93,7 @@ def connections(request):
services = []
- for provider in providers:
+ for provider in settings.USER_APP_PROVIDERS:
try:
login = user.social_auth.get(provider=provider["provider"])
except UserSocialAuth.DoesNotExist: