Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.web
Commits
edcb7941
Commit
edcb7941
authored
May 14, 2020
by
Flavio TARSETTI
Browse files
[accounts/navigation/ui/utils] pre-commit cleanup
parent
8568f248
Pipeline
#39855
passed with stage
in 14 minutes and 25 seconds
Changes
8
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
beat/web/accounts/api.py
View file @
edcb7941
This diff is collapsed.
Click to expand it.
beat/web/accounts/models.py
View file @
edcb7941
...
...
@@ -164,16 +164,21 @@ class TemporaryUrlManager(models.Manager):
for
_
in
range
(
length
)
)
now
=
datetime
.
datetime
.
now
()
expiration_date_delta
=
datetime
.
timedelta
(
days
=
settings
.
ACCOUNT_ACTIVATION_DAYS_FROM_SUPERVISOR
)
expiration_date_delta
=
datetime
.
timedelta
(
days
=
settings
.
ACCOUNT_ACTIVATION_DAYS_FROM_SUPERVISOR
)
expires
=
now
+
expiration_date_delta
temporary_url
=
self
.
model
(
status
=
status
,
url_hash
=
url_hash
,
expires
=
expires
,
supervision_track
=
supervision_track
)
temporary_url
=
self
.
model
(
status
=
status
,
url_hash
=
url_hash
,
expires
=
expires
,
supervision_track
=
supervision_track
,
)
temporary_url
.
save
()
return
temporary_url
class
TemporaryUrl
(
models
.
Model
):
# _____ Constants __________
...
...
beat/web/accounts/urls.py
View file @
edcb7941
...
...
@@ -29,7 +29,15 @@ from django.conf.urls import url
from
.
import
views
urlpatterns
=
[
url
(
r
'^settings/$'
,
views
.
account_settings
,
name
=
'settings'
),
url
(
r
'^validation/(?P<hash_url>\w+)/$'
,
views
.
load_temporary_url_validation
,
name
=
"temp_url_validation"
),
url
(
r
'^rejection/(?P<hash_url>\w+)/$'
,
views
.
load_temporary_url_rejection
,
name
=
"temp_url_rejection"
),
url
(
r
"^settings/$"
,
views
.
account_settings
,
name
=
"settings"
),
url
(
r
"^validation/(?P<hash_url>\w+)/$"
,
views
.
load_temporary_url_validation
,
name
=
"temp_url_validation"
,
),
url
(
r
"^rejection/(?P<hash_url>\w+)/$"
,
views
.
load_temporary_url_rejection
,
name
=
"temp_url_rejection"
,
),
]
beat/web/accounts/views.py
View file @
edcb7941
This diff is collapsed.
Click to expand it.
beat/web/navigation/admin.py
View file @
edcb7941
...
...
@@ -36,49 +36,51 @@ from ..accounts.models import Profile
from
..accounts.models
import
TemporaryUrl
#----------------------------------------------------------
#
----------------------------------------------------------
class
AgreementInline
(
admin
.
StackedInline
):
model
=
Agreement
#----------------------------------------------------------
#
----------------------------------------------------------
class
AccountSettingsInline
(
admin
.
StackedInline
):
model
=
AccountSettings
#----------------------------------------------------------
#
----------------------------------------------------------
class
SupervisionTrackInline
(
admin
.
StackedInline
):
model
=
SupervisionTrack
fk_name
=
'
supervisor
'
fk_name
=
"
supervisor
"
#----------------------------------------------------------
#
----------------------------------------------------------
class
ProfileInline
(
admin
.
StackedInline
):
model
=
Profile
#----------------------------------------------------------
#
----------------------------------------------------------
class
UserAdmin
(
UserAdmin
):
def
agreement_number
(
self
,
obj
):
return
obj
.
agreement
.
version
agreement_number
.
admin_order_field
=
'agreement__version'
agreement_number
.
admin_order_field
=
"agreement__version"
def
notifications
(
self
,
obj
):
return
int
(
obj
.
accountsettings
.
daily_summary
)
+
\
int
(
obj
.
accountsettings
.
experiment_mail_notifications_enabled
)
+
\
int
(
obj
.
accountsettings
.
database_notifications_enabled
)
+
\
int
(
obj
.
accountsettings
.
environment_notifications_enabled
)
return
(
int
(
obj
.
accountsettings
.
daily_summary
)
+
int
(
obj
.
accountsettings
.
experiment_mail_notifications_enabled
)
+
int
(
obj
.
accountsettings
.
database_notifications_enabled
)
+
int
(
obj
.
accountsettings
.
environment_notifications_enabled
)
)
def
supervisor
(
self
,
obj
):
return
obj
.
profile
.
is_supervisor
...
...
@@ -92,8 +94,9 @@ class UserAdmin(UserAdmin):
if
obj
.
profile
.
is_supervisor
:
return
"Supervisor account"
else
:
supervisiontrack
=
SupervisionTrack
.
objects
.
get
(
supervisee
=
obj
,
is_valid
=
True
)
supervisiontrack
=
SupervisionTrack
.
objects
.
get
(
supervisee
=
obj
,
is_valid
=
True
)
supervisor
=
supervisiontrack
.
supervisor
return
supervisor
...
...
@@ -103,25 +106,24 @@ class UserAdmin(UserAdmin):
def
rejection_date
(
self
,
obj
):
return
obj
.
profile
.
rejection_date
list_display
=
(
'
username
'
,
'
is_staff
'
,
'
email
'
,
'
notifications
'
,
'
agreement_number
'
,
'
last_login
'
,
'
supervisor
'
,
'
status
'
,
'
supervision
'
,
'
supervision_key
'
,
'
rejection_date
'
,
"
username
"
,
"
is_staff
"
,
"
email
"
,
"
notifications
"
,
"
agreement_number
"
,
"
last_login
"
,
"
supervisor
"
,
"
status
"
,
"
supervision
"
,
"
supervision_key
"
,
"
rejection_date
"
,
)
ordering
=
(
'
-is_staff
'
,
'
-last_login
'
,
'
username
'
,
"
-is_staff
"
,
"
-last_login
"
,
"
username
"
,
)
inlines
=
(
...
...
@@ -131,73 +133,68 @@ class UserAdmin(UserAdmin):
ProfileInline
,
)
admin
.
site
.
unregister
(
User
)
admin
.
site
.
register
(
User
,
UserAdmin
)
#----------------------------------------------------------
#
----------------------------------------------------------
class
SupervisionTrackAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'
supervisor
'
,
'
supervisee
'
,
'
is_valid
'
,
'
start_date
'
,
'
expiration_date
'
,
'
last_validation_date
'
,
'
supervision_key
'
,
"
supervisor
"
,
"
supervisee
"
,
"
is_valid
"
,
"
start_date
"
,
"
expiration_date
"
,
"
last_validation_date
"
,
"
supervision_key
"
,
)
ordering
=
(
'supervisor'
,
)
ordering
=
(
"supervisor"
,)
admin
.
site
.
register
(
SupervisionTrack
,
SupervisionTrackAdmin
)
#----------------------------------------------------------
#
----------------------------------------------------------
class
ProfileAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'
user
'
,
'
status
'
,
'
registration_date
'
,
'
is_supervisor
'
,
'
supervision_key
'
,
'
rejection_date
'
,
"
user
"
,
"
status
"
,
"
registration_date
"
,
"
is_supervisor
"
,
"
supervision_key
"
,
"
rejection_date
"
,
)
ordering
=
(
'user'
,
)
ordering
=
(
"user"
,)
admin
.
site
.
register
(
Profile
,
ProfileAdmin
)
#----------------------------------------------------------
#
----------------------------------------------------------
class
TemporaryUrlAdmin
(
admin
.
ModelAdmin
):
def
supervision_key
(
self
,
obj
):
return
obj
.
supervision_track
.
supervision_key
list_display
=
(
'
url_hash
'
,
'
expires
'
,
'
supervision_track
'
,
'
supervision_key
'
,
'
status
'
,
"
url_hash
"
,
"
expires
"
,
"
supervision_track
"
,
"
supervision_key
"
,
"
status
"
,
)
ordering
=
(
'expires'
,
)
ordering
=
(
"expires"
,)
admin
.
site
.
register
(
TemporaryUrl
,
TemporaryUrlAdmin
)
beat/web/ui/registration/models.py
View file @
edcb7941
...
...
@@ -144,7 +144,9 @@ class RegistrationManager(models.Manager):
parsed_url
.
hostname
,
)
temp_url
=
TemporaryUrl
.
objects
.
create_temporary_url
(
TemporaryUrl
.
VALIDATION
,
supervisiontrack
)
temp_url
=
TemporaryUrl
.
objects
.
create_temporary_url
(
TemporaryUrl
.
VALIDATION
,
supervisiontrack
)
context
=
{
"supervisor"
:
supervisor_user
,
...
...
beat/web/ui/views.py
View file @
edcb7941
This diff is collapsed.
Click to expand it.
beat/web/utils/management/commands/daily_cron_actions.py
View file @
edcb7941
...
...
@@ -28,42 +28,32 @@
from
django.core.management
import
call_command
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.mail
import
send_mail
from
django.template.loader
import
render_to_string
from
django.conf
import
settings
from
django.contrib.sites.models
import
Site
from
django.core.management.base
import
BaseCommand
from
datetime
import
datetime
,
time
,
date
,
timedelta
from
....reports.models
import
Report
from
....
import
__version__
import
sys
class
Command
(
BaseCommand
):
help
=
'
Daily CRON actions
'
help
=
"
Daily CRON actions
"
def
handle
(
self
,
*
args
,
**
options
):
# Send attestations cleanup warnings and cleanup attestations
call_command
(
'
send_attestation_cleanup_warning
'
)
call_command
(
"
send_attestation_cleanup_warning
"
)
# Send report cleanup warnings and cleanup reports
call_command
(
'
send_report_cleanup_warning_and_cleanup
'
)
call_command
(
"
send_report_cleanup_warning_and_cleanup
"
)
# Clean and remove invalid users
call_command
(
'
clean_invalid_users
'
)
call_command
(
"
clean_invalid_users
"
)
# Block rejected users with no supervision after specific rejection date
call_command
(
'
block_rejected_users
'
)
call_command
(
"
block_rejected_users
"
)
# Clean blocked users with no supervision after specific rejection date
call_command
(
'
clean_blocked_users_expired_requests
'
)
call_command
(
"
clean_blocked_users_expired_requests
"
)
# Yearly revalidation process with warnings, status change and blockage
call_command
(
'
year_revalidation_users
'
)
call_command
(
"
year_revalidation_users
"
)
# Clean expired temporary urls for account activation/re-activation
call_command
(
'
clean_expired_temporary_urls
'
)
call_command
(
"
clean_expired_temporary_urls
"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment