Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pretix Matrix Inviter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KIF
Pretix Matrix Inviter
Commits
de58d760
Commit
de58d760
authored
2 years ago
by
Felix Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
Django 4 compatibility
#14
parent
0b48bb17
No related branches found
No related tags found
No related merge requests found
Pipeline
#141665
failed
2 years ago
Stage: linting
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
pretix_matrix_inviter/forms.py
+23
-17
23 additions, 17 deletions
pretix_matrix_inviter/forms.py
pretix_matrix_inviter/signals.py
+10
-8
10 additions, 8 deletions
pretix_matrix_inviter/signals.py
with
34 additions
and
25 deletions
CHANGELOG.md
+
1
−
0
View file @
de58d760
...
...
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
-
Apply updated pretix plugin cookiecutter
-
Django 4 compatibility #14
## [1.5.0] - 2022-10-09
### Added
...
...
This diff is collapsed.
Click to expand it.
pretix_matrix_inviter/forms.py
+
23
−
17
View file @
de58d760
...
...
@@ -4,7 +4,7 @@ from django.forms import (
MultipleChoiceField
,
RegexField
,
)
from
django.utils.translation
import
u
gettext_lazy
as
_
from
django.utils.translation
import
gettext_lazy
from
i18nfield.forms
import
I18nFormField
,
I18nTextInput
from
pretix.base.forms
import
SettingsForm
...
...
@@ -14,42 +14,46 @@ from .helpers import matrix_room_info_for_event
class
MatrixInviterForm
(
SettingsForm
):
matrix_inviter_items
=
MultipleChoiceField
(
widget
=
CheckboxSelectMultiple
(
attrs
=
{
"
class
"
:
"
scrolling-multiple-choice
"
}),
label
=
_
(
"
Ask Matrix ID for
"
),
label
=
gettext_lazy
(
"
Ask Matrix ID for
"
),
required
=
True
,
choices
=
[],
help_text
=
_
(
"
These products will ask for a Matrix ID.
"
),
help_text
=
gettext_lazy
(
"
These products will ask for a Matrix ID.
"
),
)
matrix_inviter_authorization_token
=
CharField
(
label
=
_
(
"
Access token
"
),
label
=
gettext_lazy
(
"
Access token
"
),
strip
=
True
,
help_text
=
_
(
help_text
=
gettext_lazy
(
"
This should be the access token of a user that can invite attendees to the target Room or Space.
"
"
Please note that other administrators of this event will be able to see this token, it should not be from
"
"
your own Matrix account but from a dedicated Matrix account.
"
),
)
matrix_inviter_matrix_server
=
CharField
(
label
=
_
(
"
Matrix server
"
),
label
=
gettext_lazy
(
"
Matrix server
"
),
strip
=
True
,
help_text
=
_
(
"
The matrix server the above access token is valid for.
"
),
help_text
=
gettext_lazy
(
"
The matrix server the above access token is valid for.
"
),
)
matrix_inviter_hint
=
I18nFormField
(
widget
=
I18nTextInput
,
label
=
_
(
"
Matrix ID field help text
"
),
label
=
gettext_lazy
(
"
Matrix ID field help text
"
),
required
=
True
,
help_text
=
_
(
help_text
=
gettext_lazy
(
"
This will be shown as help text on the Matrix ID field. It is recommended to inform your attendees
"
"
which room they will be invited to and what that room will be used for.
"
),
)
matrix_inviter_reason
=
I18nFormField
(
widget
=
I18nTextInput
,
label
=
_
(
"
Invitation message
"
),
label
=
gettext_lazy
(
"
Invitation message
"
),
required
=
False
,
help_text
=
_
(
"
This message will be added to the invitation to the Matrix room.
"
),
help_text
=
gettext_lazy
(
"
This message will be added to the invitation to the Matrix room.
"
),
)
matrix_inviter_matrix_room
=
RegexField
(
label
=
_
(
"
Matrix room
"
),
label
=
gettext_lazy
(
"
Matrix room
"
),
regex
=
"
(?:!|#)[^:]+:[^:,]+(?:
\\
s*,
\\
s*(?:!|#)[^:]+:[^:,]+)*
"
,
strip
=
True
,
)
...
...
@@ -62,7 +66,7 @@ class MatrixInviterForm(SettingsForm):
room_info
=
matrix_room_info_for_event
(
self
.
obj
)
if
not
room_info
:
room_help_text
=
_
(
room_help_text
=
gettext_lazy
(
"
Comma-separated list of room IDs or aliases to invite users to.
"
)
else
:
...
...
@@ -71,22 +75,24 @@ class MatrixInviterForm(SettingsForm):
if
room
[
"
room_id
"
].
startswith
(
"
!
"
):
if
room
[
"
canonical_alias
"
]:
room_help
.
append
(
_
(
gettext_lazy
(
'"
{name}
"
(main address: <code>{canonical_alias}</code>)
'
).
format_map
(
room
)
)
else
:
room_help
.
append
(
_
(
'"
{name}
"'
).
format_map
(
room
))
room_help
.
append
(
gettext_lazy
(
'"
{name}
"'
).
format_map
(
room
))
else
:
if
room
[
"
canonical_alias
"
]:
room_help
.
append
(
_
(
gettext_lazy
(
'"
{name}
"
(<code>{room_id}</code>, main address: <code>{canonical_alias}</code>)
'
).
format_map
(
room
)
)
else
:
room_help
.
append
(
_
(
'"
{name}
"
(<code>{room_id}</code>)
'
).
format_map
(
room
)
gettext_lazy
(
'"
{name}
"
(<code>{room_id}</code>)
'
).
format_map
(
room
)
)
room_help_text
=
"
,
"
.
join
(
room_help
)
self
.
fields
[
"
matrix_inviter_matrix_room
"
].
help_text
=
room_help_text
This diff is collapsed.
Click to expand it.
pretix_matrix_inviter/signals.py
+
10
−
8
View file @
de58d760
...
...
@@ -2,7 +2,7 @@ import json
from
django
import
forms
from
django.dispatch
import
receiver
from
django.urls
import
resolve
,
reverse
from
django.utils.translation
import
gettext_
noop
,
u
gettext_
lazy
as
_
from
django.utils.translation
import
gettext_
lazy
,
gettext_
noop
from
i18nfield.strings
import
LazyI18nString
from
pretix.base.settings
import
settings_hierarkey
from
pretix.base.signals
import
(
...
...
@@ -51,12 +51,14 @@ def add_matrix_id_question(sender, position, **kwargs):
return
{
"
matrix_inviter_matrix_id
"
:
forms
.
RegexField
(
label
=
_
(
"
Matrix ID
"
),
label
=
gettext_lazy
(
"
Matrix ID
"
),
required
=
False
,
regex
=
"
@[a-z0-9._=/-]+:[a-z0-9.-]+
"
,
strip
=
True
,
error_messages
=
{
"
invalid
"
:
_
(
"
Enter a Matrix ID of the form @username:homeserver.tld
"
)
"
invalid
"
:
gettext_lazy
(
"
Enter a Matrix ID of the form @username:homeserver.tld
"
)
},
help_text
=
rich_text_snippet
(
sender
.
settings
.
matrix_inviter_hint
),
)
...
...
@@ -132,7 +134,7 @@ def navbar_settings(sender, request=None, **kwargs):
url
=
resolve
(
request
.
path_info
)
return
[
{
"
label
"
:
_
(
"
Matrix inviter
"
),
"
label
"
:
gettext_lazy
(
"
Matrix inviter
"
),
"
url
"
:
reverse
(
"
plugins:pretix_matrix_inviter:settings
"
,
kwargs
=
{
...
...
@@ -152,16 +154,16 @@ def logentry_display(sender, logentry, **kwargs):
return
locales
=
{
"
pretix_matrix_inviter.invite_sent
"
:
_
(
"
pretix_matrix_inviter.invite_sent
"
:
gettext_lazy
(
"
{matrix_id} has been invited to {matrix_room}.
"
),
"
pretix_matrix_inviter.invite_rescinded
"
:
_
(
"
pretix_matrix_inviter.invite_rescinded
"
:
gettext_lazy
(
"
{matrix_id} has been removed from {matrix_room}.
"
),
"
pretix_matrix_inviter.error
"
:
_
(
"
pretix_matrix_inviter.error
"
:
gettext_lazy
(
"
There was an error inviting {matrix_id} to {matrix_room}: {error}
"
),
"
pretix_matrix_inviter.remove_error
"
:
_
(
"
pretix_matrix_inviter.remove_error
"
:
gettext_lazy
(
"
There was an error removing {matrix_id} from {matrix_room}: {error}
"
),
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment