diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ad8ffa1 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1ca34b9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/python-django-models-authentication.iml b/.idea/python-django-models-authentication.iml new file mode 100644 index 0000000..0a43029 --- /dev/null +++ b/.idea/python-django-models-authentication.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/3/e/3ea505836db8ef76dd1c89a43cfc6ee4cd79a896 b/.idea/sonarlint/issuestore/3/e/3ea505836db8ef76dd1c89a43cfc6ee4cd79a896 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/4/7/47a7a1b2d8d2ffd5801773581068eea7d0641a89 b/.idea/sonarlint/issuestore/4/7/47a7a1b2d8d2ffd5801773581068eea7d0641a89 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/4/e/4ebd502ddcb3a834fc75a6e83253a06a39b7cbf5 b/.idea/sonarlint/issuestore/4/e/4ebd502ddcb3a834fc75a6e83253a06a39b7cbf5 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/7/9/793c96990c42260b726e24a2e7d4ca5327df621c b/.idea/sonarlint/issuestore/7/9/793c96990c42260b726e24a2e7d4ca5327df621c new file mode 100644 index 0000000..3f4c1b6 --- /dev/null +++ b/.idea/sonarlint/issuestore/7/9/793c96990c42260b726e24a2e7d4ca5327df621c @@ -0,0 +1,3 @@ + +MWeb:TableWithoutCaptionCheck" Add a description to this table.( +? Web:S5256"%Add "" headers to this "".( \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/7/e/7ebb6dc32a2768a7e73ce1c83409f9c85bd4ad6a b/.idea/sonarlint/issuestore/7/e/7ebb6dc32a2768a7e73ce1c83409f9c85bd4ad6a new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/d/a/da7c237b85a69c00a9ab8c189bf63e22070fcac3 b/.idea/sonarlint/issuestore/d/a/da7c237b85a69c00a9ab8c189bf63e22070fcac3 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/d/e/de4aed7861d3af94a475cf71eb09ad41efc673ef b/.idea/sonarlint/issuestore/d/e/de4aed7861d3af94a475cf71eb09ad41efc673ef new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/f/1/f121007a966dcbe0e6d77b6ca09948108f3edfbb b/.idea/sonarlint/issuestore/f/1/f121007a966dcbe0e6d77b6ca09948108f3edfbb new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb new file mode 100644 index 0000000..cff7a0a --- /dev/null +++ b/.idea/sonarlint/issuestore/index.pb @@ -0,0 +1,17 @@ + +> +users/admin.py,3/e/3ea505836db8ef76dd1c89a43cfc6ee4cd79a896 +J +users/templates/login.html,7/9/793c96990c42260b726e24a2e7d4ca5327df621c +; + .report.xml,4/7/47a7a1b2d8d2ffd5801773581068eea7d0641a89 +D +blogproj/settings.py,4/e/4ebd502ddcb3a834fc75a6e83253a06a39b7cbf5 +? +users/models.py,f/1/f121007a966dcbe0e6d77b6ca09948108f3edfbb += + users/urls.py,7/e/7ebb6dc32a2768a7e73ce1c83409f9c85bd4ad6a +@ +blogproj/urls.py,d/e/de4aed7861d3af94a475cf71eb09ad41efc673ef +C +templates/base.html,d/a/da7c237b85a69c00a9ab8c189bf63e22070fcac3 \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/blogproj/settings.py b/blogproj/settings.py index c3f695c..4c621e4 100644 --- a/blogproj/settings.py +++ b/blogproj/settings.py @@ -45,6 +45,7 @@ 'django.contrib.staticfiles', 'crispy_forms', 'mainapp', + 'users', ] MIDDLEWARE = [ @@ -131,3 +132,7 @@ STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ] + +LOGIN_URL = 'login' +LOGIN_REDIRECT_URL = 'index' +AUTH_USER_MODEL = 'users.User' diff --git a/blogproj/urls.py b/blogproj/urls.py index 2dd85a5..247cabb 100644 --- a/blogproj/urls.py +++ b/blogproj/urls.py @@ -18,6 +18,7 @@ from .views import redirect_root urlpatterns = [ + path('accounts/', include('users.urls')), path('admin/', admin.site.urls), path('blog/', include('mainapp.urls')), path('', redirect_root) diff --git a/mainapp/migrations/0003_auto_20200323_1924.py b/mainapp/migrations/0003_auto_20200323_1924.py new file mode 100644 index 0000000..b9cfce0 --- /dev/null +++ b/mainapp/migrations/0003_auto_20200323_1924.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.9 on 2020-03-23 19:24 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('mainapp', '0002_auto_20191004_0501'), + ] + + operations = [ + migrations.DeleteModel( + name='BlogPost', + ), + migrations.DeleteModel( + name='Tag', + ), + ] diff --git a/templates/base.html b/templates/base.html index 826af47..3b6543c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -30,7 +30,7 @@ diff --git a/users/__init__.py b/users/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/users/admin.py b/users/admin.py new file mode 100644 index 0000000..6d53b53 --- /dev/null +++ b/users/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from django.contrib.auth.admin import UserAdmin + +from .models import User + +admin.site.register(User, UserAdmin) diff --git a/users/apps.py b/users/apps.py new file mode 100644 index 0000000..4ce1fab --- /dev/null +++ b/users/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UsersConfig(AppConfig): + name = 'users' diff --git a/users/migrations/0001_initial.py b/users/migrations/0001_initial.py new file mode 100644 index 0000000..b2d67a1 --- /dev/null +++ b/users/migrations/0001_initial.py @@ -0,0 +1,44 @@ +# Generated by Django 2.2.9 on 2020-03-23 19:24 + +import django.contrib.auth.models +import django.contrib.auth.validators +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('auth', '0011_update_proxy_permissions'), + ] + + operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('password', models.CharField(max_length=128, verbose_name='password')), + ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), + ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), + ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), + ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), + ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), + ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), + ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), + ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), + ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), + ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), + ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), + ], + options={ + 'verbose_name': 'user', + 'verbose_name_plural': 'users', + 'abstract': False, + }, + managers=[ + ('objects', django.contrib.auth.models.UserManager()), + ], + ), + ] diff --git a/users/migrations/__init__.py b/users/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/users/models.py b/users/models.py new file mode 100644 index 0000000..c60b965 --- /dev/null +++ b/users/models.py @@ -0,0 +1,6 @@ +from django.db import models + +from django.contrib.auth.models import AbstractUser + +class User(AbstractUser): + pass diff --git a/support/login.html b/users/templates/login.html similarity index 100% rename from support/login.html rename to users/templates/login.html diff --git a/users/tests.py b/users/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/users/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/users/urls.py b/users/urls.py new file mode 100644 index 0000000..516b08f --- /dev/null +++ b/users/urls.py @@ -0,0 +1,9 @@ +from django.contrib.auth import views as auth_views +from django.urls import path +from . import views + + +urlpatterns = [ + path('login/', auth_views.LoginView.as_view(template_name='login.html'), name='login'), + path('logout/', auth_views.LogoutView.as_view(next_page='index'), name='logout'), +] \ No newline at end of file diff --git a/users/views.py b/users/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/users/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here.