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
SRCT
go
Commits
ff22f146
Unverified
Commit
ff22f146
authored
Mar 29, 2017
by
David Haynes
Browse files
Initial data set on URLForm
- also proper access control set
parent
9dd954de
Pipeline
#1176
passed with stage
in 59 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
go/go/views.py
View file @
ff22f146
...
...
@@ -203,7 +203,11 @@ def edit(request, short):
# Do not allow unapproved users to edit links
if
not
request
.
user
.
registereduser
.
approved
:
return
render
(
request
,
'not_registered.html'
)
if
request
.
user
.
registereduser
.
blocked
:
return
render
(
request
,
'banned.html'
)
else
:
return
render
(
request
,
'not_registered.html'
)
# Get the URL that is going to be edited
url
=
get_object_or_404
(
URL
,
short__iexact
=
short
)
...
...
@@ -211,15 +215,6 @@ def edit(request, short):
# If the RegisteredUser is the owner of the URL
if
url
.
owner
==
request
.
user
.
registereduser
:
# Initialize a URL form
url_form
=
URLForm
(
host
=
request
.
META
.
get
(
'HTTP_HOST'
),
initial
=
{
'target'
:
url
.
target
,
'short'
:
url
.
short
# figure out how to set expires (lambda?)
})
# unbound form
# Initial data set here
# If a POST request is received, then the user has submitted a form and it's
# time to parse the form and edit that URL object
if
request
.
method
==
'POST'
:
...
...
@@ -238,6 +233,23 @@ def edit(request, short):
'form'
:
url_form
})
else
:
# Initial data set here
if
url
.
expires
!=
None
:
# Initialize a URL form with an expire date
url_form
=
URLForm
(
host
=
request
.
META
.
get
(
'HTTP_HOST'
),
initial
=
{
'target'
:
url
.
target
,
'short'
:
url
.
short
,
'expires'
:
'Custom Date'
,
'expires_custom'
:
url
.
expires
})
# unbound form
else
:
# Initialize a URL form without an expire date
url_form
=
URLForm
(
host
=
request
.
META
.
get
(
'HTTP_HOST'
),
initial
=
{
'target'
:
url
.
target
,
'short'
:
url
.
short
,
'expires'
:
'Never'
,
})
# unbound form
# Render index.html passing the form to the template
return
render
(
request
,
'core/edit_link.html'
,
{
'form'
:
url_form
...
...
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