Skip to content
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

Rename employee to staff #96

Merged
merged 5 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nmhs_cms/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"pages.organisation_pages.projects",
"pages.organisation_pages.tenders",
"pages.organisation_pages.vacancies",
"pages.organisation_pages.orgchart",
"pages.organisation_pages.staff",
"pages.email_subscription",
"pages.surveys",
"pages.search",
Expand Down
2 changes: 1 addition & 1 deletion pages/organisation_pages/organisation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class OrganisationIndexPage(MetadataPageMixin, Page):
'vacancies.VacanciesPage',
'projects.ProjectIndexPage',
'tenders.TendersPage',
'orgchart.OrganisationChartPage'
'staff.StaffPage',
'flex_page.FlexPage',
]
show_in_menus_default = True
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

67 changes: 0 additions & 67 deletions pages/organisation_pages/orgchart/views.py

This file was deleted.

23 changes: 0 additions & 23 deletions pages/organisation_pages/orgchart/wagtail_hooks.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.apps import AppConfig


class OrgchartConfig(AppConfig):
class StaffConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'pages.organisation_pages.orgchart'
name = 'pages.organisation_pages.staff'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.7 on 2024-04-18 20:10
# Generated by Django 4.2.7 on 2024-04-23 07:18

from django.db import migrations, models
import django.db.models.deletion
Expand All @@ -24,39 +24,47 @@ class Migration(migrations.Migration):
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('desc', wagtail.fields.RichTextField(blank=True, null=True)),
('order', models.PositiveIntegerField(default=0, verbose_name='Order')),
],
options={
'ordering': ['order'],
},
),
migrations.CreateModel(
name='OrganisationChartPage',
name='StaffPage',
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')),
('banner_title', models.CharField(max_length=255, verbose_name='Banner Title')),
('banner_subtitle', models.CharField(blank=True, max_length=255, null=True, verbose_name='Banner Subtitle')),
('call_to_action_button_text', models.CharField(blank=True, max_length=100, null=True, verbose_name='Call to action button text')),
('introduction_heading', models.CharField(blank=True, default='MEET OUR MEMBERS', help_text='Introduction section heading', max_length=100, null=True, verbose_name='Introduction Heading')),
('introduction_title', models.CharField(blank=True, default='Forecasting the Future: Weather & Climate at the Frontline', help_text='Introduction section title', max_length=100, null=True, verbose_name='Introduction Title')),
('introduction_text', wagtail.fields.RichTextField(blank=True, default="We're a team of scientists, meteroologist, analysists, software engineers and researchers.We are invigorated by challenging weather phenomena, thrive on surpassing previous records, and are dedicated to improving the world's conditions with each passing day. ", help_text='Introduction section description', null=True, verbose_name='Introduction text')),
('banner_image', models.ForeignKey(blank=True, help_text='A high quality banner image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image', verbose_name='Banner Image')),
('call_to_action_related_page', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.page', verbose_name='Call to action related page')),
('search_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image', verbose_name='Search image')),
],
options={
'abstract': False,
'verbose_name': 'Staff Page',
},
bases=(wagtailmetadata.models.WagtailImageMetadataMixin, 'wagtailcore.page', models.Model, wagtailcache.cache.WagtailCacheMixin),
),
migrations.CreateModel(
name='Employee',
name='StaffMember',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('sort_order', models.IntegerField(blank=True, editable=False, null=True)),
('name', models.CharField(help_text='First and Last names of employee', max_length=100, verbose_name="Employee's name")),
('role', models.CharField(help_text='The role/position of the employee', max_length=100, verbose_name="Employee's role")),
('bio', wagtail.fields.RichTextField(blank=True, help_text='Optional Summary biography of the employe', null=True, verbose_name='Employee Biography')),
('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='orgchart.department', verbose_name="Employee's Department")),
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='employees', to='orgchart.organisationchartpage')),
('photo', models.ForeignKey(blank=True, help_text='A high quality square image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image', verbose_name='Employee Image')),
('name', models.CharField(help_text='First and Last names of Staff member', max_length=100, verbose_name="Staff member's name")),
('role', models.CharField(help_text='The role/position of the Staff member', max_length=100, verbose_name="Staff member's role")),
('bio', wagtail.fields.RichTextField(blank=True, help_text='Optional Summary biography of the Staff member', null=True, verbose_name='Staff member Biography')),
('department', models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to='staff.department', verbose_name="Staff member's Department")),
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='staffmembers', to='staff.staffpage')),
('photo', models.ForeignKey(blank=True, help_text='A high quality square image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image', verbose_name="Staff member's Profile Image")),
],
options={
'verbose_name': 'Staff Member',
'verbose_name_plural': 'Staff Members',
'ordering': ['sort_order'],
'abstract': False,
},
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ class Meta:
ordering = ['order']


class OrganisationChartPage(AbstractBannerPage):
template = 'orgchart/orgchart_page.html'
class StaffPage(AbstractBannerPage):
template = 'staff/staff_page.html'
parent_page_types = ['organisation.OrganisationIndexPage']
subpage_types = []
show_in_menus_default = True

max_count = 1

introduction_heading = models.CharField(max_length=100, verbose_name=_('Introduction Heading'),
help_text=_("Introduction section heading"), null=True, blank=True, default='MEET OUR TEAM')
help_text=_("Introduction section heading"), null=True, blank=True, default='MEET OUR MEMBERS')
introduction_title = models.CharField(max_length=100, verbose_name=_('Introduction Title'),
help_text=_("Introduction section title"), null=True, blank=True, default='Weather and Climate through Us')
help_text=_("Introduction section title"), null=True, blank=True, default="Forecasting the Future: Weather & Climate at the Frontline")
introduction_text = RichTextField(features=SUMMARY_RICHTEXT_FEATURES, verbose_name=_('Introduction text'),
help_text=_("Introduction section description"), null=True, blank=True, default="We're a team of scientists, meteroologist, analysists, software engineers and researchers.We are invigorated by challenging weather phenomena, thrive on surpassing previous records, and are dedicated to improving the world's conditions with each passing day. ")

Expand All @@ -58,36 +58,35 @@ class OrganisationChartPage(AbstractBannerPage):
FieldPanel('introduction_title'),
FieldPanel('introduction_text'),
], heading=_('Introduction Section')),
InlinePanel('employees', heading=_("Employee"), label=_("Employee")),
InlinePanel('staffmembers', heading=_("Staff"), label=_("Staff")),
]

@cached_property
def all_departments(self):
# Annotate the queryset with the count of employees per department
departments_with_employee_count = Employee.objects.values('department__name').annotate(employee_count=Count('department')).order_by('department__order')

departments_with_staff_count = StaffMember.objects.values('department__name').annotate(staffmembers_count=Count('department')).order_by('department__order')
# Filter departments with at least one employee
departments_with_employees = departments_with_employee_count.filter(employee_count__gt=0)
departments_with_staff = departments_with_staff_count.filter(staffmembers_count__gt=0)

return departments_with_employees
return departments_with_staff

class Meta:
verbose_name = _("Staff/Management Page")
verbose_name = _("Staff Page")


class Employee(Orderable):
page = ParentalKey(OrganisationChartPage, on_delete=models.CASCADE, related_name="employees")
name = models.CharField(max_length=100,verbose_name=_("Employee's name"),
help_text=_("First and Last names of employee"))
role = models.CharField(max_length=100, verbose_name=_("Employee's role"),
help_text=_("The role/position of the employee"))
bio = RichTextField(features=SUMMARY_RICHTEXT_FEATURES, null=True, blank=True,verbose_name=_("Employee Biography"),
help_text=_("Optional Summary biography of the employe"))
department = models.ForeignKey(Department, on_delete=models.PROTECT, blank=True, null=True,
verbose_name=_("Employee's Department"))
class StaffMember(Orderable):
page = ParentalKey(StaffPage, on_delete=models.CASCADE, related_name="staffmembers")
name = models.CharField(max_length=100,verbose_name=_("Staff member's name"),
help_text=_("First and Last names of Staff member"))
role = models.CharField(max_length=100, verbose_name=_("Staff member's role"),
help_text=_("The role/position of the Staff member"))
bio = RichTextField(features=SUMMARY_RICHTEXT_FEATURES, null=True, blank=True,verbose_name=_("Staff member Biography"),
help_text=_("Optional Summary biography of the Staff member"))
department = models.ForeignKey(Department, on_delete=models.PROTECT, blank=False, null=True,
verbose_name=_("Staff member's Department"))
photo = models.ForeignKey(
'wagtailimages.Image',
verbose_name=_("Employee Image"),
verbose_name=_("Staff member's Profile Image"),
help_text=_("A high quality square image"),
null=True,
blank=True,
Expand All @@ -104,8 +103,8 @@ class Employee(Orderable):
]

class Meta:
verbose_name = "{name} ({role})"
verbose_name_plural = "{name} ({role})"
verbose_name = _("Staff Member")
verbose_name_plural = _("Staff Members")
ordering = ['sort_order']


Expand Down
Loading