Skip to content

Commit

Permalink
feat: protect home and about view behind login
Browse files Browse the repository at this point in the history
  • Loading branch information
ngurenyaga committed Jul 15, 2021
1 parent 80e395b commit 4aa1c88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 4 additions & 7 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import include, path
from django.views import defaults as default_views
from django.views.generic import TemplateView
from rest_framework.authtoken.views import obtain_auth_token

from pepfar_mle.common.views import AboutView, HomeView

urlpatterns = [
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
path("", HomeView.as_view(), name="home"),
path(
"about/",
TemplateView.as_view(template_name="pages/about.html"),
AboutView.as_view(),
name="about",
),
# path(
# "jet/dashboard/", include("jet.dashboard.urls", "jet-dashboard")
# ), # Django JET dashboard URLS
path("jet/", include("jet.urls", "jet")), # Django JET URLS
# Django Admin, use {% url 'admin:index' %}
path(settings.ADMIN_URL, admin.site.urls),
# User management
path("users/", include("pepfar_mle.users.urls", namespace="users")),
path("accounts/", include("allauth.urls")),
# Your stuff: custom urls includes go here
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
if settings.DEBUG:
# Static file serving when using Gunicorn + Uvicorn for local web socket development
Expand Down
10 changes: 10 additions & 0 deletions pepfar_mle/common/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import TemplateView


class HomeView(LoginRequiredMixin, TemplateView):
template_name = "pages/home.html"


class AboutView(LoginRequiredMixin, TemplateView):
template_name = "pages/about.html"

0 comments on commit 4aa1c88

Please sign in to comment.