Commit 33f7ae4c authored by Zach Knox's avatar Zach Knox

The pages are swapped

but it's kind of ugly I'll fix that later
parent 98bed2aa
Pipeline #864 passed with stage
in 1 minute and 10 seconds
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- load django crispy forms' tags -->
{% load crispy_forms_tags %}
<!-- define the page title block -->
{% block title %}
SRCT Go &bull; A University Branded URL Shortener
SRCT Go &bull; My Links
{% endblock %}
<!-- define the content block for the page -->
......@@ -21,42 +18,27 @@ SRCT Go &bull; A University Branded URL Shortener
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-link fa-stack-1x fa-inverse"></i>
</span>
<i class="fa">Shorten URL</i>
<i class="fa">My Links</i>
</strong></h1>
</div>
</div>
<div class="newlink" style="text-align: right;">
<a href="{% url 'index' %}"><i class="fa fa-plus" aria-hidden="true"></i> Add new link</a>
</div>
</div>
<!-- call django crispy forms to render the go link creation form here -->
{% crispy form %}
<!-- load some JS to hide/show the custom date field -->
<script type="text/javascript">
$(function() {
// hide by default
$("div_id_expires_custom").hide();
// if the expires_custom checkbox is checked..
if ($("#id_expires_5").is(":checked")) {
// display the field
$("#div_id_expires_custom").slideDown();
} else {
// keep it up
$("#div_id_expires_custom").slideUp();
}
// if the expires_custom checkbox is clicked..
$("#div_id_expires").click(function() {
// if the expires_custom checkbox is checked..
if ($("#id_expires_5").is(":checked")) {
// display the field
$("#div_id_expires_custom").slideDown();
} else {
// keep it hidden
$("#div_id_expires_custom").slideUp();
}
})
})
</script>
<!-- show all of the links -->
<div class="row">
<!-- for every url in the urls list-->
{% for url in urls %}
<legend>
<!-- include the link box for this url -->
{% include 'link_box.html' %}
</legend>
<!-- unless the list is empty -->
{% empty %}
<h3>&nbsp;&nbsp;&nbsp;None found <i class="fa fa-frown-o"></i></h3>
{% endfor %}
</div>
{% endblock %}
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- load django crispy forms' tags -->
{% load crispy_forms_tags %}
<!-- define the page title block -->
{% block title %}
SRCT Go &bull; My Links
SRCT Go &bull; A University Branded URL Shortener
{% endblock %}
<!-- define the content block for the page -->
......@@ -18,27 +21,42 @@ SRCT Go &bull; My Links
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-link fa-stack-1x fa-inverse"></i>
</span>
<i class="fa">My Links</i>
<i class="fa">Shorten URL</i>
</strong></h1>
</div>
</div>
<div class="newlink" style="text-align: right;">
<a href="{% url 'index' %}"><i class="fa fa-plus" aria-hidden="true"></i> Add new link</a>
</div>
</div>
<!-- show all of the links -->
<div class="row">
<!-- for every url in the urls list-->
{% for url in urls %}
<legend>
<!-- include the link box for this url -->
{% include 'link_box.html' %}
</legend>
<!-- unless the list is empty -->
{% empty %}
<h3>&nbsp;&nbsp;&nbsp;None found <i class="fa fa-frown-o"></i></h3>
{% endfor %}
</div>
<!-- call django crispy forms to render the go link creation form here -->
{% crispy form %}
<!-- load some JS to hide/show the custom date field -->
<script type="text/javascript">
$(function() {
// hide by default
$("div_id_expires_custom").hide();
// if the expires_custom checkbox is checked..
if ($("#id_expires_5").is(":checked")) {
// display the field
$("#div_id_expires_custom").slideDown();
} else {
// keep it up
$("#div_id_expires_custom").slideUp();
}
// if the expires_custom checkbox is clicked..
$("#div_id_expires").click(function() {
// if the expires_custom checkbox is checked..
if ($("#id_expires_5").is(":checked")) {
// display the field
$("#div_id_expires_custom").slideDown();
} else {
// keep it hidden
$("#div_id_expires_custom").slideUp();
}
})
})
</script>
{% endblock %}
......@@ -27,7 +27,7 @@
{% if user.is_authenticated %}
<!-- only if they are an approved user -->
{% if user.registereduser.approved %}
<li><a href="{% url 'my_links' %}">My Links</a></li>
<li><a href="{% url 'new_link' %}">New Link</a></li>
{% endif %}
<!-- only if the current user has not registered to use go -->
{% if not user.registereduser.registered %}
......
......@@ -28,7 +28,7 @@ from datetime import timedelta
not_registered error page. If they are logged in AND registered, they
get the URL registration form.
"""
def index(request):
def new_link(request):
# If the user is blocked, redirect them to the blocked page.
# If the user is not authenticated, show them a public landing page.
if not request.user.is_authenticated():
......@@ -50,11 +50,15 @@ def index(request):
return redirect('view', post(request).short)
# Render index.html passing the form to the template
return render(request, 'core/index.html', {
return render(request, 'core/new_link.html', {
'form': url_form,
},
)
# for compatibility, just in case
def my_links(request):
return index(request)
#rate limits are completely arbitrary
@ratelimit(key='user', rate='3/m', method='POST', block=True)
@ratelimit(key='user', rate='25/d', method='POST', block=True)
......@@ -139,7 +143,7 @@ def view(request, short):
obviously need to be logged in to view your URLs.
"""
@login_required
def my_links(request):
def index(request):
# Do not display this page to unapproved users
if not request.user.registereduser.approved:
......@@ -152,7 +156,7 @@ def my_links(request):
urls = URL.objects.filter(owner = request.user.registereduser)
# Render my_links.html passing the list of URL's and Domain to the template
return render(request, 'my_links.html', {
return render(request, 'core/index.html', {
'urls': urls,
'domain': domain,
},
......
......@@ -26,8 +26,8 @@ urlpatterns = [
# /signup - Signup page for access.
url(r'^signup/?$', go.views.signup, name='signup'),
# /my - My-Links page, view and review links.
url(r'^myLinks/?$', go.views.my_links, name='my_links'),
# /new - My-Links page, view and review links.
url(r'^newLink/?$', go.views.new_link, name='new_link'),
# /delete/<short> - Delete a link, no content display.
url(r'^delete/(?P<short>[-\w]+)$', go.views.delete, name='delete'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment