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 <michael.tremer@ipfire.org>
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 \
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 \
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 \
# 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 = (
from . import fireinfo
from . import httpclient
from . import iuse
-from . import lists
from . import messages
from . import mirrors
from . import netboot
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)
+++ /dev/null
-#!/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 "<List %s>" % 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
+++ /dev/null
-{% 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 %}
- <section class="hero is-primary">
- <div class="hero-body">
- <div class="container">
- <nav class="breadcrumb" aria-label="breadcrumbs">
- <ul>
- <li>
- <a href="/">
- {{ _("Home") }}
- </a>
- </li>
- <li class="is-active">
- <a href="#" aria-current="page">{{ _("Mailing Lists") }}</a>
- </li>
- </ul>
- </nav>
-
- <h1 class="title">{{ _("Mailing Lists") }}</h1>
- </div>
- </div>
- </section>
-
- <section class="section">
- <div class="container">
- {% for list in sorted(lists) %}
- <div class="block">
- <div class="box">
- <h4 class="title is-4">
- {{ list }}
- </h4>
-
- <h6 class="subtitle is-6">
- {{ list.description }}
- </h6>
-
- <div class="buttons">
- <a class="button is-light" href="{{ list.archive_url }}">
- <span class="icon-text">
- <span class="icon">
- <i class="fa-solid fa-inbox"></i>
- </span>
- <span>{{ _("Archive") }}</span>
- </span>
- </a>
-
- {% if current_user %}
- {% if list in subscribed_lists %}
- <a class="button is-success is-outlined" href="/lists/{{ list.list_id }}/unsubscribe">
- {{ _("Subscribed") }}
- </a>
- {% else %}
- <a class="button is-success" href="/lists/{{ list.list_id }}/subscribe">
- {{ _("Subscribe") }}
- </a>
- {% end %}
- {% end %}
- </div>
- </div>
- </div>
- {% end %}
- </div>
- </section>
-{% end block %}
+++ /dev/null
-{% extends "../base.html" %}\r
-\r
-{% block title %}{{ _("Subscribe To %s") }} % {{ list }}{% end block %}\r
-\r
-{% block head %}\r
- {% module OpenGraph(\r
- title=_("IPFire - Subscribe to %s") % list,\r
- description="Subscribe and you will receive emails concerning %s!" % list",\r
- ) %}\r
-{% end block %}\r
-\r
-{% block container %}\r
- <div class="columns is-centered">\r
- <div class="column is-one-third-desktop">\r
- <div class="notification my-auto">\r
- <h5 class="title is-5">{{ _("Subscribe To %s") }} % {{ list }}</h5>\r
-\r
- <div class="content">\r
- <p>\r
- {{ _("Subscribe and you will receive emails concerning %s!") }} % {{ list }}\r
- </p>\r
-\r
- {% if list.description %}\r
- <p>\r
- {{ list.description }}\r
- </p>\r
- {% end %}\r
- </div>\r
-\r
- <!-- Hier sollte dann wahrscheinlich noch ein Button zum subscriben bzw. unsubscriben hin -->\r
- </div>\r
- </div>\r
- </div>\r
-{% end block %}\r
+++ /dev/null
-{% extends "../base.html" %}\r
-\r
-{% block title %}{{ _("Unsubscribe from %s") }} % {{ list }}{% end block %}\r
-\r
-{% block head %}\r
- {% module OpenGraph(\r
- title=_("IPFire - Unsubscribe from %s") % list,\r
- description="Unsubscribe and you will no longer receive Emails concerning %s!" % list,\r
- ) %}\r
-{% end block %}\r
-\r
-{% block container %}\r
- <div class="columns is-centered">\r
- <div class="column is-one-third-desktop">\r
- <div class="notification my-auto">\r
- <h5 class="title is-5">{{ _("We'd Be Sorry To See You Go") }}</h5>\r
-\r
- <div class="content">\r
- <p>\r
- {{ _("If you unsubscribe, you will no longer receive important emails concerning %s") }} % {{ list }}\r
- {{ _("There are plenty of benefits to remain subscribed:") }}\r
- </p>\r
-\r
- {% if list.description %}\r
- <p>\r
- {{ list.description }}\r
- </p>\r
- {% end %}\r
- </div>\r
-\r
- <!-- Hier sollte dann wahrscheinlich noch ein Button zum subscriben bzw. unsubscriben hin -->\r
- </div>\r
- </div>\r
- </div>\r
-{% end block %}\r
from . import downloads
from . import fireinfo
from . import iuse
-from . import lists
from . import location
from . import nopaste
from . import ui_modules
(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),
+++ /dev/null
-#!/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)