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

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 --> <!-- include the base html template -->
{% extends 'layouts/base.html' %} {% extends 'layouts/base.html' %}
<!-- load django crispy forms' tags -->
{% load crispy_forms_tags %}
<!-- define the page title block --> <!-- define the page title block -->
{% block title %} {% block title %}
SRCT Go &bull; A University Branded URL Shortener SRCT Go &bull; My Links
{% endblock %} {% endblock %}
<!-- define the content block for the page --> <!-- define the content block for the page -->
...@@ -21,42 +18,27 @@ SRCT Go &bull; A University Branded URL Shortener ...@@ -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-circle fa-stack-2x"></i>
<i class="fa fa-link fa-stack-1x fa-inverse"></i> <i class="fa fa-link fa-stack-1x fa-inverse"></i>
</span> </span>
<i class="fa">Shorten URL</i> <i class="fa">My Links</i>
</strong></h1> </strong></h1>
</div> </div>
</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> </div>
<!-- call django crispy forms to render the go link creation form here --> <!-- show all of the links -->
{% crispy form %} <div class="row">
<!-- for every url in the urls list-->
<!-- load some JS to hide/show the custom date field --> {% for url in urls %}
<script type="text/javascript"> <legend>
$(function() { <!-- include the link box for this url -->
// hide by default {% include 'link_box.html' %}
$("div_id_expires_custom").hide(); </legend>
<!-- unless the list is empty -->
// if the expires_custom checkbox is checked.. {% empty %}
if ($("#id_expires_5").is(":checked")) { <h3>&nbsp;&nbsp;&nbsp;None found <i class="fa fa-frown-o"></i></h3>
// display the field {% endfor %}
$("#div_id_expires_custom").slideDown(); </div>
} 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 %} {% endblock %}
<!-- include the base html template --> <!-- include the base html template -->
{% extends 'layouts/base.html' %} {% extends 'layouts/base.html' %}
<!-- load django crispy forms' tags -->
{% load crispy_forms_tags %}
<!-- define the page title block --> <!-- define the page title block -->
{% block title %} {% block title %}
SRCT Go &bull; My Links SRCT Go &bull; A University Branded URL Shortener
{% endblock %} {% endblock %}
<!-- define the content block for the page --> <!-- define the content block for the page -->
...@@ -18,27 +21,42 @@ SRCT Go &bull; My Links ...@@ -18,27 +21,42 @@ SRCT Go &bull; My Links
<i class="fa fa-circle fa-stack-2x"></i> <i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-link fa-stack-1x fa-inverse"></i> <i class="fa fa-link fa-stack-1x fa-inverse"></i>
</span> </span>
<i class="fa">My Links</i> <i class="fa">Shorten URL</i>
</strong></h1> </strong></h1>
</div> </div>
</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> </div>
<!-- show all of the links --> <!-- call django crispy forms to render the go link creation form here -->
<div class="row"> {% crispy form %}
<!-- for every url in the urls list-->
{% for url in urls %} <!-- load some JS to hide/show the custom date field -->
<legend> <script type="text/javascript">
<!-- include the link box for this url --> $(function() {
{% include 'link_box.html' %} // hide by default
</legend> $("div_id_expires_custom").hide();
<!-- unless the list is empty -->
{% empty %} // if the expires_custom checkbox is checked..
<h3>&nbsp;&nbsp;&nbsp;None found <i class="fa fa-frown-o"></i></h3> if ($("#id_expires_5").is(":checked")) {
{% endfor %} // display the field
</div> $("#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 %} {% endblock %}
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
{% if user.is_authenticated %} {% if user.is_authenticated %}
<!-- only if they are an approved user --> <!-- only if they are an approved user -->
{% if user.registereduser.approved %} {% 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 %} {% endif %}
<!-- only if the current user has not registered to use go --> <!-- only if the current user has not registered to use go -->
{% if not user.registereduser.registered %} {% if not user.registereduser.registered %}
......
...@@ -28,7 +28,7 @@ from datetime import timedelta ...@@ -28,7 +28,7 @@ from datetime import timedelta
not_registered error page. If they are logged in AND registered, they not_registered error page. If they are logged in AND registered, they
get the URL registration form. 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 blocked, redirect them to the blocked page.
# If the user is not authenticated, show them a public landing page. # If the user is not authenticated, show them a public landing page.
if not request.user.is_authenticated(): if not request.user.is_authenticated():
...@@ -50,11 +50,15 @@ def index(request): ...@@ -50,11 +50,15 @@ def index(request):
return redirect('view', post(request).short) return redirect('view', post(request).short)
# Render index.html passing the form to the template # 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, 'form': url_form,
}, },
) )
# for compatibility, just in case
def my_links(request):
return index(request)
#rate limits are completely arbitrary #rate limits are completely arbitrary
@ratelimit(key='user', rate='3/m', method='POST', block=True) @ratelimit(key='user', rate='3/m', method='POST', block=True)
@ratelimit(key='user', rate='25/d', method='POST', block=True) @ratelimit(key='user', rate='25/d', method='POST', block=True)
...@@ -139,7 +143,7 @@ def view(request, short): ...@@ -139,7 +143,7 @@ def view(request, short):
obviously need to be logged in to view your URLs. obviously need to be logged in to view your URLs.
""" """
@login_required @login_required
def my_links(request): def index(request):
# Do not display this page to unapproved users # Do not display this page to unapproved users
if not request.user.registereduser.approved: if not request.user.registereduser.approved:
...@@ -152,7 +156,7 @@ def my_links(request): ...@@ -152,7 +156,7 @@ def my_links(request):
urls = URL.objects.filter(owner = request.user.registereduser) urls = URL.objects.filter(owner = request.user.registereduser)
# Render my_links.html passing the list of URL's and Domain to the template # 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, 'urls': urls,
'domain': domain, 'domain': domain,
}, },
......
...@@ -26,8 +26,8 @@ urlpatterns = [ ...@@ -26,8 +26,8 @@ urlpatterns = [
# /signup - Signup page for access. # /signup - Signup page for access.
url(r'^signup/?$', go.views.signup, name='signup'), url(r'^signup/?$', go.views.signup, name='signup'),
# /my - My-Links page, view and review links. # /new - My-Links page, view and review links.
url(r'^myLinks/?$', go.views.my_links, name='my_links'), url(r'^newLink/?$', go.views.new_link, name='new_link'),
# /delete/<short> - Delete a link, no content display. # /delete/<short> - Delete a link, no content display.
url(r'^delete/(?P<short>[-\w]+)$', go.views.delete, name='delete'), 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