diff options
author | adityacp | 2020-07-27 17:13:57 +0530 |
---|---|---|
committer | adityacp | 2020-07-27 17:13:57 +0530 |
commit | 8a67bbe45e51f33dc82f4492f8dcc318f0995256 (patch) | |
tree | c680c7ae669a662f4c23f4ab2dfcbf36f706183b | |
parent | e119c6f2fa675a2284cbac17ba0bb5ae4f5b7f87 (diff) | |
download | workshop_booking-8a67bbe45e51f33dc82f4492f8dcc318f0995256.tar.gz workshop_booking-8a67bbe45e51f33dc82f4492f8dcc318f0995256.tar.bz2 workshop_booking-8a67bbe45e51f33dc82f4492f8dcc318f0995256.zip |
Change project files
- Add project views to redirect to the cms home page if available
- Add home page title variable in the settings
- Change initial reg ex url pattern for the app urls
-rw-r--r-- | workshop_portal/settings.py | 7 | ||||
-rw-r--r-- | workshop_portal/urls.py | 6 | ||||
-rw-r--r-- | workshop_portal/views.py | 16 |
3 files changed, 25 insertions, 4 deletions
diff --git a/workshop_portal/settings.py b/workshop_portal/settings.py index ad727af..b340ab2 100644 --- a/workshop_portal/settings.py +++ b/workshop_portal/settings.py @@ -127,7 +127,7 @@ USE_TZ = True STATIC_URL = '/static/' -STATIC_ROOT = os.path.join(BASE_DIR, "static/") +STATIC_ROOT = 'workshop_app/static/' LOGIN_URL = '/login/' @@ -156,7 +156,10 @@ ADMIN_EMAIL = 'your admin email' # Set True or False to view/hide SHOW_WORKSHOP_STATS = True -LOGIN_REDIRECT_URL = '/profile' +# Create a CMS page as a home page and give the page title here +HOME_PAGE_TITLE = "home-page-title" + +LOGIN_REDIRECT_URL = '/workshop/login' SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_SAVE_EVERY_REQUEST = True SESSION_COOKIE_AGE = 3600 diff --git a/workshop_portal/urls.py b/workshop_portal/urls.py index 703a9ed..8adddd8 100644 --- a/workshop_portal/urls.py +++ b/workshop_portal/urls.py @@ -15,11 +15,13 @@ Including another URLconf """ from django.conf.urls import url, include from django.contrib import admin +from workshop_portal import views urlpatterns = [ url(r'^admin/', admin.site.urls), - url(r'^', include('workshop_app.urls')), + url(r'^$', views.index), + url(r'^workshop/', include('workshop_app.urls')), url(r'^reset/', include('django.contrib.auth.urls')), - url(r'^', include('cms.urls')), + url(r'^page/', include('cms.urls')), ] diff --git a/workshop_portal/views.py b/workshop_portal/views.py new file mode 100644 index 0000000..e166039 --- /dev/null +++ b/workshop_portal/views.py @@ -0,0 +1,16 @@ +# Django Imports
+from django.shortcuts import redirect
+from django.urls import reverse
+from django.conf import settings
+
+# Local Imports
+from cms.models import Page
+
+
+def index(request):
+ page = Page.objects.filter(title=settings.HOME_PAGE_TITLE)
+ if page.exists():
+ redirect_url = reverse("cms:home", args=[page.first().permalink])
+ else:
+ redirect_url = reverse("workshop_app:index")
+ return redirect(redirect_url)
|