Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
c8626343
Verified
Commit
c8626343
authored
3 years ago
by
Tom Teichler
Browse files
Options
Downloads
Patches
Plain Diff
Document overriden views
parent
e657f2f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!450
User invitations
Pipeline
#45615
failed
3 years ago
Stage: test
Stage: build
Stage: publish
Stage: docker
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/views.py
+20
-6
20 additions, 6 deletions
aleksis/core/views.py
with
20 additions
and
6 deletions
aleksis/core/views.py
+
20
−
6
View file @
c8626343
...
...
@@ -1072,11 +1072,7 @@ class InvitePerson(PermissionRequiredMixin, SingleTableView, SendInvite):
table_class
=
InvitationsTable
context
=
{}
def
get_initial
(
self
):
if
person
:
return
{
"
person
"
:
person
}
return
super
().
get_initial
(
**
kwargs
)
# Get queryset of invitations
def
get_context_data
(
self
,
**
kwargs
):
queryset
=
kwargs
.
pop
(
"
object_list
"
,
None
)
if
queryset
is
None
:
...
...
@@ -1092,12 +1088,14 @@ class EnterInvitationCode(FormView):
def
form_valid
(
self
,
form
):
code
=
""
.
join
(
form
.
cleaned_data
[
"
code
"
].
lower
().
split
(
"
-
"
))
# Check if valid invitations exists
if
(
PersonInvitation
.
objects
.
filter
(
key
=
code
).
exists
()
and
not
PersonInvitation
.
objects
.
get
(
key
=
code
).
accepted
and
not
PersonInvitation
.
objects
.
get
(
key
=
code
).
key_expired
()
):
invitation
=
PersonInvitation
.
objects
.
get
(
key
=
code
)
# Mark invitation as accepted and redirect to signup
accept_invitation
(
invitation
=
invitation
,
request
=
self
.
request
,
signal_sender
=
self
.
request
.
user
)
...
...
@@ -1109,16 +1107,20 @@ class GenerateInvitationCode(View):
"""
View to generate an invitation code.
"""
def
get
(
self
,
request
):
# Build code
length
=
get_site_preferences
()[
"
auth__invite_code_length
"
]
packet_size
=
get_site_preferences
()[
"
auth__invite_code_packet_size
"
]
code
=
generate_random_code
(
length
,
packet_size
)
# Create invitation object
invitation
=
PersonInvitation
.
objects
.
create
(
email
=
""
,
inviter
=
request
.
user
,
key
=
code
,
sent
=
timezone
.
now
()
)
# Make code more readable
code
=
"
-
"
.
join
(
wrap
(
invitation
.
key
,
5
))
# Generate success message and print code
messages
.
success
(
request
,
_
(
f
"
The invitation was successfully created. The invitation code is
{
code
}
"
),
...
...
@@ -1394,6 +1396,12 @@ def server_error(
class
AccountRegisterView
(
SignupView
):
"""
Rewrite account register view from upstream.
Rewrite dispatch function to check if signup is open or if the user has an verified
email address from an invitation, otherwise raise permission denied.
"""
form_class
=
AccountRegisterForm
success_url
=
"
index
"
...
...
@@ -1439,7 +1447,13 @@ class InvitePersonByID(View):
class
LoginView
(
AllAuthLoginView
):
"""
Override upstream loginview to check if person has a verified email address.
"""
"""
Override upstream loginview from django-allauth.
Override view to check if email verification from django-invitations is mandatory.
If verification is mandatory, check if the user has a verified email address, if not,
re-sent verification.
"""
def
done
(
self
,
form_list
,
**
kwargs
):
if
settings
.
ACCOUNT_EMAIL_VERIFICATION
==
"
mandatory
"
:
...
...
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