Commit Graph

225 Commits

Author SHA1 Message Date
ac30acb266 Bump some cache times up
About page goes from 10min to 30min (short cache to rotate the
quotes).

Search results go from 15min to 30 min.

Dynamic CSS goes from 6 hours to 48 hours, since we use cache busting
URLs everywhere these days, and on average they change very seldom.
2021-02-18 17:15:25 +01:00
171c6b5be1 Send moderation notice to moderators even when no changes are made
When a moderation notice was sent without making any actual state
changse (so not approving, rejecting or returning), the notice would
only be sent to the submitter, and not to the moderators. Which
obviously can lead to some confusion. So make sure that it's always sent
there as well, and the message clearly states that it was just a
comment.
2021-01-17 16:20:43 +01:00
3c94c2cf24 Clarify the instructions for how/when to add new organisations 2021-01-14 17:26:42 +01:00
e1e5de0c70 Move the hint message for organisation to its own file
This is way too much text to duplicate across many places..
2021-01-14 16:49:42 +01:00
1104140da4 Add organisation "name" to moderation fields
This makes it slightly easier to perform appropriate moderation
review on an organisation.
2020-11-19 09:36:04 -05:00
8cd2181be8 Add note to form when creating new organisations
In particular, highlight that an organisation is not needed to
participate on lists, send bug reports etc. Caused by the number of
people who apparently get this wrong previously.
2020-11-12 18:53:18 +01:00
ea9becd746 Re-do markdown handling for better user experience and security
* Get rid of the django_markwhat dependency, and implement our own
  classes to get more control. In passing also remove django-markdown,
  because we never used that.
* Instead of trying to clean markdown with regexps, use the bleach
  library (NEW DEPENDENCY) with special whitelisting of allowed tags
  based off standard markdown. This means that one can input links or
  formatting in HTML if one prefers, as long as it renders to the same
  subset of tags that markdown allows.
* Replace javascript based client side preview with an actual call to a
  preview URL that renders the exact result using the same function,
  since the use of showdown on the client was increasingly starting to
  differ from the server, and since that cannot be kept secure the same
  way. Rewrite the client side javascript to work better with the now
  longer interval between updates of the preview.

Long in planning, but never got around to it.

Suggestion to use bleach for escaping from David Fetter.
2020-11-12 18:52:04 +01:00
47e1ef2bce Don't remove news articles when attached email is removed
At this point, we set the field to PROTECTED and dont' allow the
deletion at all. In the future we might want to allow a set null
operation, but for now we require the users to contact webmaster@ to
handle that, so we keep it under control.
2020-11-11 15:36:51 +01:00
f4d7c746fd Add a filter for getting language name from code
This adds a requirement on the Babel module in python.
2020-10-28 16:39:27 +01:00
bc1c7fa1ea Add filter to list all templates in a directory 2020-10-28 16:39:27 +01:00
1d3482df09 Add static og: tag to the index page 2020-10-22 14:30:10 +02:00
8a0037c86f Fix regression that prevented accessing new organisation page
The addition of the fieldsets did not account for the fields
themselves from being removed from the new organisation form.
The OrganisationForm now removes the appropriate fieldset when
the fields are not available in this form.
2020-10-07 17:59:22 -04:00
1960b89a06 Add fieldsets to the organisation form 2020-10-07 18:53:45 +02:00
669d2f733c Add support for fieldsets to forms
This makes it possible to define a fieldset which has a legend and a
description, to split up a large form into multiple visual components.
2020-10-07 18:53:45 +02:00
d409e7dfd1 Make the add manager field more clear in the organisation form
Make it clear that one should enter the email address, not username, to
add a manager, and that it should be an existing account.
2020-10-07 12:25:48 +02:00
a6a860f092 Fix merging of organisations
This has been broken since the OneToOne change in 2016 and since the
addition of pugs in 2013. Clearly not much used functionality.
2020-09-26 17:00:26 +02:00
d7d5b105d1 Improve moderation messages somewhat
Change the subject to use the title of the object instead of the id, and
include a link to the moderation page. There's surely more to be done,
but this is a decent start.
2020-09-18 11:13:36 +02:00
eec44cb08e Add admin function to initiate user password reset
This will trigger the same reset-your-password email as a user initiated
one, but it'll cut out one step and be a bit more user friendly...

Also, if this is done with an OAuth connected account, it will be
converted into a regular one (something we don't allow the end user to
do, for support reasons)

This also adds an entry to the user editor in the admin view that shows
if the user *is* an oauth user or not, or if they might have an old
"unmigrated" password.
2020-09-18 09:14:21 +02:00
6d5319371f Properly verify owner of organisation in all forms 2020-09-17 14:37:58 +02:00
71f27f8b11 Remove form that no longer does anyting non-default 2020-09-16 19:59:18 +02:00
07696d8050 Add an inline to view and edit organisation emalis
The ability to do this was lost when we moved to multiple emails per
organisation since it's no longer in the main table, so add it back as
an inline.
2020-09-16 19:59:18 +02:00
5ca70d02e5 Remove unused import 2020-09-16 19:59:18 +02:00
0ff0789831 Add easy way to do xkey based purging of a template
Since we can purge based on the md5 hash of a template name, expose this
in the purge dialog so one doesn't have to manually calculate the hash
to use it.
2020-09-16 19:59:18 +02:00
9eb01b3355 Fix reject message subject on two-moderator items
Two-moderator items require only one moderator to be rejected or to be
sent back for more editing. In that case, don't log None as the other
moderator.
2020-09-16 19:59:18 +02:00
3015484483 Don't send link to edit deleted submissions
Once a submission, like a news article, has been deleted, that link
would just become a 404 anyway.
2020-09-16 19:59:18 +02:00
7aafd6131f Remove dynamic "docs" stylesheet
This was never used. And it was probably good that it wasn't, because if
it had it would've included both two copies of bootstrap in the page,
and also the bootstrap css map (as part of the css, and not as the map).

The docs pages these days use the same base stylesheet as the rest of
the site.
2020-09-12 12:48:58 +02:00
b59090f865 Fix moderation preview of organisatoin managers 2020-09-10 20:27:05 +02:00
8ac8f586da Fix invalid field name
Missed in a previous rename round.
2020-09-10 20:11:09 +02:00
7a9e532091 Track multiple email addresses for an organisation
This allows organisation managers to add more than one email address to
an organisation, and use this for sending news from. Sending news is the
only thing that the email field is used for at this point. Adding an
email will trigger a validation email sent to the address with a token
to confirm it, so that we can actually trust the emails.

Remove the previous registered emails on organisations. These addresses
were never validated and thus cannot really be trusted, so it's better
to remove them cleanly than to migrate them into the new system and be
uncertain.

Finally, in passing, remove the phone field on organisations. We've
never used that for anything and there's not really any point in
collecting the data.
2020-09-10 14:52:41 +02:00
3ab07fa069 Send moderation notices to organisation admins
Instead of tracking one single (non-verified!) email address for
organisations only to send notificationsn to, send the notifications to
all managers. This is relevant because all managers are in a position to
act upon them (and for example fix a posting).
2020-09-10 14:52:41 +02:00
e4453cdda9 Add support for sending out news as HTML email
When a news article is approved, it gets delivered as an email to the
pgsql-announce mailinglist. It will render the markdown of the news
article into a HTML part of the email, and include the markdown raw as
the text part (for those unable or unwilling to read html mail).

For each organisation, a mail template can be specified. Initially only
two templates are supported, one "default" and one "pgproject" which is
for official project news. The intention is *not* to provide generic
templates, but we may want to extend this to certain related projects in
the future *maybe* (such as regional NPOs).

These templates are stored in templates/news/mail/*.html, and for each
template *all* images found in templates/news/mail/img.<template>/ will
be attached to the email. "Conditional image inclusion" currently not
supported.

To do CSS inlining on top of the markdown output, module pynliner is now
required (available in the python3-pynliner package on Debian).

A testing script is added as news_send_email.py in order to easier test
out templates. This is *not* intended for production sending, so it will
for example send unmoderated news. By sending, it adds it to the
outgoing mailqueue in the system, so unless the cronjob is set up to
send, nothing will happen until that is run manually.

Support is included for tagged delivery using pglister, by directly
mapping NewsTags to pglister tags.

While at it, update the moderation preview forms to preview news items
using the HTML template for the email (while leaving other types of
items previewing without a particular stylesheet).
2020-09-10 14:52:41 +02:00
e1b397ac4b Add templatefilter joinandor
This filter takes a list of a,b,c,d and turns it into "a, b, c and d"
or "a, b, c or d" depending on parameter given.
2020-09-10 14:52:41 +02:00
5ffe6c389c Re-work moderation of submitted items
This includes a number of new features:

* Move some moderation functionality into shared places, so we don't
  keep re-inventing the wheel.
* Implement three-state moderation, where the submitter can edit their
  item and then explicitly say "i'm done, please moderate this now".
  This is currently only implemented for News, but done in a reusable
  way.
* Move moderation workflow to it's own set of URLs instead of
  overloading it on the general admin interface. Admin interface remains
  for editing things, but these are now separated out into separate
  things.
* Do proper stylesheet clearing for moderation of markdown fields, using
  a dynamic sandboxed iframe, so it's not ruined by the /admin/ css.
* Move moderation email notification into dedicated moderation code,
  thereby simplifying the admin subclassing we did which was in some
  places quite fragile.
* Reset date of news postings to the date of their approval, when
  approved. This avoids some annoying ordering issues.
2020-09-10 14:52:41 +02:00
8e7e52101c Add explicit links to git history for policies
We don't do this for all pages, but specifically for policies that
already included the "Last update", it's friendly to have a link to the
full set of changes.

We still lave the "Last updated" field as manually updated, because we
don't want to update that one if we just fix a typo or similar, it
should be reserved for when we make acstual content updates to a policy.

This creates and uses a specific template tag to automate the creation
of the links (that can of course be used elsewhere as well if needed).
2020-08-12 17:52:52 +02:00
fb99733afe Teach pgweb to handle secondary email addresses
This allows each account to have more than one email address, of which
one is primary. Adding more addresses will trigger an email with a
verification link (of course). The field previously known as "email" is
now changed to be "primary email".

Change the profile form to allow freely changing between the added
addresses which one is the primary. Remove the functionality to directly
change the primary email -- instead one has to add a new address first
and then change to that one, which simplifies several things in the
handling.
2020-08-11 11:33:46 +02:00
62963d71de Fix incorrect indentation 2020-08-06 19:13:36 +02:00
4f1bf70ea0 Remove unused imports 2020-07-13 14:53:07 +02:00
5c838c57ea Fix up some incorrect imports 2020-07-04 15:52:36 +02:00
7f8a0a56dd Load signal handlers from an app instead of urllist
This is the place to load them to make sure they always load. This means
we can also now remove a hardcoded special varnish purging in the CVE
crawler script, because all saves including those from cron jobs will
now fire the signals and thus the automatic varnish purges.
2020-07-03 17:57:25 +02:00
b405302d97 Avoid returning HttpServerError for things not server errors
With the new django, alerts are raised for everything with status 500,
not juse exceptions. This put a light on a number of places where we
were returning 500 server error code for things that are not actually
server errors. Some should be a regular 200 ok with an error message,
and others should be a permissions error.
2020-04-04 14:43:27 +02:00
454ea7a7be Fix spacing problem pep8 complains about 2020-04-04 14:43:13 +02:00
6d62619add Enable django v2 style autocomplete fields in admin 2020-03-31 22:55:13 +02:00
5d7cf9833f Remove dependency on django-selectable 2020-03-31 22:55:13 +02:00
46606e5284 Set on_delete=models.CASCADE on all ForeignKey fields
This is the bardware compatible value that will be needed once we
upgrade django later.
2020-03-31 22:34:51 +02:00
f4e7598c87 Update dynamic CSS generation for "docs.css"
This is primarily to enable the "make STYLE=website html" build
option of the PostgreSQL docs, as the pgweb docs page uses
the "base.css" file to render the documentation. By updating the
dynamic doc.css generation file, we can allow the builders of the
documentation to better preview what their documentation will look
like when it is loaded onto the website.

Presently, the dynamic "docs.css" is unused in pgweb or the core
project, and as those are the two biggest consumers of the
documentation styles, this is an apparent safe vector to make this
change.
2020-02-12 08:10:49 -05:00
69923c7190 Stop using bare exceptions
This is frowned upon in newer versions of pep8, so fix it once and for
all.
2020-01-09 13:14:32 +01:00
2148cb084a Raise a http 404 error on paths that are too long
We never have any paths this long, and it's nicer to raise a proper 404
than a 500 internal server error.
2019-10-10 20:49:45 +02:00
80eac2568e Support xkey purge requests on the API endpoint
Simply specigfying "x<n>" instead o "p<n>" should do the trick.
2019-06-19 21:26:18 +02:00
789550515e Style fixups to pass pep checks
This fixes the style issues introduced in the patches for the new
release notes styles. Clearly a broken verification hook somewhere.
2019-03-10 08:24:01 -07:00
c884493494 Create Release Notes archive in the Documentation section.
This creates a consolidated area to reference all of the notes from
previous releases of PostgreSQL, as current releases only keep the
the notes for that specific major release of PostgreSQL.
2019-03-08 11:19:25 -08:00