-
Notifications
You must be signed in to change notification settings - Fork 4
- Install wagtail and wagtail-factories #116
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
Open
samklq
wants to merge
2
commits into
main
Choose a base branch
from
3602796543_set_up_cms_with_wagtail
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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,40 @@ | ||
| # Generated by Django 4.1.3 on 2022-12-06 13:42 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
| import wagtail.fields | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('wagtailcore', '0078_referenceindex'), | ||
| ('staff', '0015_alter_course_name'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='CoursePage', | ||
| fields=[ | ||
| ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), | ||
| ('intro', wagtail.fields.RichTextField(blank=True)), | ||
| ('course', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='staff.course')), | ||
| ], | ||
| options={ | ||
| 'abstract': False, | ||
| }, | ||
| bases=('wagtailcore.page',), | ||
| ), | ||
| migrations.CreateModel( | ||
| name='BatchPage', | ||
| fields=[ | ||
| ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), | ||
| ('intro', wagtail.fields.RichTextField(blank=True)), | ||
| ('batch', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='staff.batch')), | ||
| ], | ||
| options={ | ||
| 'abstract': False, | ||
| }, | ||
| bases=('wagtailcore.page',), | ||
| ), | ||
| ] |
This file contains hidden or 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,28 @@ | ||
| # Generated by Django 4.1.4 on 2023-01-03 08:17 | ||
|
|
||
| from django.db import migrations, models | ||
| import django.db.models.deletion | ||
| import wagtail.fields | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('wagtailcore', '0078_referenceindex'), | ||
| ('staff', '0016_coursepage_batchpage'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='DayPage', | ||
| fields=[ | ||
| ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')), | ||
| ('body', wagtail.fields.RichTextField(blank=True)), | ||
| ('batch_page', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='staff.batchpage')), | ||
| ], | ||
| options={ | ||
| 'abstract': False, | ||
| }, | ||
| bases=('wagtailcore.page',), | ||
| ), | ||
| ] |
This file contains hidden or 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,5 +1,8 @@ | ||
| from .batch import Batch | ||
| from .batch_page import BatchPage | ||
| from .batch_schedule import BatchSchedule | ||
| from .certificate import Certificate | ||
| from .course import Course | ||
| from .course_page import CoursePage | ||
| from .day_page import DayPage | ||
| from .section import Section |
This file contains hidden or 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 hidden or 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,30 @@ | ||
| from django import forms | ||
| from django.db import models | ||
| from wagtail.admin.panels import FieldPanel | ||
| from wagtail.fields import RichTextField | ||
| from wagtail.models import Page | ||
| from wagtail.search import index | ||
|
|
||
| from staff.models import Batch | ||
|
|
||
|
|
||
| class BatchPage(Page): | ||
| intro = RichTextField(blank=True) | ||
| batch = models.ForeignKey(Batch, on_delete=models.PROTECT) | ||
|
|
||
| search_fields = Page.search_fields + [ | ||
| index.FilterField('intro'), | ||
| index.SearchField('intro'), | ||
| ] | ||
|
|
||
| content_panels = Page.content_panels + [ | ||
| FieldPanel('batch', widget=forms.Select), | ||
| FieldPanel('intro') | ||
| ] | ||
|
|
||
| def save(self, *args, **kwargs): | ||
| # slug does not appear above as an attribute | ||
| # because it is an attribute on Wagtail's Page model | ||
| self.slug = self.batch.number | ||
|
|
||
| return super().save(*args, **kwargs) |
This file contains hidden or 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 hidden or 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,23 @@ | ||
| from django import forms | ||
| from django.db import models | ||
| from wagtail.admin.panels import FieldPanel | ||
| from wagtail.fields import RichTextField | ||
| from wagtail.models import Page | ||
| from wagtail.search import index | ||
|
|
||
| from staff.models import Course | ||
|
|
||
|
|
||
| class CoursePage(Page): | ||
| intro = RichTextField(blank=True) | ||
| course = models.ForeignKey(Course, on_delete=models.PROTECT) | ||
|
|
||
| search_fields = Page.search_fields + [ | ||
| index.FilterField('intro'), | ||
| index.SearchField('intro'), | ||
| ] | ||
|
|
||
| content_panels = Page.content_panels + [ | ||
| FieldPanel('course', widget=forms.Select), | ||
| FieldPanel('intro') | ||
| ] |
This file contains hidden or 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,23 @@ | ||
| from django import forms | ||
| from django.db import models | ||
| from wagtail.admin.panels import FieldPanel | ||
| from wagtail.fields import RichTextField | ||
| from wagtail.models import Page | ||
| from wagtail.search import index | ||
|
|
||
| from staff.models import BatchPage | ||
|
|
||
|
|
||
| class DayPage(Page): | ||
| batch_page = models.ForeignKey(BatchPage, on_delete=models.PROTECT) | ||
| body = RichTextField(blank=True) | ||
|
|
||
| search_fields = Page.search_fields + [ | ||
| index.FilterField('body'), | ||
| index.SearchField('body'), | ||
| ] | ||
|
|
||
| content_panels = Page.content_panels + [ | ||
| FieldPanel('batch_page', widget=forms.Select), | ||
| FieldPanel('body') | ||
| ] |
This file contains hidden or 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,20 @@ | ||
| {% extends "staff_base.html" %} | ||
|
|
||
| {% load wagtailcore_tags %} | ||
|
|
||
| {% block body_class %}template-blogindexpage{% endblock %} | ||
|
|
||
| {% block content %} | ||
| <div class="row"> | ||
| <div class="col-6"> | ||
| <h1>{{ page.title }}</h1> | ||
|
|
||
| <div class="intro my-5">{{ page.intro|richtext }}</div> | ||
|
|
||
| {% for post in page.get_children %} | ||
| <h2><a href="{% pageurl post %}">{{ post.title }}</a></h2> | ||
| {% endfor %} | ||
| </div> | ||
| </div> | ||
|
|
||
| {% endblock %} |
This file contains hidden or 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,20 @@ | ||
| {% extends "staff_base.html" %} | ||
|
|
||
| {% load wagtailcore_tags %} | ||
|
|
||
| {% block body_class %}template-blogindexpage{% endblock %} | ||
|
|
||
| {% block content %} | ||
| <div class="row"> | ||
| <div class="col-6"> | ||
| <h1>{{ page.title }}</h1> | ||
|
|
||
| <div class="intro my-5">{{ page.intro|richtext }}</div> | ||
|
|
||
| {% for post in page.get_children %} | ||
| <h4><a href="{% pageurl post %}">{{ post.title }}</a></h4> | ||
| {% endfor %} | ||
| </div> | ||
| </div> | ||
|
|
||
| {% endblock %} |
This file contains hidden or 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,20 @@ | ||
| {% extends "staff_base.html" %} | ||
|
|
||
| {% load wagtailcore_tags %} | ||
|
|
||
| {% block body_class %}template-blogindexpage{% endblock %} | ||
|
|
||
| {% block content %} | ||
| <div class="row"> | ||
| <div class="col-6"> | ||
| <h1>{{ page.title }}</h1> | ||
|
|
||
| <div class="intro my-5">{{ page.body|richtext }}</div> | ||
|
|
||
| {% for post in page.get_children %} | ||
| <h2><a href="{% pageurl post %}">{{ post.title }}</a></h2> | ||
| {% endfor %} | ||
| </div> | ||
| </div> | ||
|
|
||
| {% endblock %} |
This file contains hidden or 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,25 @@ | ||
| from django.utils.text import slugify | ||
| from factory import LazyAttribute, SubFactory, Trait | ||
| from factory.fuzzy import FuzzyText | ||
| from wagtail_factories import PageFactory | ||
|
|
||
| from staff.models import BatchPage | ||
| from staff.tests.factories.batch_factory import BatchFactory | ||
|
|
||
| class BatchPageFactory(PageFactory): | ||
| class Meta: | ||
| model = BatchPage | ||
|
|
||
| title = FuzzyText(length=15) | ||
| slug = LazyAttribute(lambda object: slugify(object.batch.number)) | ||
| intro = FuzzyText(length=20) | ||
| batch = SubFactory(BatchFactory, swe_fundamentals=True) | ||
|
|
||
| class Params: | ||
| swe_fundamentals = Trait( | ||
| batch=SubFactory(BatchFactory, swe_fundamentals=True) | ||
| ) | ||
|
|
||
| coding_bootcamp = Trait( | ||
| batch=SubFactory(BatchFactory, coding_bootcamp=True) | ||
| ) | ||
This file contains hidden or 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,25 @@ | ||
| from django.utils.text import slugify | ||
| from factory import LazyAttribute, SubFactory, Trait | ||
| from factory.fuzzy import FuzzyText | ||
| from wagtail_factories import PageFactory | ||
|
|
||
| from staff.models import CoursePage | ||
| from staff.tests.factories.course_factory import CourseFactory | ||
|
|
||
| class CoursePageFactory(PageFactory): | ||
| class Meta: | ||
| model = CoursePage | ||
|
|
||
| title = FuzzyText(length=15) | ||
| slug = LazyAttribute(lambda object: slugify(object.course.name.replace('_', '-'))) | ||
| intro = FuzzyText(length=20) | ||
| course = SubFactory(CourseFactory, swe_fundamentals=True) | ||
|
|
||
| class Params: | ||
| swe_fundamentals = Trait( | ||
| course=SubFactory(CourseFactory, swe_fundamentals=True) | ||
| ) | ||
|
|
||
| coding_bootcamp = Trait( | ||
| course=SubFactory(CourseFactory, coding_bootcamp=True) | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be safer to name
coding_bootcampswe_bootcampinstead, to anticipate future bootcamp courses like Data Science bootcamp.