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
21d465e5
Commit
21d465e5
authored
Dec 15, 2013
by
Jean Michel Rouly
Browse files
If you don't own a url, you can't delete it.
parent
2c38747e
Changes
3
Hide whitespace changes
Inline
Side-by-side
go/go/views.py
View file @
21d465e5
...
...
@@ -13,11 +13,12 @@ def index(request):
# My-Links page.
@
login_required
def
my_links
(
request
):
def
my_links
(
request
,
permission
=
True
):
links
=
URL
.
objects
.
filter
(
owner
=
request
.
user
)
return
render
(
request
,
'my_links.html'
,
{
'links'
:
links
,
'permission'
:
permission
,
},
)
...
...
@@ -27,7 +28,9 @@ def delete(request, short):
url
=
URL
.
objects
.
get
(
short
=
short
)
if
url
.
owner
==
request
.
user
:
url
.
delete
()
return
redirect
(
'my_links'
)
return
redirect
(
'my_links'
)
else
:
return
my_links
(
request
,
permission
=
False
)
# About page, static.
def
about
(
request
):
...
...
go/settings/urls.py
View file @
21d465e5
...
...
@@ -15,7 +15,7 @@ urlpatterns = patterns('go.views',
url
(
r
'^signup/?$'
,
'signup'
,
name
=
'signup'
),
# /my - My-Links page, view and review links.
url
(
r
'^my/?$'
,
'my_links'
,
name
=
'my_links'
),
url
(
r
'^my/?$'
,
'my_links'
,
{
'permission'
:
True
},
name
=
'my_links'
),
# /delete - Delete a link, no content display.
url
(
r
'^delete/(?P<short>\w+)$'
,
'delete'
,
name
=
'delete'
),
...
...
go/templates/my_links.html
View file @
21d465e5
...
...
@@ -8,8 +8,12 @@ Go - A URL Shortener
{% block content %}
<div
id=
"mylinks"
>
{% if not permission %}
<p
class=
"error"
>
That link does not belong to you!
</p>
{% endif %}
{% if links %}
<div
id=
"mylinks"
>
{% for link in links %}
<p>
<strong>
Long:
</strong>
<a
href=
"{{link.target}}"
>
{{link.target}}
</a>
...
...
@@ -24,11 +28,17 @@ Go - A URL Shortener
<strong>
Expires:
</strong>
{{link.expires}}
<br
/>
<strong><a
href=
"{%url 'delete' link.short%}"
>
Delete
</a></strong>
<strong>
<a
href=
"{%url 'delete' link.short%}"
onclick=
"return confirm('Are you sure you want to delete this link?');"
>
Delete
</a>
</strong>
</p>
{% endfor %}
</div>
</div>
{% else %}
<p>
None found.
</p>
{% endif %}
{% endblock %}
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