Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

view template #163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
SECRET_KEY = env("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ["127.0.0.1", ".zurifordummies.com"]

Expand Down Expand Up @@ -176,7 +176,7 @@
ACCOUNT_LOGOUT_ON_PASSWORD_CHANGE = True
ACCOUNT_EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECTED_URL = None

# email config
# # email config
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_USE_SSL = True
EMAIL_USE_TLS = False
Expand Down
4 changes: 3 additions & 1 deletion pages/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from django.contrib import admin

from .models import *
# Register your models here.

admin.site.register(Template)
22 changes: 22 additions & 0 deletions pages/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.1 on 2022-08-15 12:48

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Template',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('directory', models.CharField(max_length=20, null=None)),
('template_index', models.CharField(default='index.html', max_length=20)),
],
),
]
7 changes: 7 additions & 0 deletions pages/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
from django.db import models

# Create your models here.

class Template(models.Model):
directory = models.CharField(max_length=20, null=None)
template_index = models.CharField(max_length=20, default="index.html")

def __str__ (self):
return self.directory
5 changes: 3 additions & 2 deletions pages/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from django.urls import path, include
from .views import HomePageView, DashboardView, SelectTemplateView, BloggerUsersView
from .views import HomePageView, DashboardView, selectTemplate, BloggerUsersView,viewTemplate

urlpatterns = [
path("", HomePageView.as_view(), name="home"),
path("dashboard/", DashboardView.as_view(), name="dashboard"),
path("dashboard/users/", BloggerUsersView.as_view(), name="users"),
path("select_template/", SelectTemplateView.as_view(), name="select_template"),
path("select_template/", selectTemplate, name="select_template"),
path("select_template/<str:pk>/", viewTemplate, name="viewTemplate"),
]
17 changes: 9 additions & 8 deletions pages/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from re import template
from django.conf import settings
from django.shortcuts import redirect
from django.shortcuts import render
from django.views.generic import TemplateView

from .models import *
# Create your views here.


Expand All @@ -14,17 +15,17 @@ class DashboardView(TemplateView):
template_name = "dashboard.html"


class SelectTemplateView(TemplateView):
template_name = "select_template.html"


class BloggerUsersView(TemplateView):
template_name = "dashboard_users.html"


def error_404(request, exception):
return render(request, "404.html")

def selectTemplate(request):
temp_name = Template.objects.all()
context = {'temp_name':temp_name}
return render(request, 'select_template.html',context)

# def error_500(request):
# return render(request, "404.html")
def viewTemplate(request, pk):
template = Template.objects.get(id=pk)
return render(request, f'{template.directory}/{template.template_index}')
2 changes: 1 addition & 1 deletion static/assets/css/select_template.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ main p {
height: 416px;
}
#col1 {
background-image: url(/static/assets/images/template1.png);
background-image: url(/static/assets/images/huddle-template.png);
background-repeat: no-repeat;
background-size: 100% 416px;
}
Expand Down
Loading