Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
SMASCH
scheduling-system
Commits
02efbb03
Commit
02efbb03
authored
4 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
added privacy notice view
parent
fd7f6e30
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!276
Resolve "privacy notice and usage terms"
Pipeline
#34364
failed
4 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/views/privacy_notice.py
+77
-0
77 additions, 0 deletions
smash/web/views/privacy_notice.py
with
77 additions
and
0 deletions
smash/web/views/privacy_notice.py
0 → 100644
+
77
−
0
View file @
02efbb03
# coding=utf-8
import
io
from
wsgiref.util
import
FileWrapper
from
django.contrib
import
messages
from
django.http
import
HttpResponse
from
django.shortcuts
import
redirect
,
get_object_or_404
from
django.urls
import
reverse_lazy
from
django.views.generic
import
DeleteView
from
django.views.generic
import
ListView
from
web.decorators
import
PermissionDecorator
from
.
import
WrappedView
from
.
import
wrap_response
from
..forms.privacy_notice
import
PrivacyNoticeForm
from
..models
import
PrivacyNotice
class
PrivacyNoticeListView
(
ListView
,
WrappedView
):
model
=
PrivacyNotice
context_object_name
=
"
privacy_notices
"
template_name
=
'
privacy_notice/list.html
'
@PermissionDecorator
(
'
change_privacynotice
'
,
'
privacynotice
'
)
def
dispatch
(
self
,
*
args
,
**
kwargs
):
return
super
(
PrivacyNoticeListView
,
self
).
dispatch
(
*
args
,
**
kwargs
)
@PermissionDecorator
(
'
change_privacynotice
'
,
'
privacynotice
'
)
def
privacy_notice_add
(
request
):
if
request
.
method
==
'
POST
'
:
form
=
PrivacyNoticeForm
(
request
.
POST
,
request
.
FILES
)
if
form
.
is_valid
():
try
:
form
.
save
()
except
:
messages
.
add_message
(
request
,
messages
.
ERROR
,
'
There was a problem when saving privacy notice.
'
'
Contact system administrator.
'
)
return
redirect
(
'
web.views.privacy_notices
'
)
else
:
form
=
PrivacyNoticeForm
()
return
wrap_response
(
request
,
'
privacy_notice/add.html
'
,
{
'
form
'
:
form
})
@PermissionDecorator
(
'
change_privacynotice
'
,
'
privacynotice
'
)
def
privacy_notice_edit
(
request
,
pk
):
privacy_notice
=
get_object_or_404
(
PrivacyNotice
,
pk
=
pk
)
if
request
.
method
==
'
POST
'
:
form
=
PrivacyNoticeForm
(
request
.
POST
,
request
.
FILES
,
instance
=
privacy_notice
)
if
form
.
is_valid
():
try
:
form
.
save
()
return
redirect
(
'
web.views.privacy_notices
'
)
except
:
messages
.
add_message
(
request
,
messages
.
ERROR
,
'
There was a problem when updating the privacy notice.
'
'
Contact system administrator.
'
)
return
wrap_response
(
request
,
'
privacy_notice/edit.html
'
,
{
'
form
'
:
form
,
'
privacy_notice
'
:
privacy_notice
})
else
:
form
=
PrivacyNoticeForm
(
instance
=
privacy_notice
)
return
wrap_response
(
request
,
'
privacy_notice/edit.html
'
,
{
'
form
'
:
form
,
'
privacy_notice
'
:
privacy_notice
})
class
PrivacyNoticeDeleteView
(
DeleteView
,
WrappedView
):
model
=
PrivacyNotice
success_url
=
reverse_lazy
(
'
web.views.privacy_notices
'
)
template_name
=
'
privacy_notice/confirm_delete.html
'
@PermissionDecorator
(
'
change_privacynotice
'
,
'
privacynotice
'
)
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
messages
.
success
(
request
,
"
Privacy Notice deleted
"
)
#try:
return
super
(
PrivacyNoticeDeleteView
,
self
).
delete
(
request
,
*
args
,
**
kwargs
)
#except:
# messages.add_message(request, messages.ERROR, 'There was a problem when deleting privacy notice. '
# 'Contact system administrator.')
return
redirect
(
'
web.views.privacy_notices
'
)
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