Previously this was also trying to catch ones at the beginning of new
paragraphs, but that seems to mostly just be causing unexpected issues
when people create ordered lists with a blank line between items. This
can probably be done properly in the future, but just restricting it to
the start of posts is probably better for now.
Allows (manually) granting permissions to allow users to re-tag topics,
move them between groups, and edit their titles.
This should probably be generalized in the near future, but this will do
the trick for now.
Previously there was a specific is_admin boolean column. This commit
changes to have a general permissions column which is stored in JSON,
and currently should either be a single string or list of strings. These
strings are used as the user's principals for the authorization system.
So now, setting a user as admin would involve adding the string "admin"
to their permissions column, instead of just setting is_admin to True.
As part of this change, I also moved the MutableDict associations onto
specific columns, instead of being attached to JSONB by default (since
this new column won't always be a dict).
Nothing too significant in here, just a few adjustments and other
follow-ups that I wanted to do:
* Make backup code usage a bit more lenient - allow uppercase, and
doesn't need exact spacing as originally displayed.
* Display the backup codes a little more nicely.
* Change the message on the settings page based on whether 2FA is
enabled or not.
* Use webargs instead of request.params.get
Black won't re-wrap comments because it has no way to determine when
that's a "safe" thing to do (that might break deliberate line-breaks).
So this is a quick pass through to re-wrap most multi-line comments and
docstrings to the new max line-length of 88.
This commit contains only changes that were made automatically by Black
(except for some minor fixes to string un-wrapping and two
format-disabling blocks in the user and group schemas). Some manual
cleanup/adjustments will probably need to be made in a follow-up commit,
but this one contains the result of running Black on the codebase
without significant further manual tweaking.
Boussole (which watches the SCSS files for changes and compiles them)
has just been running in the same venv as the main app until now, but
it's holding back the version of the click package. There's no real
reason that it needs to be in the app venv, so this moves it to its own
one, which also eliminates quite a few other packages that were only
being installed because of Boussole.
An example was recently added to the github cmark repo to show how to
set up the extensions from Python, so this is heavily based on that
code:
https://github.com/github/cmark/blob/master/wrappers/wrapper_ext.py
This should also fix a memory leak, since I wasn't manually freeing the
returned buffer (as the library recommends that you do).
Because of the way the topic_visits update works (only updating visits
that were before the comment was posted), this will only behave
correctly when the previous notifications are processed in the order
their comments were posted.
This process needs to be replaced soon anyway, but this should make it
work correctly for now.
Just a couple more tests for comment permissions that are more essential
to be working correctly - replying in locked threads, and viewing
removed comments. Also changes the "deleted comments lose all
permissions" test slightly to actually check all permissions instead of
a hard-coded (and obsolete) set of them.
The previous approach to writing ACLs made them difficult to follow,
which resulted in making it easy to make mistakes (like allowing users
to reply to themselves in locked threads). This approach should work
much better.
Unfortunately some of the triggers aren't currently testable due to
the fact that postgresql's NOW() and similar functions will always
return the same value during the entire test transaction, but this at
least tests a couple more of the behaviors.
This moves some of the commonly-used fixtures (creating a topic, etc.)
into a separate module, which gets included into conftest.py (so the
fixtures are available everywhere) by treating it as a "plugin".
There was some special handling of apostrophes in two string-related
functions: the one for generating url slugs, as well as the one for
doing a word count. Both of these weren't handling "curly" apostrophes
(unicode char 0x2019) properly before, so they've both been updated now.
A couple of different locations in the code were causing crashes if the
user specified ridiculously long time periods (via topic listings).
This should prevent it, or at least give a better error when it happens.
The functions that target a comment's .comment-itself div (editing,
voting, deleting) were nesting an additional .comment-itself inside it,
instead of replacing the existing one.
This detects mentions of users in comments using the same pattern as the
markdown parsing uses to generate user links. Mentioned users are sent a
notification, and mentions are added/deleted if needed on comment edits.
As part of this, setup was done to generate rabbitmq messages for
comment creation and edits, and the mentions are handled by an async
consumer of these messages.
The bottom margin on <ol> was causing some weird spacing when it's the
last element inside a block. This is most noticeable on a blockquote
where the background color extends further down than it should.
This needs some more work still to clean up a few things, but it should
be good enough for now. This allows users to see (only on their own user
page), separate "tabs" for Topics and Comments, and those separate
listings are paginated.
Previously, _sort_column wasn't set by default and needed to be set by
the query, but some of the other methods would fail if it hadn't been
set. This just defaults it to use the created_time column as the default
sort, which should always be present on models being queried by this
class (for now, at least).
This adds two new properties to PaginatedResults - .next_page_after_id
and .prev_page_before_id. These can be used when creating the links to
the before/after pages, instead of needing to access the right
element/property "manually".
This will be most useful in listings that contain items of multiple
types (such as comments and topics), since we won't necessarily know
which type the first/last elements are.
When you're posting a new topic and you fill out both the link and text
fields, it posts as a link topic with the text posted as the first
comment. Because this is done in the same database transaction, the link
and comment get exactly the same `created_time` value. Previously, the
comment was being sorted "before" the topic, which was a bit confusing
when viewing a user's profile - it would show the comment as being
posted before the topic it was posted on.
This just reverses the order that the two lists are joined in to fix
this slight oddity.
Adds a new sub-option to the "Open links in new tabs" setting which uses
javascript to find external links in the text of topics, comments, and
messages and sets them to open in new tabs.
The previous setup was a bit unusual and confusing - various functions
that restricted the query somehow were accepting None as an argument and
simply doing nothing if it was passed. This made calling them a little
simpler, but overall didn't make a lot of sense - if you don't want to
apply the restriction, you shouldn't call the function in the first
place.