Skip to content

Commit

Permalink
add pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyPatterson committed Feb 27, 2025
1 parent b542cbb commit 275b2ee
Show file tree
Hide file tree
Showing 16 changed files with 559 additions and 22 deletions.
1 change: 1 addition & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
ROOT_DIR / 'node_modules' / '@uktrade' / 'great-design-system' / 'dist' / 'components' / 'cta_banner',
ROOT_DIR / 'node_modules' / '@uktrade' / 'great-design-system' / 'dist' / 'components' / 'action_link',
ROOT_DIR / 'node_modules' / '@uktrade' / 'great-design-system' / 'dist' / 'components' / 'responsive_image',
ROOT_DIR / 'node_modules' / '@uktrade' / 'great-design-system' / 'dist' / 'components' / 'pagination',
ROOT_DIR
/ 'node_modules'
/ '@uktrade'
Expand Down

Large diffs are not rendered by default.

33 changes: 30 additions & 3 deletions international_online_offer/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django import forms
from django.contrib.postgres.fields import ArrayField
from django.core.paginator import Paginator
from django.db import models
from django.http import HttpResponseRedirect
from django.shortcuts import redirect, render
Expand Down Expand Up @@ -405,6 +406,10 @@ def get_context(self, request, *args, **kwargs):
IOOTradeShowPage.objects.live().filter(dbt_sectors__contains=[triage_data.sector])
)

paginator = Paginator(all_tradeshows, 20)
page = request.GET.get('page', 1)
paginated_tradeshows = paginator.get_page(page)

breadcrumbs = [
{'name': 'Home', 'url': '/international/'},
{
Expand All @@ -414,7 +419,8 @@ def get_context(self, request, *args, **kwargs):
]
context.update(
triage_data=triage_data,
all_tradeshows=all_tradeshows,
paginated_tradeshows=paginated_tradeshows,
num_pages=paginator.num_pages,
breadcrumbs=breadcrumbs,
)
self.set_ga360_payload(
Expand Down Expand Up @@ -459,10 +465,10 @@ class IOOTradeShowPage(BaseContentPage):
blank=True,
)
tradeshow_locale = models.CharField(blank=True, null=True)
tradeshow_city = models.TextField(
tradeshow_city = models.CharField(
choices=region_sector_helpers.generate_location_choices(include_regions=False), blank=True, null=True
)
tradeshow_region = models.TextField(
tradeshow_region = models.CharField(
choices=region_sector_helpers.generate_location_choices(include_cities=False), blank=True, null=True
)
tradeshow_link = models.URLField(blank=True, max_length=255, null=True)
Expand All @@ -489,6 +495,27 @@ class IOOTradeShowPage(BaseContentPage):
FieldPanel('tags'),
]

@property
def location_display(self):
output = ''

if self.tradeshow_locale:
output += self.tradeshow_locale

if self.tradeshow_city or self.tradeshow_region:
output += ', '

if self.tradeshow_city:
output += self.get_tradeshow_city_display()

if self.tradeshow_region:
output += ', '

if self.tradeshow_region:
output += self.get_tradeshow_region_display()

return output


class EYBArticlesPage(BaseContentPage):
parent_page_types = ['international_online_offer.EYBGuidePage', 'international_online_offer.EYBArticlesPage']
Expand Down
21 changes: 21 additions & 0 deletions international_online_offer/sass/components/article-list-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,24 @@
}

}

.listitem{
&-logo {
width: 60px;
height: 60px;
background-position: top;
background-repeat: no-repeat;
background-size: cover;
}
&-title-link {
text-decoration: none !important;

&::after {
content: '\f35d';
font-family: 'Font Awesome 5 Free';
font-weight: 900;
position: static;
padding-left: 5px;
}
}
}
29 changes: 29 additions & 0 deletions international_online_offer/static/svg/icon-planning-status.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions international_online_offer/templates/eyb/includes/list_item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{% load static %}
<div class="govuk-!-margin-bottom-6 govuk-!-padding-bottom-2 great-grey-bottom-border great-display-flex great-align-items-top great-gap">
<div>
{% if icon %}
<div class="listitem-logo"
style="background-image: url('{% static 'svg/icon-planning-status.svg' %}')"></div>
{% endif %}
</div>
<div class="great-full-width">
<a href="{{ url }}"
{% if rel %}rel="{{ rel }}"{% endif %}
{% if target %}target="{{ target }}"{% endif %}
class="govuk-heading-xs govuk-!-margin-bottom-1 great-heading-link great-ds-heading-link listitem-title-link">
<h2 class="govuk-heading-xs great-heading-link__heading govuk-!-font-size-24">
<span>{{ link_title }}</span>
</h2>
</a>
{% if location %}
<p class="govuk-body govuk-!-margin-bottom-1">
<i class="fa fa-map-marker-alt govuk-!-margin-right-1"
aria-hidden="true">
</i>
<span class="govuk-hint">{{ location }}</span>
</p>
{% endif %}
{% if description %}<p class="govuk-body govuk-!-margin-bottom-4">{{ description }}</p>{% endif %}
</div>
</div>
16 changes: 12 additions & 4 deletions international_online_offer/templates/eyb/trade_shows.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% load wagtailcore_tags %}
{% load wagtailimages_tags %}
{% load sector_filters %}
{% load range_from_1 from eyb_tags %}
{% load static %}
{% block head_title %}Trade events {{ block.super }}{% endblock %}
{% block meta_title %}Trade events {{ block.super }}{% endblock %}
Expand All @@ -22,14 +23,14 @@ <h1 class="govuk-heading-xl">UK events</h1>
</div>
</div>
<div class="govuk-grid-row govuk-!-margin-bottom-6">
{% if all_tradeshows %}
{% if paginated_tradeshows %}
<div class="govuk-grid-column-full">
{% for page in all_tradeshows %}
{% for page in paginated_tradeshows.object_list %}
{% if request.user.is_authenticated %}
{% include './includes/article_list_item.html' with rel="noopener noreferrer" target="_blank" url=page.specific.tradeshow_link link_title=page.specific.tradeshow_title link_description=page.specific.tradeshow_subheading %}
{% include './includes/list_item.html' with rel="noopener noreferrer" target="_blank" icon='icon' url=page.specific.tradeshow_link link_title=page.specific.tradeshow_title description=page.specific.tradeshow_subheading location=page.specific.location_display %}
{% else %}
{% url 'international_online_offer:signup' as signup_url %}
{% include './includes/article_list_item.html' with url=signup_url link_title=page.specific.tradeshow_title link_description=page.specific.tradeshow_subheading %}
{% include './includes/list_item.html' with url=signup_url link_title=page.specific.tradeshow_title link_description=page.specific.tradeshow_subheading %}
{% endif %}
{% endfor %}
</div>
Expand All @@ -45,6 +46,13 @@ <h1 class="govuk-heading-xl">UK events</h1>
</div>
{% endif %}
</div>
{% if num_pages > 1 %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
{% include '_numbered_pagination.html' with currentPage=request.GET.page totalPagesRange=num_pages|range_from_1 %}
</div>
</div>
{% endif %}
</div>
{% endblock %}
{% block feedback_reporter %}
Expand Down
6 changes: 6 additions & 0 deletions international_online_offer/templatetags/eyb_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ def get_salary_display_classes(context):
result['salary_card_class'] = 'govuk-grid-column-one-half'

return result


# for pagination component - check if tag is elsewhere
@register.filter
def range_from_1(value):
return range(1, value + 1)
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"dependencies": {
"@babel/polyfill": "^7.12.1",
"@fortawesome/fontawesome-free": "^5.15.4",
"@uktrade/great-design-system": "1.0.15",
"@uktrade/great-design-system": "1.1.4",
"govuk-frontend": "^4.5.0",
"great-styles": "github:uktrade/great-styles",
"prop-types": "15.7.2",
Expand Down
Loading

0 comments on commit 275b2ee

Please sign in to comment.