Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
django-url-follower
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikolaos S. Papaspyrou
django-url-follower
Commits
9c2d8bbf
Commit
9c2d8bbf
authored
Jun 15, 2015
by
Nikolaos S. Papaspyrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add simple views
parent
0a6764d6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
0 deletions
+53
-0
urls.py
myprj/urls.py
+1
-0
admin.py
urlforward/admin.py
+4
-0
details.html
urlforward/templates/details.html
+8
-0
index.html
urlforward/templates/index.html
+14
-0
urls.py
urlforward/urls.py
+9
-0
views.py
urlforward/views.py
+17
-0
No files found.
myprj/urls.py
View file @
9c2d8bbf
...
...
@@ -17,5 +17,6 @@ from django.conf.urls import include, url
from
django.contrib
import
admin
urlpatterns
=
[
url
(
r'^'
,
include
(
'urlforward.urls'
)),
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
]
urlforward/admin.py
View file @
9c2d8bbf
from
django.contrib
import
admin
# Register your models here.
from
.models
import
Url
admin
.
site
.
register
(
Url
)
urlforward/templates/details.html
0 → 100644
View file @
9c2d8bbf
<h1>
Details of URL {{ url.id }}
</h1>
<ul>
<li>
Owner: {{ url.user.first_name }} {{ url.user.last_name }}
({{ url.user.username }})
</li>
<li>
Target:
<a
href=
"{{ url.target }}"
target=
"_blank"
><code>
{{ url.target }}
</code></a></li>
<li>
Followed: {{ url.used }} time(s).
</li>
</ul>
urlforward/templates/index.html
0 → 100644
View file @
9c2d8bbf
<h1>
List of URLs
</h1>
{% if url_list %}
<ul>
{% for u in url_list %}
<li>
<a
href=
"/url={{ u.id }}"
>
Show details
</a>
, or follow
<a
href=
"/{{ u.id }}"
target=
"_blank"
><code>
{{ u.target }}
</code></a>
</li>
{% endfor %}
</ul>
{% else %}
<p>
No URLs are available.
</p>
{% endif %}
urlforward/urls.py
0 → 100644
View file @
9c2d8bbf
from
django.conf.urls
import
url
from
.
import
views
urlpatterns
=
[
url
(
r'^$'
,
views
.
index
,
name
=
'index'
),
url
(
r'^(?P<url_id>[0-9]+)$'
,
views
.
redir
,
name
=
'redir'
),
url
(
r'^url=(?P<url_id>[0-9]+)$'
,
views
.
details
,
name
=
'details'
),
]
urlforward/views.py
View file @
9c2d8bbf
from
django.shortcuts
import
render
from
.models
import
Url
# Create your views here.
def
index
(
request
):
context
=
{
'url_list'
:
Url
.
objects
.
all
()
}
return
render
(
request
,
'index.html'
,
context
)
def
redir
(
request
,
url_id
):
return
HttpResponse
(
"You are following the url: {}"
.
format
(
url_id
))
def
details
(
request
,
url_id
):
context
=
{
'url'
:
Url
.
objects
.
get
(
id
=
url_id
)
}
return
render
(
request
,
'details.html'
,
context
)
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