Skip to content

Commit

Permalink
Merge pull request #26 from hotosm/feat/home-page-continued
Browse files Browse the repository at this point in the history
home page done! (for now!)
  • Loading branch information
luminaryFlowers authored Jun 3, 2024
2 parents a3856c9 + 527ba42 commit da53cf4
Show file tree
Hide file tree
Showing 34 changed files with 1,051 additions and 62 deletions.
10 changes: 3 additions & 7 deletions app/impact_areas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ def get_context(self, request, *args, **kwargs):

projects_list = IndividualProjectPage.objects.live().filter(
Q(impact_area_list__contains=[{'type': 'impact_area', 'value': context['page'].id}])
)
# print(IndividualProjectPage.objects.first().impact_area_list[0].value.id)
# print(context['page'].id)
# print(IndividualProjectPage.objects.first().impact_area_list.__contains__([{'value__id': context['page'].id}]))
# print(dir(IndividualProjectPage.objects.first().impact_area_list))
).filter(locale=context['page'].locale)
page = request.GET.get('page', 1)
paginator = Paginator(projects_list, 4)
paginator = Paginator(projects_list, 8) # if you want more/less items per page (i.e., per load), change the number here to something else
try:
projects = paginator.page(page)
except PageNotAnInteger:
Expand All @@ -42,7 +38,7 @@ def get_context(self, request, *args, **kwargs):
projects = paginator.page(paginator.num_pages)

context['projects'] = projects
other_impact_areas = IndividualImpactAreaPage.objects.live()
other_impact_areas = IndividualImpactAreaPage.objects.live().filter(locale=context['page'].locale)
context['other_impact_areas'] = other_impact_areas
return context

Expand Down
4 changes: 2 additions & 2 deletions app/mapping_hubs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class DogearBoxBlock(StreamBlock):
class IndividualMappingHubPage(Page):
def get_context(self, request):
context = super().get_context(request)
projects = IndividualProjectPage.objects.filter(owner_region_hub=context['page'])
projects = IndividualProjectPage.objects.filter(owner_region_hub=context['page'], locale=context['page'].locale)
context['projects'] = projects
other_hubs = IndividualMappingHubPage.objects.live()
other_hubs = IndividualMappingHubPage.objects.live().filter(locale=context['page'].locale)
context['other_hubs'] = other_hubs
return context

Expand Down
20 changes: 20 additions & 0 deletions app/news/migrations/0015_alter_individualnewspage_article_body.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.7 on 2024-05-27 23:44

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


class Migration(migrations.Migration):

dependencies = [
('news', '0014_individualnewspage_news_read_more_text'),
]

operations = [
migrations.AlterField(
model_name='individualnewspage',
name='article_body',
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.RichTextBlock(features=['h1', 'h2', 'h3', 'h4', 'bold', 'italic', 'link', 'ol', 'ul', 'hr', 'document-link', 'image', 'embed', 'code', 'blockquote']))], blank=True, null=True, use_json_field=True),
),
]
2 changes: 1 addition & 1 deletion app/programs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ProgramGoalBlock(StreamBlock):
class IndividualProgramPage(Page):
def get_context(self, request):
context = super().get_context(request)
projects = IndividualProjectPage.objects.filter(owner_program=context['page'])
projects = IndividualProjectPage.objects.filter(owner_program=context['page'], locale=context['page'].locale)
context['projects'] = projects
return context

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.7 on 2024-05-27 23:44

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


class Migration(migrations.Migration):

dependencies = [
('projects', '0013_individualprojectpage_impact_area_list'),
]

operations = [
migrations.AlterField(
model_name='individualprojectpage',
name='description',
field=wagtail.fields.StreamField([('text_block', wagtail.blocks.RichTextBlock(features=['h1', 'h2', 'h3', 'h4', 'bold', 'italic', 'link', 'ol', 'ul', 'hr', 'document-link', 'image', 'embed', 'code', 'blockquote']))], null=True, use_json_field=True),
),
]
10 changes: 10 additions & 0 deletions app/ui/templates/ui/components/news/NewsPreviewBlockProjects.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
- news: an IndividualNewsPage object; the news page to be previewed
{% endcomment %}

{% load wagtailimages_tags %}

{% image news.image original as image_p %}
<div class="my-4">
<a href="{{ news.url }}">
{% if showimage %}
<div class="image-hide-small w-full min-h-[9rem] mb-3 content-end bg-no-repeat bg-cover image-overshadow-gradient" style="background-image: url('{{ image_p.url }}')">
<div>
</div>
</div>
{% endif %}

<p class="text-hot-red text-small font-semibold">
Blog
</p>
Expand Down
26 changes: 26 additions & 0 deletions app/ui/templates/ui/components/programs/ProgramCarouselBlock.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% load wagtailimages_tags %}
<div x-data="{ partnerIndex: 0, fixedIndex(x) {return ({{programs|length}} + x + this.partnerIndex) % {{programs|length}}}, moveIndex(x) {this.partnerIndex = this.fixedIndex(x)} }" class="{{class}}">
<div class="text-right mb-4">
<div x-on:click="moveIndex(1)" class="pr-4 text-hot-red inline-flex flex-col justify-center">
<div class="border-hot-red border-2 rounded-full h-8 w-8 text-center">
{% include "ui/components/icon_svgs/LinkCaret.html" with class="rotate-180" %}
</div>
</div>
<div x-on:click="moveIndex(-1)" class="text-hot-red inline-flex flex-col justify-center">
<div class="border-hot-red border-2 rounded-full h-8 w-8 text-center">
{% include "ui/components/icon_svgs/LinkCaret.html" %}
</div>
</div>
</div>

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
{% for program in programs %}
<div x-show="partnerIndex=={{forloop.counter0}} || fixedIndex(1)=={{forloop.counter0}} || fixedIndex(2)=={{forloop.counter0}} || fixedIndex(3)=={{forloop.counter0}}"
x-bind:class="{'order-1': partnerIndex=={{forloop.counter0}}, 'order-2': fixedIndex(1)=={{forloop.counter0}}, 'order-3 hidden md:block': fixedIndex(2)=={{forloop.counter0}}, 'order-4 hidden lg:block': fixedIndex(3)=={{forloop.counter0}},}"

>
{% include "ui/components/programs/ProgramPreviewBlockBase.html" with program=program.value %}
</div>
{% endfor %}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
</div>
</a>

<p class="text-mini">
<div class="text-mini my-2">
{% for area in project.impact_area_list %}
<a class="text-hot-red text-mini" href="{{ area.value.url }}">
<p>{{ area.value.title }}{% if not forloop.last %},{% endif %}</p>
</a>
{% endfor %}
</p>
</div>
</div>
1 change: 1 addition & 0 deletions frontend/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module.exports = {
colors: {
"hot-red": "var(--hot-red)",
"hot-navy": "var(--hot-navy)",
"hot-navy-grey": "var(--hot-navy-grey)",
"hot-dark-grey": "var(--hot-dark-grey)",
"hot-slate-grey": "var(--hot-slate-grey)",
"hot-light-grey": "var(--hot-light-grey)",
Expand Down
137 changes: 137 additions & 0 deletions home/migrations/0009_homepage_get_involved_button_link_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Generated by Django 4.2.7 on 2024-05-27 23:44

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


class Migration(migrations.Migration):

dependencies = [
('wagtailimages', '0025_alter_image_file_alter_rendition_file'),
('home', '0008_blankinaccessiblepage'),
]

operations = [
migrations.AddField(
model_name='homepage',
name='get_involved_button_link',
field=models.URLField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='get_involved_button_text',
field=models.CharField(default='Get Involved'),
),
migrations.AddField(
model_name='homepage',
name='highlighted_programs',
field=wagtail.fields.StreamField([('program', wagtail.blocks.PageChooserBlock(page_type=['programs.IndividualProgramPage']))], blank=True, null=True, use_json_field=True),
),
migrations.AddField(
model_name='homepage',
name='highlighted_programs_description',
field=wagtail.fields.RichTextField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='highlighted_programs_title',
field=models.CharField(default='Highlighted Programs'),
),
migrations.AddField(
model_name='homepage',
name='impact_areas_description',
field=wagtail.fields.RichTextField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='impact_areas_title',
field=models.CharField(default='Impact Areas'),
),
migrations.AddField(
model_name='homepage',
name='mapping_hubs_description',
field=wagtail.fields.RichTextField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='mapping_hubs_title',
field=wagtail.fields.RichTextField(blank=True, help_text='Any text written in bold will be displayed as red in this title.'),
),
migrations.AddField(
model_name='homepage',
name='opportunities_description',
field=wagtail.fields.RichTextField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='opportunities_title',
field=wagtail.fields.RichTextField(blank=True, help_text='Any text written in bold will be displayed as red in this title.'),
),
migrations.AddField(
model_name='homepage',
name='our_work_title',
field=models.CharField(default='Our Work'),
),
migrations.AddField(
model_name='homepage',
name='partner_with_us_button_link',
field=models.URLField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='partner_with_us_button_text',
field=models.CharField(default='Partner With Us'),
),
migrations.AddField(
model_name='homepage',
name='tools_resources_button_text',
field=models.CharField(default='Tools & Resources'),
),
migrations.AddField(
model_name='homepage',
name='tools_resources_button_url',
field=models.URLField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='tools_resources_description',
field=wagtail.fields.RichTextField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='tools_resources_image',
field=models.ForeignKey(blank=True, help_text='Tools and Resources section image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'),
),
migrations.AddField(
model_name='homepage',
name='tools_resources_title',
field=wagtail.fields.RichTextField(blank=True, help_text='Any text written in bold will be displayed as red in this title.'),
),
migrations.AddField(
model_name='homepage',
name='view_all_programs_text',
field=models.CharField(default='View all programs'),
),
migrations.AddField(
model_name='homepage',
name='who_we_are_button_link',
field=models.URLField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='who_we_are_button_text',
field=models.CharField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='who_we_are_intro_description',
field=wagtail.fields.RichTextField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='who_we_are_intro_title',
field=wagtail.fields.RichTextField(blank=True, help_text='Any text written in bold will be displayed as red in this title.'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 4.2.7 on 2024-05-28 00:22

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


class Migration(migrations.Migration):

dependencies = [
('home', '0009_homepage_get_involved_button_link_and_more'),
]

operations = [
migrations.AddField(
model_name='homepage',
name='news_title',
field=models.CharField(default='News'),
),
migrations.AddField(
model_name='homepage',
name='related_news',
field=wagtail.fields.StreamField([('news_page', wagtail.blocks.PageChooserBlock(page_type=['news.IndividualNewsPage']))], blank=True, null=True, use_json_field=True),
),
migrations.AddField(
model_name='homepage',
name='view_all_news_text',
field=models.CharField(default='View all news'),
),
migrations.AddField(
model_name='homepage',
name='view_all_news_url',
field=models.URLField(blank=True),
),
migrations.AddField(
model_name='homepage',
name='view_all_programs_link',
field=models.URLField(blank=True),
),
]
Loading

0 comments on commit da53cf4

Please sign in to comment.