diff --git a/foundation/organisation/admin.py b/foundation/organisation/admin.py index 264c5433..dc9a0979 100644 --- a/foundation/organisation/admin.py +++ b/foundation/organisation/admin.py @@ -3,8 +3,7 @@ from django.contrib import admin from .forms import PersonForm from .models import ( - Person, Unit, Board, - NetworkGroup, UnitMembership, + Person, Board, NetworkGroup, BoardMembership, NetworkGroupMembership, SideBarExtension ) @@ -21,20 +20,6 @@ class PersonAdmin(reversion.admin.VersionAdmin): admin.site.register(Person, PersonAdmin) -class UnitMembershipInline(admin.TabularInline): - model = UnitMembership - - -class UnitAdmin(reversion.admin.VersionAdmin): - list_display = ('name',) - ordering = ('name',) - - inlines = [UnitMembershipInline] - - -admin.site.register(Unit, UnitAdmin) - - class BoardMembershipInline(admin.TabularInline): model = BoardMembership diff --git a/foundation/organisation/cms_apps.py b/foundation/organisation/cms_apps.py index cb636195..0693d163 100644 --- a/foundation/organisation/cms_apps.py +++ b/foundation/organisation/cms_apps.py @@ -3,16 +3,6 @@ from django.utils.translation import gettext_lazy as _ -class UnitsAppHook(CMSApp): - name = _("Units") - - def get_urls(self, page=None, language=None, **kwargs): - return ["foundation.organisation.urls.units"] - - -apphook_pool.register(UnitsAppHook) - - class BoardAppHook(CMSApp): name = _("Board of Directors") diff --git a/foundation/organisation/migrations/0024_remove_unitmembership_person_and_more.py b/foundation/organisation/migrations/0024_remove_unitmembership_person_and_more.py new file mode 100644 index 00000000..a440dd5c --- /dev/null +++ b/foundation/organisation/migrations/0024_remove_unitmembership_person_and_more.py @@ -0,0 +1,27 @@ +# Generated by Django 4.2.3 on 2024-06-11 07:59 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisation', '0023_sidebarextension_image'), + ] + + operations = [ + migrations.RemoveField( + model_name='unitmembership', + name='person', + ), + migrations.RemoveField( + model_name='unitmembership', + name='unit', + ), + migrations.DeleteModel( + name='Unit', + ), + migrations.DeleteModel( + name='UnitMembership', + ), + ] diff --git a/foundation/organisation/models.py b/foundation/organisation/models.py index 8f47a581..c00648ac 100644 --- a/foundation/organisation/models.py +++ b/foundation/organisation/models.py @@ -114,41 +114,6 @@ def __repr__(self): return "".format(self.person.name, self.doing_type) -class Unit(models.Model): - created_at = models.DateTimeField(auto_now_add=True) - updated_at = models.DateTimeField(auto_now=True) - - name = models.CharField(max_length=100) - members = models.ManyToManyField("Person", through="UnitMembership") - order = models.IntegerField( - blank=True, null=True, help_text="Higher numbers mean higher up in the list" - ) - - def __str__(self): - return self.name - - class Meta: - ordering = ["-order", "name"] - - -class UnitMembership(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) - unit = models.ForeignKey("Unit", 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 Board(models.Model): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) diff --git a/foundation/organisation/tests/test_views.py b/foundation/organisation/tests/test_views.py index 11909d2b..61dac7fb 100644 --- a/foundation/organisation/tests/test_views.py +++ b/foundation/organisation/tests/test_views.py @@ -11,170 +11,13 @@ from ..models import ( Board, Person, - Unit, NetworkGroup, NetworkGroupMembership, BoardMembership, - UnitMembership, NowDoing, ) -class UnitListViewTest(WebTest): - def setUp(self): - self.donatello = Person.objects.create( - name="Donatello (Donnie)", - description="Turtle with a purple mask", - email="donatello@tmnt.org", - ) - self.leonardo = Person.objects.create( - name="Leonardo (Leo)", - description="Turtle with a blue mask", - email="leonardo@tmnt.org", - ) - self.raphael = Person.objects.create( - name="Raphael (Raph)", - description="Turtle with a red mask", - email="raphael@tmnt.org", - twitter="raph", - url="http://tmnt.org/raphael", - ) - self.rocksteady = Person.objects.create( - name="Rocksteady", - description="Mutant rhinoceros", - email="rocksteady@shreddercorp.org", - twitter="rocksteady", - url="http://beboprocksteady.com", - ) - self.april = Person.objects.create( - name="April O'Neil", - description="Computer Programmer", - email="april@oneil.me", - twitter="april", - url="http://oneil.me", - ) - self.splinter = Person.objects.create( - name="Splinter", description="Ninja rat", email="splinter@tmnt.org" - ) - - self.turtles = Unit.objects.create(name="Turtles") - self.footclan = Unit.objects.create(name="Foot Clan") - self.masters = Unit.objects.create(name="Ninja Masters", order=1) - - self.turtle_donatello = UnitMembership.objects.create( - title="Hacker", person=self.donatello, unit=self.turtles - ) - - self.turtle_leonardo = UnitMembership.objects.create( - title="Leader", person=self.leonardo, unit=self.turtles, order=1 - ) - - self.turtle_raphael = UnitMembership.objects.create( - title="Bad boy", person=self.raphael, unit=self.turtles - ) - - self.evil_rocksteady = UnitMembership.objects.create( - title="Comic relief", person=self.rocksteady, unit=self.footclan - ) - - self.master_splinter = UnitMembership.objects.create( - title="Master", person=self.splinter, unit=self.masters - ) - - def test_units_in_response(self): - response = self.app.get(reverse("units")) - self.assertTrue(self.turtles.name in response) - self.assertTrue(self.footclan.name in response) - - def test_unit_member_in_response(self): - response = self.app.get(reverse("units")) - self.assertTrue(self.leonardo.name in response) - self.assertTrue(self.raphael.name in response) - self.assertTrue(self.rocksteady.name in response) - - def test_non_unit_member_not_in_response(self): - response = self.app.get(reverse("units")) - self.assertTrue(self.april.name not in response) - - def test_unit_members_in_units(self): - response = self.app.get(reverse("units")) - - # Units are ordered alphabetically - footclan = response.text.find(self.footclan.name) - turtles = response.text.find(self.turtles.name) - self.assertTrue(footclan < turtles) - - # Unit members are ordered alphabetically - # unless order is overwritten - donatello = response.text.find(self.donatello.name) - leonardo = response.text.find(self.leonardo.name) - raphael = response.text.find(self.raphael.name) - rocksteady = response.text.find(self.rocksteady.name) - self.assertTrue(footclan < rocksteady < turtles) - self.assertTrue(turtles < leonardo < donatello < raphael) - - def test_description_in_response(self): - response = self.app.get(reverse("units")) - self.assertTrue(self.leonardo.description in response) - self.assertTrue(self.raphael.description in response) - self.assertTrue(self.rocksteady.description in response) - self.assertTrue(self.april.description not in response) - - def test_email_in_response(self): - response = self.app.get(reverse("units")) - self.assertTrue(self.leonardo.email in response) - self.assertTrue(self.raphael.email in response) - self.assertTrue(self.rocksteady.email in response) - self.assertTrue(self.april.email not in response) - - def test_twitter_in_response(self): - response = self.app.get(reverse("units")) - twitter_url = "https://twitter.com/{handle}" - twitter_raphael = twitter_url.format(handle=self.raphael.twitter) - twitter_rocksteady = twitter_url.format(handle=self.rocksteady.twitter) - twitter_april = twitter_url.format(handle=self.april.twitter) - self.assertTrue(twitter_raphael in response) - self.assertTrue(twitter_rocksteady in response) - self.assertTrue(twitter_april not in response) - - # Raphael is the last turtle. We assume that the unit list will be - # where the first occurance of the names come up (since main content - # should come before sidebars). - # Leonardo doesn't use Twitter so there shouldn't be a twitter url - # between the last Leo's name and Raph's name - leonardo = response.text.find(self.leonardo.name) - raphael = response.text.find(self.raphael.name) - twitter = response.text.find("https://twitter.com/", leonardo, raphael) - self.assertTrue(twitter == -1) - - @skip("Broken after the 2019 update") - def test_url_in_response(self): - response = self.app.get(reverse("units")) - - self.assertTrue(self.raphael.url in response) - self.assertTrue(self.rocksteady.url in response) - self.assertTrue(self.april.url not in response) - - # Raphael is the last turtle. We assume that the unit list will be - # where the first occurance of the names come up (since main content - # should come before sidebars). - # Leonardo doesn't have a website so there shouldn't be a - # 'Personal website' between the last Leo's name and Raph's name - - leonardo = response.text.find(self.leonardo.name) - raphael = response.text.find(self.raphael.name) - website = response.text.find("Personal website", leonardo, raphael) - self.assertTrue(website == -1) - - def test_manual_order_of_units(self): - response = self.app.get(reverse("units")) - masters = response.text.find(self.masters.name) - turtles = response.text.find(self.turtles.name) - footclan = response.text.find(self.footclan.name) - - self.assertTrue(masters < footclan < turtles) - - class BoardViewTest(WebTest): def setUp(self): self.leonardo = Person.objects.create( diff --git a/foundation/organisation/urls/units.py b/foundation/organisation/urls/units.py deleted file mode 100644 index 517a1467..00000000 --- a/foundation/organisation/urls/units.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.urls import re_path -from django.views.generic.list import ListView - -from ..models import Unit -from ..views import PersonView - -urlpatterns = [ - re_path(r'^$', ListView.as_view(model=Unit), name='units'), - re_path(r'^(?P\d+)/$', PersonView.as_view(), name='person') -] diff --git a/foundation/search/templates/search/results.html b/foundation/search/templates/search/results.html index 86253c8e..05fc062e 100644 --- a/foundation/search/templates/search/results.html +++ b/foundation/search/templates/search/results.html @@ -4,11 +4,6 @@ {% include "search/cms/page.html" %} {% endwith %} {% endif %} -{% if search_result.content_type == 'organisation.person' %} - {% with person=search_result.object %} - {% include "search/organisation/person.html" %} - {% endwith %} -{% endif %} {% if search_result.content_type == 'organisation.networkgroup' %} {% with networkgroup=search_result.object %} {% include "search/organisation/networkgroup.html" %}