This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from DHRI-Curriculum:pages
Resolves #107
- Loading branch information
Showing
13 changed files
with
133 additions
and
3,002 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 3.0.7 on 2020-07-09 18:37 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('website', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='page', | ||
name='is_homepage', | ||
), | ||
migrations.AddField( | ||
model_name='page', | ||
name='template', | ||
field=models.CharField(default='website/page.html', max_length=100), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.0.7 on 2020-07-09 18:41 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('website', '0002_auto_20200709_1837'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='page', | ||
name='template', | ||
field=models.CharField(choices=[('website/page.html', 'Standard'), ('workshop/workshop-list.html', 'Workshop list'), ('library/all-library-items.html', 'Library items')], default='website/page.html', max_length=100), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
|
||
class Page(models.Model): | ||
class Template(models.TextChoices): | ||
STANDARD = 'website/page.html', _('Standard') | ||
WORKSHOP_LIST = 'workshop/workshop-list.html', _('Workshop list') | ||
LIBRARY_LIST = 'library/all-library-items.html', _('Library items') | ||
|
||
name = models.CharField(max_length=200) | ||
slug = models.CharField(max_length=200, blank=True) | ||
text = models.TextField() | ||
is_homepage = models.BooleanField(default=False) | ||
template = models.CharField(max_length=100, choices=Template.choices, default=Template.STANDARD) | ||
|
||
def __str__(self): | ||
return str(self.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,28 @@ | ||
from django.shortcuts import render, get_object_or_404 | ||
from .models import Page | ||
from workshop.models import Workshop | ||
from library.models import Project, Reading, Resource, Tutorial | ||
from django.views.decorators.csrf import ensure_csrf_cookie | ||
|
||
@ensure_csrf_cookie | ||
def index(request): | ||
page = Page.objects.filter(is_homepage=True).last() | ||
return render(request, 'website/index.html', {'page': page}) | ||
|
||
@ensure_csrf_cookie | ||
def page(request, page_slug): | ||
payload = dict() | ||
|
||
page = get_object_or_404(Page, slug=page_slug) | ||
return render(request, 'website/page.html', {'page': page}) | ||
payload['page'] = page | ||
|
||
if page.template == Page.Template.WORKSHOP_LIST: | ||
payload['workshops'] = Workshop.objects.all() | ||
|
||
if page.template == Page.Template.LIBRARY_LIST: | ||
payload['projects'] = Project.objects.all().order_by('title')[:3] | ||
payload['readings'] = Reading.objects.all().order_by('title')[:3] | ||
payload['resources'] = Resource.objects.all().order_by('title')[:3] | ||
payload['tutorials'] = Tutorial.objects.all().order_by('label')[:3] | ||
|
||
return render(request, page.template, payload) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters