From: Michael Tremer Date: Wed, 5 Mar 2025 16:37:11 +0000 (+0000) Subject: lists: Remove stuff for Mailman X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c663d17b871cf978635471fa66a1456c0c15c4d5;p=ipfire.org.git lists: Remove stuff for Mailman We are moving away from mailman and therefore don't need this any more. I don't think that the new solution will have some API that we can use instead, so all of it is going for now. Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index 9c127b5e..097bbd8d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,7 +63,6 @@ backend_PYTHON = \ src/backend/httpclient.py \ src/backend/hwdata.py \ src/backend/iuse.py \ - src/backend/lists.py \ src/backend/messages.py \ src/backend/mirrors.py \ src/backend/misc.py \ @@ -95,7 +94,6 @@ web_PYTHON = \ src/web/fireinfo.py \ src/web/handlers.py \ src/web/iuse.py \ - src/web/lists.py \ src/web/location.py \ src/web/nopaste.py \ src/web/ui_modules.py \ @@ -278,11 +276,6 @@ templates_location_how_to_use_DATA = \ templates_location_how_to_usedir = $(templates_locationdir)/how-to-use -templates_lists_DATA = \ - src/templates/lists/index.html - -templates_listsdir = $(templatesdir)/lists - templates_messages_DATA = \ src/templates/messages/base.html \ src/templates/messages/base-promo.html \ diff --git a/src/backend/accounts.py b/src/backend/accounts.py index 8928033c..5ffc66a5 100644 --- a/src/backend/accounts.py +++ b/src/backend/accounts.py @@ -1569,11 +1569,6 @@ class Account(LDAPObject): # Disable the user await user.disable(text) - # Mailman - - async def get_lists(self): - return await self.backend.lists.get_subscribed_lists(self) - class Groups(Object): hidden_groups = ( diff --git a/src/backend/base.py b/src/backend/base.py index 7131127e..cfe7a78f 100644 --- a/src/backend/base.py +++ b/src/backend/base.py @@ -20,7 +20,6 @@ from . import database from . import fireinfo from . import httpclient from . import iuse -from . import lists from . import messages from . import mirrors from . import netboot @@ -205,10 +204,6 @@ class Backend(object): def groups(self): return accounts.Groups(self) - @lazy_property - def lists(self): - return lists.Lists(self) - @lazy_property def messages(self): return messages.Messages(self) diff --git a/src/backend/lists.py b/src/backend/lists.py deleted file mode 100644 index d2adff40..00000000 --- a/src/backend/lists.py +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/python3 - -import json -import urllib.parse - -from . import accounts -from . import misc - -class Lists(misc.Object): - @property - def url(self): - """ - Returns the base URL of a Mailman instance - """ - return self.settings.get("mailman-url") - - @property - def username(self): - return self.settings.get("mailman-username") - - @property - def password(self): - return self.settings.get("mailman-password") - - async def _request(self, method, url, data=None): - headers, body = {}, None - - # URL - url = urllib.parse.urljoin(self.url, url) - - # For GET requests, append query arguments - if method == "GET": - if data: - url = "%s?%s" % (url, urllib.parse.urlencode(data)) - - # For POST/PUT encode all arguments as JSON - elif method in ("POST", "PUT", "PATCH"): - headers |= { - "Content-Type" : "application/json", - } - - body = json.dumps(data) - - # Send the request and wait for a response - res = await self.backend.http_client.fetch(url, method=method, - headers=headers, body=body, - - # Authentication - auth_username=self.username, auth_password=self.password, - ) - - # Decode JSON response - body = json.loads(res.body) - - # XXX handle errors - - return body - - # Lists - - async def _get_lists(self, *args, **kwargs): - lists = [] - - # Fetch the response - response = await self._request(*args, **kwargs) - - # Fetch entries - for entry in response.get("entries", []): - list = List(self.backend, **entry) - lists.append(list) - - return lists - - async def get_lists(self): - """ - Fetches all available lists - """ - data = { - "advertised" : True, - } - - return await self._get_lists("GET", "/api/3.1/lists", data=data) - - async def get_subscribed_lists(self, account): - data = { - "subscriber" : account.email, - "role" : "member", - } - - return await self._get_lists("GET", "/api/3.1/members/find", data=data) - - -class List(misc.Object): - def init(self, list_id, **kwargs): - self.list_id = list_id - - # Store all other data - self.data = kwargs - - def __repr__(self): - return "" % self.list_id - - def __str__(self): - return self.display_name - - def __eq__(self, other): - if isinstance(other, self.__class__): - return self.list_id == other.list_id - - return NotImplemented - - def __lt__(self, other): - if isinstance(other, self.__class__): - return self.list_id < other.list_id - - return NotImplemented - - def __len__(self): - return self.data.get("member_count") - - @property - def display_name(self): - return self.data.get("display_name") - - @property - def description(self): - return self.data.get("description") - - @property - def archive_url(self): - return "https://lists.ipfire.org/hyperkitty/list/%s/" % self.list_id - - async def subscribe(self, account): - pass # XXX TODO - - async def unsubscribe(self, account): - pass # XXX TODO diff --git a/src/templates/lists/index.html b/src/templates/lists/index.html deleted file mode 100644 index eb90ab5a..00000000 --- a/src/templates/lists/index.html +++ /dev/null @@ -1,74 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Lists") }}{% end block %} - -{% block head %} - {% module OpenGraph( - title=_("IPFire - Mailing Lists"), - description="A Collection of every IPFire Mailing List", - ) %} -{% end block %} - -{% block container %} -
-
-
- - -

{{ _("Mailing Lists") }}

-
-
-
- -
-
- {% for list in sorted(lists) %} -
-
-

- {{ list }} -

- -
- {{ list.description }} -
- -
- - - - - - {{ _("Archive") }} - - - - {% if current_user %} - {% if list in subscribed_lists %} - - {{ _("Subscribed") }} - - {% else %} - - {{ _("Subscribe") }} - - {% end %} - {% end %} -
-
-
- {% end %} -
-
-{% end block %} diff --git a/src/templates/lists/subscribe.html b/src/templates/lists/subscribe.html deleted file mode 100644 index ef7c2d61..00000000 --- a/src/templates/lists/subscribe.html +++ /dev/null @@ -1,34 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Subscribe To %s") }} % {{ list }}{% end block %} - -{% block head %} - {% module OpenGraph( - title=_("IPFire - Subscribe to %s") % list, - description="Subscribe and you will receive emails concerning %s!" % list", - ) %} -{% end block %} - -{% block container %} -
-
-
-
{{ _("Subscribe To %s") }} % {{ list }}
- -
-

- {{ _("Subscribe and you will receive emails concerning %s!") }} % {{ list }} -

- - {% if list.description %} -

- {{ list.description }} -

- {% end %} -
- - -
-
-
-{% end block %} diff --git a/src/templates/lists/unsubscribe.html b/src/templates/lists/unsubscribe.html deleted file mode 100644 index d2a74b9a..00000000 --- a/src/templates/lists/unsubscribe.html +++ /dev/null @@ -1,35 +0,0 @@ -{% extends "../base.html" %} - -{% block title %}{{ _("Unsubscribe from %s") }} % {{ list }}{% end block %} - -{% block head %} - {% module OpenGraph( - title=_("IPFire - Unsubscribe from %s") % list, - description="Unsubscribe and you will no longer receive Emails concerning %s!" % list, - ) %} -{% end block %} - -{% block container %} -
-
-
-
{{ _("We'd Be Sorry To See You Go") }}
- -
-

- {{ _("If you unsubscribe, you will no longer receive important emails concerning %s") }} % {{ list }} - {{ _("There are plenty of benefits to remain subscribed:") }} -

- - {% if list.description %} -

- {{ list.description }} -

- {% end %} -
- - -
-
-
-{% end block %} diff --git a/src/web/__init__.py b/src/web/__init__.py index 2d0efca4..52a1fe36 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -23,7 +23,6 @@ from . import donate from . import downloads from . import fireinfo from . import iuse -from . import lists from . import location from . import nopaste from . import ui_modules @@ -188,9 +187,6 @@ class Application(tornado.web.Application): (r"/fireinfo/processors", fireinfo.ProcessorsHandler), (r"/fireinfo/releases", fireinfo.ReleasesHandler), - # Lists - (r"/lists", lists.IndexHandler), - # Confirm Email (r"/confirm-email/([a-z_][a-z0-9_-]{0,31})/(\w+)", auth.ConfirmEmailHandler), diff --git a/src/web/lists.py b/src/web/lists.py deleted file mode 100644 index 14256035..00000000 --- a/src/web/lists.py +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/python3 - -import tornado.web - -from . import base - -class IndexHandler(base.BaseHandler): - @tornado.web.authenticated - async def get(self): - # Fetch all available lists - lists = await self.backend.lists.get_lists() - - # Fetch all subscribed lists - subscribed_lists = await self.current_user.get_lists() - - self.render("lists/index.html", lists=lists, subscribed_lists=subscribed_lists)