From 9d32b12b05f96f108518ed49fccc4a2c72dd7f24 Mon Sep 17 00:00:00 2001 From: Conrad Date: Sun, 19 Jan 2020 11:14:34 +0100 Subject: [PATCH] Profile and Settings Work - Added logout button + url - Added redirect urls - Fixed bug where the steam name wouldn't show in template - Added tradeurl to model - Added simple profile - Added ability to change own trade url --- src/asiimov/settings.py | 11 +++-- src/asiimov/urls.py | 4 +- src/common/static_files/css/profile.css | 3 ++ src/common/templates/master.html | 3 +- src/core/forms.py | 9 ++++ src/core/migrations/0002_gamer_tradeurl.py | 18 +++++++ src/core/migrations/0003_gamer_offer_count.py | 18 +++++++ src/core/models.py | 3 ++ src/core/steam_api.py | 2 +- src/core/templates/core/signup.html | 1 - src/core/templates/profile/profile.html | 43 ++++++++++++++++ src/core/templates/profile/settings.html | 21 ++++++++ src/core/urls.py | 1 + src/core/views.py | 49 ++++++++++++++----- 14 files changed, 167 insertions(+), 19 deletions(-) create mode 100644 src/common/static_files/css/profile.css create mode 100644 src/core/forms.py create mode 100644 src/core/migrations/0002_gamer_tradeurl.py create mode 100644 src/core/migrations/0003_gamer_offer_count.py delete mode 100644 src/core/templates/core/signup.html create mode 100644 src/core/templates/profile/profile.html create mode 100644 src/core/templates/profile/settings.html diff --git a/src/asiimov/settings.py b/src/asiimov/settings.py index 89e282e..772dab6 100644 --- a/src/asiimov/settings.py +++ b/src/asiimov/settings.py @@ -27,7 +27,6 @@ ALLOWED_HOSTS = [] # Application definition - INSTALLED_APPS = [ 'core', 'django.contrib.admin', @@ -71,7 +70,6 @@ WSGI_APPLICATION = 'asiimov.wsgi.application' # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases - DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', @@ -82,7 +80,6 @@ DATABASES = { # Password validation # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators - AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', @@ -101,7 +98,6 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization # https://docs.djangoproject.com/en/3.0/topics/i18n/ - LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True @@ -119,3 +115,10 @@ STATICFILES_DIRS = [ # Steam API variables STEAM_API_KEY = os.environ['STEAM_API_KEY'] + +# Redirect for users to login +LOGIN_URL = 'signup' +# Redirect after login +LOGIN_REDIRECT_URL = 'me' +# Redirect after logout +LOGOUT_REDIRECT_URL = 'home' diff --git a/src/asiimov/urls.py b/src/asiimov/urls.py index 82b67d9..734ea78 100644 --- a/src/asiimov/urls.py +++ b/src/asiimov/urls.py @@ -15,8 +15,10 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include +from django.contrib.auth.views import LogoutView urlpatterns = [ path('', include('core.urls')), - path('admin/', admin.site.urls) + path('admin/', admin.site.urls), + path('logout/', LogoutView.as_view(template_name='logout.html'), name='logout') ] diff --git a/src/common/static_files/css/profile.css b/src/common/static_files/css/profile.css new file mode 100644 index 0000000..01d40ba --- /dev/null +++ b/src/common/static_files/css/profile.css @@ -0,0 +1,3 @@ +.content_block{ + text-align: center; +} diff --git a/src/common/templates/master.html b/src/common/templates/master.html index 0125f90..66ca612 100644 --- a/src/common/templates/master.html +++ b/src/common/templates/master.html @@ -13,6 +13,7 @@ + {% block header %}{% endblock %} @@ -22,7 +23,7 @@