Skip to content

Commit

Permalink
Merge pull request #39 from hotosm/feat/partnership-and-reports
Browse files Browse the repository at this point in the history
partnership template, document collection, open mapping solutions, resource and learning pages
  • Loading branch information
luminaryFlowers authored Aug 26, 2024
2 parents aebdcc3 + 7a00c9c commit fc713f8
Show file tree
Hide file tree
Showing 31 changed files with 983 additions and 64 deletions.
17 changes: 17 additions & 0 deletions app/core/migrations/0009_remove_partner_partner_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.7 on 2024-08-14 19:46

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0008_partnertype_type_description_partnertype_type_icon'),
]

operations = [
migrations.RemoveField(
model_name='partner',
name='partner_type',
),
]
20 changes: 20 additions & 0 deletions app/core/migrations/0010_partner_partner_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.7 on 2024-08-14 19:47

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('partners', '0010_remove_ourpartnerspage_call_to_action_description_and_more'),
('core', '0009_remove_partner_partner_type'),
]

operations = [
migrations.AddField(
model_name='partner',
name='partner_type',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='partners.partnershiptemplatepage'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.7 on 2024-08-14 20:01

from django.db import migrations
import modelcluster.fields


class Migration(migrations.Migration):

dependencies = [
('partners', '0010_remove_ourpartnerspage_call_to_action_description_and_more'),
('core', '0010_partner_partner_type'),
]

operations = [
migrations.RemoveField(
model_name='partner',
name='partner_type',
),
migrations.AddField(
model_name='partner',
name='partner_type',
field=modelcluster.fields.ParentalManyToManyField(blank=True, null=True, to='partners.partnershiptemplatepage'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.7 on 2024-08-14 20:59

from django.db import migrations
import wagtail.blocks
import wagtail.fields


class Migration(migrations.Migration):

dependencies = [
('core', '0011_remove_partner_partner_type_partner_partner_type'),
]

operations = [
migrations.RemoveField(
model_name='partner',
name='partner_type',
),
migrations.AddField(
model_name='partner',
name='partner_type',
field=wagtail.fields.StreamField([('type', wagtail.blocks.PageChooserBlock(page_type=['partners.PartnershipTemplatePage']))], blank=True, null=True, use_json_field=True),
),
]
16 changes: 16 additions & 0 deletions app/core/migrations/0013_delete_partnertype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 4.2.7 on 2024-08-14 21:33

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('core', '0012_remove_partner_partner_type_partner_partner_type'),
]

operations = [
migrations.DeleteModel(
name='PartnerType',
),
]
37 changes: 2 additions & 35 deletions app/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,6 @@
from wagtail.admin.panels import FieldPanel, MultiFieldPanel, InlinePanel


@register_snippet
class PartnerType(models.Model):
type_name = models.CharField()
type_icon = models.ForeignKey(
"wagtailimages.Image",
null=True,
on_delete=models.SET_NULL,
related_name="+",
help_text="Icon for the partner type"
)
type_description = RichTextField(blank=True)

panels = [
FieldPanel("type_name"),
MultiFieldPanel([
FieldPanel('type_icon'),
FieldPanel('type_description'),
], heading="These will show in the Partner With Us page - an info block is automatically created for each partner type.")
]

def __str__(self):
return self.type_name

class Meta:
verbose_name_plural = "Partner Types"


@register_snippet
class Partner(models.Model):
partner_name = models.CharField()
Expand All @@ -46,19 +19,13 @@ class Partner(models.Model):
help_text="Partner logo"
)
partner_url = models.URLField(blank=True)
partner_type = models.ForeignKey(
'core.PartnerType',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
partner_type = StreamField([('type', PageChooserBlock(page_type="partners.PartnershipTemplatePage"))], use_json_field=True, null=True, blank=True)

panels = [
FieldPanel("partner_name"),
FieldPanel("partner_logo"),
FieldPanel("partner_url"),
FieldPanel("partner_type", widget=forms.RadioSelect),
FieldPanel("partner_type"),
]

def __str__(self):
Expand Down
37 changes: 37 additions & 0 deletions app/misc/migrations/0012_documentcollectionpage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 4.2.7 on 2024-08-14 22:35

from django.db import migrations, models
import django.db.models.deletion
import wagtail.blocks
import wagtail.documents.blocks
import wagtail.fields
import wagtail.images.blocks


class Migration(migrations.Migration):

dependencies = [
('wagtailimages', '0025_alter_image_file_alter_rendition_file'),
('wagtailcore', '0089_log_entry_data_json_null_to_object'),
('misc', '0011_rename_body_text_privacypolicypage_brief_body_text_and_more'),
]

operations = [
migrations.CreateModel(
name='DocumentCollectionPage',
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')),
('header_description', wagtail.fields.RichTextField(blank=True)),
('document_access_prefix_text', models.CharField(default='Access', help_text="Text to prefix the name of the document in the link to the document; if the document's title is 'Cool Doc', and this field is 'Access', the link for the document would show as 'Access Cool Doc'.")),
('documents', wagtail.fields.StreamField([('block', wagtail.blocks.StructBlock([('icon', wagtail.images.blocks.ImageChooserBlock()), ('document', wagtail.documents.blocks.DocumentChooserBlock()), ('description', wagtail.blocks.RichTextBlock())]))], blank=True, null=True, use_json_field=True)),
('sidebar_box_title', models.CharField(blank=True)),
('sidebar_box_button_text', models.CharField(blank=True)),
('sidebar_box_button_link', wagtail.fields.StreamField([('page', wagtail.blocks.PageChooserBlock()), ('url', wagtail.blocks.URLBlock())], blank=True, use_json_field=True)),
('header_image', models.ForeignKey(blank=True, help_text='Header image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
22 changes: 22 additions & 0 deletions app/misc/migrations/0013_alter_documentcollectionpage_documents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.7 on 2024-08-14 22:45

from django.db import migrations
import wagtail.blocks
import wagtail.documents.blocks
import wagtail.fields
import wagtail.images.blocks


class Migration(migrations.Migration):

dependencies = [
('misc', '0012_documentcollectionpage'),
]

operations = [
migrations.AlterField(
model_name='documentcollectionpage',
name='documents',
field=wagtail.fields.StreamField([('block', wagtail.blocks.StructBlock([('icon', wagtail.images.blocks.ImageChooserBlock(blank=True, null=True)), ('document', wagtail.documents.blocks.DocumentChooserBlock()), ('description', wagtail.blocks.RichTextBlock(blank=True, null=True))]))], blank=True, null=True, use_json_field=True),
),
]
22 changes: 22 additions & 0 deletions app/misc/migrations/0014_alter_documentcollectionpage_documents.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.7 on 2024-08-14 22:46

from django.db import migrations
import wagtail.blocks
import wagtail.documents.blocks
import wagtail.fields
import wagtail.images.blocks


class Migration(migrations.Migration):

dependencies = [
('misc', '0013_alter_documentcollectionpage_documents'),
]

operations = [
migrations.AlterField(
model_name='documentcollectionpage',
name='documents',
field=wagtail.fields.StreamField([('block', wagtail.blocks.StructBlock([('icon', wagtail.images.blocks.ImageChooserBlock(blank=True, null=True, required=False)), ('document', wagtail.documents.blocks.DocumentChooserBlock()), ('description', wagtail.blocks.RichTextBlock(blank=True, null=True, required=False))]))], blank=True, null=True, use_json_field=True),
),
]
61 changes: 61 additions & 0 deletions app/misc/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from django.db import models
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

from wagtail.admin.panels import FieldPanel, MultiFieldPanel
from wagtail.fields import RichTextField, StreamField
from wagtail.blocks import CharBlock, StreamBlock, StructBlock, URLBlock, RichTextBlock, PageChooserBlock
from wagtail.images.blocks import ImageChooserBlock
from wagtail.models import Page
from wagtail.documents.blocks import DocumentChooserBlock

from app.core.models import LinkOrPageBlock


Expand Down Expand Up @@ -233,3 +236,61 @@ class DataPrinciplesPage(Page):
FieldPanel('footer_button_link'),
], heading="Footer"),
]


class DocumentCollectionPage(Page):
def get_context(self, request, *args, **kwargs):
context = super().get_context(request, *args, **kwargs)

documents = context['page'].documents
page = request.GET.get('page', 1)
paginator = Paginator(documents, 6) # if you want more/less items per page (i.e., per load), change the number here to something else
try:
documents = paginator.page(page)
except PageNotAnInteger:
documents = paginator.page(1)
except EmptyPage:
documents = paginator.page(paginator.num_pages)

context['documents'] = documents
context['paginator'] = paginator
return context

header_image = models.ForeignKey(
"wagtailimages.Image",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
help_text="Header image"
)
header_description = RichTextField(blank=True)

document_access_prefix_text = models.CharField(default="Access", help_text="Text to prefix the name of the document in the link to the document; if the document's title is 'Cool Doc', and this field is 'Access', the link for the document would show as 'Access Cool Doc'.")
documents = StreamField([
('block', StructBlock([
('icon', ImageChooserBlock(blank=True, null=True, required=False)),
('document', DocumentChooserBlock()),
('description', RichTextBlock(blank=True, null=True, required=False))
]))
], use_json_field=True, null=True, blank=True)

sidebar_box_title = models.CharField(blank=True)
sidebar_box_button_text = models.CharField(blank=True)
sidebar_box_button_link = StreamField(LinkOrPageBlock(), use_json_field=True, blank=True)

content_panels = Page.content_panels + [
MultiFieldPanel([
FieldPanel('header_image'),
FieldPanel('header_description'),
], heading="Header"),
MultiFieldPanel([
FieldPanel('document_access_prefix_text'),
FieldPanel('documents'),
], heading="Documents"),
MultiFieldPanel([
FieldPanel('sidebar_box_title'),
FieldPanel('sidebar_box_button_text'),
FieldPanel('sidebar_box_button_link'),
], heading="Sidebar"),
]
8 changes: 4 additions & 4 deletions app/misc/templates/misc/code_of_conduct_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ <h1 class="font-semibold text-h1">
{{page.title}}
</h1>
<div class="text-intro font-medium">
{{page.intro|safe}}
{{page.intro|richtext}}
</div>

<h2 class="font-bold text-h2 mt-8">
{{page.short_version_title}}
</h2>
<div class="base-article-m">
{{page.short_version_body|safe}}
{{page.short_version_body|richtext}}
</div>

<h2 class="font-bold text-h2 mt-8">
{{page.full_version_title}}
</h2>
<div class="base-article-m">
{{page.full_version_body|safe}}
{{page.full_version_body|richtext}}
</div>

<h2 class="font-bold text-h2 mt-8">
{{page.complaint_handling_title}}
</h2>
<div class="base-article-m">
{{page.complaint_handling_body|safe}}
{{page.complaint_handling_body|richtext}}
</div>
</div>

Expand Down
Loading

0 comments on commit fc713f8

Please sign in to comment.