forked from Klimaat-Helpdesk/website
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added volunteer model, page, and view. Missing adding categories
- Loading branch information
Showing
9 changed files
with
244 additions
and
1 deletion.
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
klimaat_helpdesk/cms/migrations/0027_volunteerindexpage.py
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,29 @@ | ||
# Generated by Django 3.1.13 on 2021-09-18 09:50 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import wagtail.core.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('wagtailcore', '0060_fix_workflow_unique_constraint'), | ||
('cms', '0026_auto_20201108_1222'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='VolunteerIndexPage', | ||
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')), | ||
('subtitle', models.CharField(max_length=128)), | ||
('intro', wagtail.core.fields.RichTextField(blank=True)), | ||
('outro', wagtail.core.fields.RichTextField(blank=True)), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=('wagtailcore.page',), | ||
), | ||
] |
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
35 changes: 35 additions & 0 deletions
35
klimaat_helpdesk/templates/volunteers/includes/volunteer_block.html
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,35 @@ | ||
{% load static wagtailimages_tags i18n %} | ||
|
||
<div class="expert" id="{{ volunteer.pk }}"> | ||
<div class="expert__image-container"> | ||
{% image volunteer.picture fill-200x200 as image %} | ||
<img class="expert__image" src="{{ image.url }}" alt="{{ image.alt }}"> | ||
</div> | ||
|
||
<div class="expert__content"> | ||
<div class="expert__title-container"> | ||
<h3 class="expert__title">{{ volunteer.name }}</h3> | ||
{% if volunteer.website %} | ||
<a class="exper__linkedinlink" href="{{ volunteer.website }}"><span class="expert__link-icon"></span></a> | ||
{% endif %} | ||
{% if volunteer.linkedin_profile %} | ||
<a class="exper__linkedinlink" href="{{ volunteer.linkedin_profile }}"><span class="expert__linkedin-icon"></span></a> | ||
{% endif %} | ||
{% if volunteer.twitter_profile %} | ||
<a class="exper__linkedinlink" href="{{ volunteer.twitter_profile }}"><span class="expert__twitter-icon"></span></a> | ||
{% endif %} | ||
{% if volunteer.orcid_profile %} | ||
<a class="exper__linkedinlink" href="{{ volunteer.orcid_profile }}"><span class="expert__orcid-icon"></span></a> | ||
{% endif %} | ||
</div> | ||
<div class="expert__text richtext"> | ||
<p><strong>{{ volunteer.affiliation }}</strong></p> | ||
<p>{{ volunteer.bio }}</p> | ||
</div> | ||
<div class="expert__link"> | ||
<a class="expert__link-text" | ||
href="/answers_by/{{ volunteer.pk }}">{% trans 'Bekijk de vragen die beantwoord zijn door ' %} {{ volunteer.name }}</a> | ||
</div> | ||
|
||
</div> | ||
</div> |
66 changes: 66 additions & 0 deletions
66
klimaat_helpdesk/templates/volunteers/volunteers_list.html
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,66 @@ | ||
{% extends "base.html" %} | ||
{% load i18n static wagtailcore_tags%} | ||
|
||
{% block smokedglass %} | ||
{% endblock %} | ||
|
||
{% block content_area %} | ||
<div {% block smokedglass-class %}{% endblock %}> | ||
|
||
{% block head %} | ||
<div class="simple-header"> | ||
<div class="simple-header__wrapper"> | ||
<a class="simple-header__back-link" href="/"> | ||
<span class="simple-header__back-link-icon"></span> | ||
</a> | ||
|
||
<div class="simple-header__title-container"> | ||
<h1 class="simple-header__title">{{ page.title }}</h1> | ||
</div> | ||
|
||
<div class="simple-header__introduction-container"> | ||
<div class="simple-header__introduction"> | ||
{{ page.intro|richtext }} | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="expert-list"> | ||
<div class="expert-list__wrapper"> | ||
<div class="expert-list__experts"> | ||
{% for volunteer in volunteers %} | ||
{% include 'volunteers/includes/volunteer_block.html' with volunteer=volunteer %} | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="link-block"> | ||
<div class="link-block__wrapper"> | ||
<div class="link-block__title-container"> | ||
<h2 class="link-block__title"> | ||
{% trans 'Wie zijn de mensen achter de KlimaatHelpdesk' %} | ||
</h2> | ||
</div> | ||
|
||
<div class="link-block__text-container"> | ||
<div class="link-block__text richtext"> | ||
{{ page.outro|richtext }} | ||
</div> | ||
<a href="/about"> | ||
<button class="button"> | ||
<span class="button__text">{% trans 'Wie zijn wij?' %}</span> | ||
<span class="button__icon"></span> | ||
</button> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{% endblock %} | ||
</div> | ||
{% endblock content_area %} |
Empty file.
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,23 @@ | ||
from django.utils.translation import gettext_lazy as _ | ||
from django.contrib import admin | ||
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register | ||
|
||
from klimaat_helpdesk.volunteers.models import Volunteer | ||
|
||
|
||
class VolunteerAdmin(ModelAdmin): | ||
model = Volunteer | ||
menu_label = _('Volunteers') | ||
menu_icon = 'user' | ||
menu_order = 280 | ||
add_to_settings_menu = False | ||
exclude_from_explorer = False | ||
list_display = ('name', 'affiliation', 'email') | ||
search_fields = ('name', 'affiliation') | ||
|
||
|
||
modeladmin_register(VolunteerAdmin) | ||
|
||
admin.site.register([ | ||
Volunteer, | ||
]) |
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,7 @@ | ||
from django.apps import AppConfig | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class VolunteersConfig(AppConfig): | ||
name = "klimaat_helpdesk.volunteers" | ||
verbose_name = _("Volunteers") |
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,57 @@ | ||
from django.db import models | ||
from django.utils.translation import ugettext_lazy as _ | ||
from taggit.managers import TaggableManager | ||
from wagtail.admin.edit_handlers import FieldPanel | ||
from wagtail.images.edit_handlers import ImageChooserPanel | ||
|
||
from wagtail.snippets.models import register_snippet | ||
|
||
@register_snippet | ||
class Volunteer(models.Model): | ||
""" Volunteers are people who contribute time to Klimaat Helpdesk. The model is similar to those of | ||
experts, with some minor differences that's why it is not a plain inherited object. | ||
""" | ||
|
||
name = models.CharField(_('name'), max_length=255, null=False, blank=False) | ||
email = models.EmailField(_('email'), null=True, blank=True) | ||
bio = models.TextField(verbose_name=_('biography'), null=False, blank=False) | ||
picture = models.ForeignKey('wagtailimages.Image', null=True, related_name='+', on_delete=models.SET_NULL) | ||
areas_expertise = TaggableManager(verbose_name=_('areas of expertise')) | ||
affiliation = models.CharField(_('Affiliation'), blank=False, max_length=128) | ||
website = models.URLField(_('Website'), blank=True) | ||
twitter_profile = models.URLField(_('Twitter Profile'), blank=True, null=True) | ||
linkedin_profile = models.URLField(_('LinkedIn Profile'), blank=True, null=True) | ||
orcid_profile = models.URLField(_('OrcID Link'), blank=True, null=True) | ||
creation_date = models.DateTimeField(auto_now_add=True) | ||
last_updated = models.DateTimeField(auto_now_add=True) | ||
active_since = models.DateTimeField(null=True, auto_now=False, default=None) | ||
|
||
panels = [ | ||
FieldPanel('name'), | ||
ImageChooserPanel('picture', heading="Volunteer's photo, 1:1 aspect ratio (square) works best"), | ||
FieldPanel('email'), | ||
FieldPanel('bio'), | ||
FieldPanel('affiliation'), | ||
FieldPanel('areas_expertise', heading="Areas of expertise. A maximum of 16 characters per word is recommended for optimal mobile display"), | ||
FieldPanel('website'), | ||
FieldPanel('twitter_profile'), | ||
FieldPanel('linkedin_profile'), | ||
FieldPanel('orcid_profile'), | ||
] | ||
|
||
def __str__(self): | ||
return f"{self.name}" | ||
|
||
@property | ||
def twitter_username(self): | ||
if self.twitter_profile: | ||
if self.twitter_profile.endswith('/'): | ||
self.twitter_profile = self.twitter_profile[:-1] | ||
self.save() | ||
twitter_username = self.twitter_profile.split('/')[-1] | ||
return twitter_username | ||
|
||
class Meta: | ||
ordering = ['name', ] | ||
|
||
|