From ce1f17e5104d44fa833090c47dd76466a2d7f743 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Apr 2015 21:47:49 -0400 Subject: Redirect several URLs at the router level. --- public/tests.py | 8 +++++-- public/views.py | 14 +---------- templates/public/art.html | 57 -------------------------------------------- templates/public/donate.html | 28 ---------------------- urls.py | 14 ++++++----- 5 files changed, 15 insertions(+), 106 deletions(-) delete mode 100644 templates/public/art.html delete mode 100644 templates/public/donate.html diff --git a/public/tests.py b/public/tests.py index 49bbd2bb..d0140e98 100644 --- a/public/tests.py +++ b/public/tests.py @@ -13,7 +13,9 @@ class PublicTest(TestCase): def test_art(self): response = self.client.get('/art/') - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, 302) + self.assertTrue(response['Location'].startswith( + 'https://projects.parabola.nu/artwork.git/') def test_svn(self): response = self.client.get('/svn/') @@ -35,7 +37,9 @@ class PublicTest(TestCase): def test_donate(self): response = self.client.get('/donate/') - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, 302) + self.assertEqual(response['Location'], + 'https://wiki.parabola.nu/Donations') def test_download(self): response = self.client.get('/download/') diff --git a/public/views.py b/public/views.py index 0b245071..57634983 100644 --- a/public/views.py +++ b/public/views.py @@ -5,7 +5,7 @@ from operator import attrgetter from django.conf import settings from django.contrib.auth.models import User from django.db.models import Count, Q -from django.http import Http404, HttpResponse, HttpResponseRedirect +from django.http import Http404, HttpResponse from django.shortcuts import render from django.views.decorators.cache import cache_control, cache_page @@ -63,14 +63,6 @@ def userlist(request, user_type='hackers'): return render(request, 'public/userlist.html', context) -@cache_control(max_age=307) -def donate(request): - context = { - 'donors': Donor.objects.filter(visible=True).order_by('name'), - } - return render(request, 'public/donate.html', context) - - def _mirror_urls(): '''In order to ensure this is lazily evaluated since we can't do sorting at the database level, make it a callable.''' @@ -81,10 +73,6 @@ def _mirror_urls(): return sorted(urls, key=sort_by) -@cache_control(max_age=307) -def download(request): - return HttpResponseRedirect('https://wiki.parabola.nu/Get_Parabola') - @cache_control(max_age=307) def feeds(request): repos = Repo.objects.all() diff --git a/templates/public/art.html b/templates/public/art.html deleted file mode 100644 index 32acc172..00000000 --- a/templates/public/art.html +++ /dev/null @@ -1,57 +0,0 @@ -{% extends "base.html" %} -{% load static from staticfiles %} - -{% block title %}{{ BRANDING_DISTRONAME }} - Artwork{% endblock %} - -{% block content %} -
- -

{{ BRANDING_DISTRONAME }} Logos and Artwork

- -

You can help by creating artwork for {{ BRANDING_DISTRONAME }}.

- -

Send your designs to dev@lists.parabola.nu and state they are CC-by-sa - or another free culture friendly license.

- -{% comment %} -

Logos for Press Usage

- -

The following {{BRANDING_DISTRONAME}} logos are available for press and other use.

- -

Two-color standard version
- - - Also available in print-quality - PNG and scalable - SVG formats.

- - Parabola PNG logo @ 90dpi - -

Two-color inverted version (for dark backgrounds)
- - -

One-color standard version
- - -

One-colour inverted version (for dark backgrounds)
- -

Logos and Artwork for the Community

- -

Official logos and artwork are also available directly from the - repositories. These packages would be:

- - -{% endcomment %} - -
-{% endblock %} diff --git a/templates/public/donate.html b/templates/public/donate.html deleted file mode 100644 index f7087dc9..00000000 --- a/templates/public/donate.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends "base.html" %} -{% load cache %} -{% load static from staticfiles %} -{% load wiki %} - -{% block title %}{{ BRANDING_DISTRONAME }} - Donate{% endblock %} - -{% block content %} -{% cache 600 donations secure %} -
- -

Donate to {{ BRANDING_SHORTNAME }}

- -

We don't accept any money donations

- -

That's right. At the moment, Parabola isn't accepting any money - donations. And that's because we have nothing to do with them. We really - don't, at the moment. So, some voluntary work is much preferred than - anything, because we are a really small community of hackers.

- -

If you want, we have a pretty nice TODO list you can check to help us by donating some of your - time. That will be very much appreciated by us :)

- -
-{% endcache %} -{% endblock %} diff --git a/urls.py b/urls.py index 506b83ef..e7a2cbc3 100644 --- a/urls.py +++ b/urls.py @@ -25,14 +25,16 @@ urlpatterns += patterns('public.views', (r'^$', 'index', {}, 'index'), (r'^about/$', TemplateView.as_view(template_name='public/about.html'), {}, 'page-about'), + ('^art/$', RedirectView.as_view('https://projects.parabola.nu/artwork.git/'), + {}, 'page-art'), (r'^https/$', TemplateView.as_view(template_name='public/https.html'), {}, 'page-https'), - (r'^art/$', TemplateView.as_view(template_name='public/art.html'), - {}, 'page-art'), (r'^hackers/$', 'userlist', { 'user_type':'hackers' }, 'page-devs'), (r'^fellows/$', 'userlist', { 'user_type':'fellows' }, 'page-fellows'), - (r'^donate/$', 'donate', {}, 'page-donate'), - (r'^download/$', 'download', {}, 'page-download'), + (r'^donate/$', RedirectView.as_view('https://wiki.parabola.nu/Donations'), + {}, 'page-donate'), + (r'^download/$', RedirectView.as_view('https://wiki.parabola.nu/Get_Parabola'), + {}, 'page-download'), (r'^master-keys/$', 'keys', {}, 'page-keys'), (r'^master-keys/json/$', 'keys_json', {}, 'pgp-keys-json'), ) @@ -109,8 +111,8 @@ legacy_urls = ( ('^docs/', 'https://wiki.parabola.nu/'), - ('^developers/$', '/hackers/'), - ('^trustedusers/$', '/hackers/'), + ('^developers/$', '/hackers/'), + ('^trustedusers/$', '/hackers/'), ) urlpatterns += [url(old_url, RedirectView.as_view(url=new_url)) -- cgit v1.2.3