diff --git a/foundation/organisation/admin.py b/foundation/organisation/admin.py index dc9a0979..258e0b24 100644 --- a/foundation/organisation/admin.py +++ b/foundation/organisation/admin.py @@ -3,8 +3,8 @@ from django.contrib import admin from .forms import PersonForm from .models import ( - Person, Board, NetworkGroup, - BoardMembership, NetworkGroupMembership, SideBarExtension + Person, NetworkGroup, + NetworkGroupMembership, SideBarExtension ) from cms.extensions import PageExtensionAdmin @@ -20,21 +20,6 @@ class PersonAdmin(reversion.admin.VersionAdmin): admin.site.register(Person, PersonAdmin) -class BoardMembershipInline(admin.TabularInline): - model = BoardMembership - - -class BoardAdmin(reversion.admin.VersionAdmin): - list_display = ('name',) - ordering = ('name',) - - prepopulated_fields = {"slug": ("name",)} - inlines = [BoardMembershipInline] - - -admin.site.register(Board, BoardAdmin) - - class NetworkGroupMembershipInline(admin.TabularInline): model = NetworkGroupMembership diff --git a/foundation/organisation/cms_apps.py b/foundation/organisation/cms_apps.py index 0693d163..5092b495 100644 --- a/foundation/organisation/cms_apps.py +++ b/foundation/organisation/cms_apps.py @@ -3,26 +3,6 @@ from django.utils.translation import gettext_lazy as _ -class BoardAppHook(CMSApp): - name = _("Board of Directors") - - def get_urls(self, page=None, language=None, **kwargs): - return ["foundation.organisation.urls.board"] - - -apphook_pool.register(BoardAppHook) - - -class AdvisoryBoardAppHook(CMSApp): - name = _("Advisory Board") - - def get_urls(self, page=None, language=None, **kwargs): - return ["foundation.organisation.urls.advisoryboard"] - - -apphook_pool.register(AdvisoryBoardAppHook) - - class NetworkGroupsAppHook(CMSApp): name = _("Network Groups") diff --git a/foundation/organisation/migrations/0025_remove_boardmembership_board_and_more.py b/foundation/organisation/migrations/0025_remove_boardmembership_board_and_more.py new file mode 100644 index 00000000..8f9e8096 --- /dev/null +++ b/foundation/organisation/migrations/0025_remove_boardmembership_board_and_more.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.3 on 2024-06-11 08:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisation', '0024_remove_unitmembership_person_and_more'), + ] + + operations = [ + migrations.RemoveField( + model_name='boardmembership', + name='board', + ), + migrations.RemoveField( + model_name='boardmembership', + name='person', + ), + migrations.DeleteModel( + name='Board', + ), + migrations.DeleteModel( + name='BoardMembership', + ), + ] diff --git a/foundation/organisation/models.py b/foundation/organisation/models.py index c00648ac..172f0180 100644 --- a/foundation/organisation/models.py +++ b/foundation/organisation/models.py @@ -6,7 +6,7 @@ from django.urls import reverse from django.urls.exceptions import NoReverseMatch from django.db import models -from django.utils.text import slugify, Truncator +from django.utils.text import slugify from django_countries.fields import CountryField @@ -114,45 +114,6 @@ def __repr__(self): return "".format(self.person.name, self.doing_type) -class Board(models.Model): - created_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - - name = models.CharField(max_length=100) - slug = models.SlugField(max_length=100, unique=True) - description = models.TextField() - - members = models.ManyToManyField("Person", through="BoardMembership") - - @property - def placeholder(self): - return Truncator(self.name).chars(10, truncate="...") + " (sidebar)" - - def get_absolute_url(self): - return reverse("board") - - def __str__(self): - return self.name - - -class BoardMembership(models.Model): - created_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - - title = models.CharField(max_length=100) - person = models.ForeignKey("Person", on_delete=models.CASCADE) - board = models.ForeignKey("Board", on_delete=models.CASCADE) - order = models.IntegerField( - blank=True, null=True, help_text="Higher numbers mean higher up in the list" - ) - - def __str__(self): - return self.person.name + " - " + self.title - - class Meta: - ordering = ["-order", "person__name"] - - class NetworkGroupManager(models.Manager): def countries(self): return self.get_queryset().filter(region_slug="") diff --git a/foundation/organisation/tests/test_views.py b/foundation/organisation/tests/test_views.py index 61dac7fb..c1f5a07a 100644 --- a/foundation/organisation/tests/test_views.py +++ b/foundation/organisation/tests/test_views.py @@ -1,126 +1,19 @@ from io import StringIO from django.urls import reverse -from django.utils.html import escape from django_webtest import WebTest -from unittest import skip from iso3166 import countries import csv from ..models import ( - Board, Person, NetworkGroup, NetworkGroupMembership, - BoardMembership, NowDoing, ) -class BoardViewTest(WebTest): - def setUp(self): - self.leonardo = Person.objects.create( - name="Leonardo (Leo)", - description="Turtle with a blue mask", - email="leonardo@tmnt.org", - ) - self.april = Person.objects.create( - name="April O'Neil", - description="Computer Programmer", - email="april@oneil.me", - twitter="april", - url="http://oneil.me", - ) - self.casey = Person.objects.create( - name="Casey Jones", - description="Hockey mask wearing vigilante", - email="casey.jones@newyorkcricketclub.com", - twitter="arnold", - ) - self.splinter = Person.objects.create( - name="Splinter", description="Ninja rat", email="splinter@tmnt.org" - ) - - self.board = Board.objects.create( - name="Board of directors", - slug="board", - description="The board consists of a rat", - ) - self.council = Board.objects.create( - name="Advisory Council", - slug="advisory-board", - description="Get a room you two!", - ) - - self.rat_board = BoardMembership.objects.create( - title="Director", person=self.splinter, board=self.board - ) - - self.april_council = BoardMembership.objects.create( - title="Technical consultant", person=self.april, board=self.council, order=2 - ) - self.casey_council = BoardMembership.objects.create( - title="Sport utilities consultant", - person=self.casey, - board=self.council, - order=1, - ) - self.leonardo_council = BoardMembership.objects.create( - title="Medical consultant", - person=self.leonardo, - board=self.council, - order=3, - ) - - @skip("Broken after the 2019 update") - def test_board(self): - response = self.app.get(reverse("board")) - self.assertTrue(self.board.name in response.text) - self.assertTrue(self.board.description in response.text) - - self.assertTrue(self.council.name not in response.text) - - self.assertTrue(self.splinter.name in response.text) - self.assertTrue(self.rat_board.title in response.text) - self.assertTrue(self.splinter.description in response.text) - self.assertTrue(self.splinter.email not in response.text) - - self.assertTrue(self.casey.name not in response.text) - self.assertTrue(self.april.name not in response.text) - - @skip("Broken after the 2019 update") - def test_advisory_council(self): - response = self.app.get(reverse("advisory-board")) - self.assertTrue(self.council.name in response.text) - self.assertTrue(self.council.description in response.text) - - self.assertTrue(self.board.name not in response.text) - - # April's name must be escaped because of the single quote in O'Neil - self.assertTrue(escape(self.april.name) in response.text) - self.assertTrue(self.april_council.title in response.text) - self.assertTrue(self.april.description in response.text) - self.assertTrue(self.april.email not in response.text) - self.assertTrue(self.april.twitter in response.text) - self.assertTrue(self.april.url in response.text) - - self.assertTrue(self.casey.name in response.text) - self.assertTrue(self.casey_council.title in response.text) - self.assertTrue(self.casey.description in response.text) - self.assertTrue(self.casey.email not in response.text) - self.assertTrue(self.casey.twitter in response.text) - - self.assertTrue(self.splinter.name not in response.text) - - def test_manual_order_of_units(self): - response = self.app.get(reverse("advisory-board")) - april = response.text.find(escape(self.april.name)) - leonardo = response.text.find(self.leonardo.name) - casey = response.text.find(self.casey.name) - self.assertTrue(leonardo < april < casey) - - class NetworkGroupDetailViewTest(WebTest): def setUp(self): self.otto = Person.objects.create( diff --git a/foundation/organisation/urls/advisoryboard.py b/foundation/organisation/urls/advisoryboard.py deleted file mode 100644 index fcdccbb5..00000000 --- a/foundation/organisation/urls/advisoryboard.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.urls import re_path - -from ..views import BoardView - -urlpatterns = [ - re_path( - r'^$', BoardView.as_view(board='advisory-board'), - name='advisory-board' - ), -] diff --git a/foundation/organisation/urls/board.py b/foundation/organisation/urls/board.py deleted file mode 100644 index 0dcd6c81..00000000 --- a/foundation/organisation/urls/board.py +++ /dev/null @@ -1,7 +0,0 @@ -from django.urls import re_path - -from ..views import BoardView - -urlpatterns = [ - re_path(r'^$', BoardView.as_view(board='our-board'), name='board'), -] diff --git a/foundation/organisation/views.py b/foundation/organisation/views.py index b96372ea..1c185d9a 100644 --- a/foundation/organisation/views.py +++ b/foundation/organisation/views.py @@ -6,17 +6,7 @@ from iso3166 import countries import csv -from .models import Board, NetworkGroup, NetworkGroupMembership, Person - - -class BoardView(DetailView): - model = Board - template_name = 'organisation/board_details.html' - board = None - - def get_object(self, *args, **kwargs): - # Try to find the board based on the slug or 404 - return get_object_or_404(Board, slug=self.board) +from .models import NetworkGroup, NetworkGroupMembership, Person class NetworkGroupDetailView(DetailView): diff --git a/foundation/tests/urls.py b/foundation/tests/urls.py index e90a24fe..3ca1248a 100644 --- a/foundation/tests/urls.py +++ b/foundation/tests/urls.py @@ -7,10 +7,6 @@ re_path(r"^login/", lambda x: x, name="login"), re_path(r"^search/", include("haystack.urls")), re_path(r"^jobs/", include("foundation.jobs.urls")), - re_path(r"^about/board", include("foundation.organisation.urls.board")), - re_path( - r"^about/advisory-board", include("foundation.organisation.urls.advisoryboard") - ), re_path(r"^network/", include("foundation.organisation.urls.networkgroups")), re_path(r"^", include("cms.urls")), ]