diff --git a/pinry/core/urls.py b/pinry/core/urls.py index 2c24676..e9ed1aa 100644 --- a/pinry/core/urls.py +++ b/pinry/core/urls.py @@ -5,7 +5,7 @@ urlpatterns = patterns('', url(r'^$', 'pinry.core.views.home', name='home'), url(r'^private/$', 'pinry.core.views.private', name='private'), url(r'^login/$', 'django.contrib.auth.views.login', - {'template_name': 'core/login.html'}, name='login'), + {'template_name': 'user/login.html'}, name='login'), url(r'^register/$', 'pinry.core.views.register', name='register'), url(r'^logout/$', 'pinry.core.views.logout_user', name='logout'), ) diff --git a/pinry/core/views.py b/pinry/core/views.py index 86f7e3c..ca834d4 100644 --- a/pinry/core/views.py +++ b/pinry/core/views.py @@ -15,7 +15,7 @@ def home(request): def private(request): - return TemplateResponse(request, 'core/private.html', None) + return TemplateResponse(request, 'user/private.html', None) def register(request): @@ -35,7 +35,7 @@ def register(request): else: form = UserCreationForm() - return TemplateResponse(request, 'core/register.html', {'form': form}) + return TemplateResponse(request, 'user/register.html', {'form': form}) @login_required diff --git a/pinry/pins/models.py b/pinry/pins/models.py index 7891271..422943a 100644 --- a/pinry/pins/models.py +++ b/pinry/pins/models.py @@ -1,5 +1,6 @@ -from cStringIO import StringIO import urllib2 +from cStringIO import StringIO + from django.core.files.uploadedfile import InMemoryUploadedFile from django.db import models diff --git a/pinry/pins/templatetags/__init__.py b/pinry/pins/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/pinry/pins/templatetags/new_pin.py b/pinry/pins/templatetags/new_pin.py deleted file mode 100644 index eef890b..0000000 --- a/pinry/pins/templatetags/new_pin.py +++ /dev/null @@ -1,15 +0,0 @@ -from django.template.loader import render_to_string -from django.template import Library -from django.template import RequestContext - -from pinry.pins.forms import ImageForm - - -register = Library() - - -@register.simple_tag -def new_pin(request): - return render_to_string('pins/templatetags/new_pin.html', - {'form': ImageForm()}, - context_instance=RequestContext(request)) diff --git a/pinry/pins/tests.py b/pinry/pins/tests.py deleted file mode 100644 index a3e2e4a..0000000 --- a/pinry/pins/tests.py +++ /dev/null @@ -1,60 +0,0 @@ -from django.test import TestCase -from django.test.client import Client -from django.core.urlresolvers import reverse - - -class RecentPinsTest(TestCase): - def setUp(self): - self.client = Client() - self.url = reverse('pins:recent-pins') - - def test_url(self): - self.assertEqual(self.url, '/pins/') - - def test_status_code(self): - response = self.client.get(self.url) - self.assertEqual(response.status_code, 200) - - -class NewPinTest(TestCase): - def setUp(self): - self.client = Client() - self.url = reverse('pins:new-pin') - - def test_url(self): - self.assertEqual(self.url, '/pins/new-pin/') - - def test_status_code(self): - response = self.client.get(self.url) - self.assertEqual(response.status_code, 200) - - def test_new_pin(self): - response = self.client.post(self.url, { - 'url': 'https://github.com/overshard/pinry/raw/master/' - 'screenshot.png', - }) - self.assertEqual(response.status_code, 200) - - def test_new_pin_invalid_protocol(self): - response = self.client.post(self.url, { - 'url': 'ftp://github.com/overshard/pinry/raw/master/' - 'screenshot.png', - }) - self.assertEqual(response.status_code, 200) - - def test_new_pin_invalid_file_type(self): - response = self.client.post(self.url, { - 'url': 'https://raw.github.com/overshard/pinry/master/README.md', - }) - self.assertEqual(response.status_code, 200) - - def test_new_pin_already_pinned(self): - response = self.client.post(self.url, { - 'url': 'http://github.com/overshard/pinry/raw/master/' - 'screenshot.png', - }) - response = self.client.post(self.url, { - 'url': 'https://github.com/overshard/pinry/raw/master/' - 'screenshot.png', - }) - self.assertEqual(response.status_code, 200) diff --git a/pinry/pins/urls.py b/pinry/pins/urls.py index 4ea50b2..9bef562 100644 --- a/pinry/pins/urls.py +++ b/pinry/pins/urls.py @@ -1,11 +1,11 @@ from django.conf.urls import patterns, url +from django.views.generic import TemplateView -from .views import RecentPins from .views import UploadImage urlpatterns = patterns('pinry.pins.views', - url(r'^$', RecentPins.as_view(), name='recent-pins'), - url(r'^tag/.+/$', RecentPins.as_view(), name='tag'), url(r'^upload-pin/$', UploadImage.as_view(), name='new-pin'), + url(r'^$', TemplateView.as_view(template_name='core/recent_pins.html'), + name='recent-pins'), ) diff --git a/pinry/pins/views.py b/pinry/pins/views.py index e81e556..21779c4 100644 --- a/pinry/pins/views.py +++ b/pinry/pins/views.py @@ -2,23 +2,17 @@ import json from django.contrib.auth import REDIRECT_FIELD_NAME from django.contrib.auth.decorators import login_required -from django.core.urlresolvers import reverse from django.contrib import messages from django.http import HttpResponse from django.utils.decorators import method_decorator from django.utils.functional import lazy -from django.views.generic import ( - TemplateView, CreateView) -from django.views.generic.detail import SingleObjectTemplateResponseMixin +from django.views.generic import CreateView from django_images.models import Image from .forms import ImageForm -reverse_lazy = lambda name=None, *args: lazy(reverse, str)(name, args=args) - - class LoginRequiredMixin(object): """ A login required mixin for use with class based views. This Class is a light wrapper around the @@ -68,7 +62,7 @@ class JSONResponseMixin(object): class UploadImage(JSONResponseMixin, LoginRequiredMixin, CreateView): - template_name = 'pins/pin_form.html' + template_name = 'core/pin_form.html' model = Image form_class = ImageForm @@ -90,7 +84,3 @@ class UploadImage(JSONResponseMixin, LoginRequiredMixin, CreateView): else: messages.error(self.request, message) return super(UploadImage, self).form_invalid(form) - - -class RecentPins(TemplateView): - template_name = 'pins/recent_pins.html' \ No newline at end of file diff --git a/pinry/settings/__init__.py b/pinry/settings/__init__.py index 637b11e..5eccf78 100644 --- a/pinry/settings/__init__.py +++ b/pinry/settings/__init__.py @@ -35,7 +35,6 @@ STATICFILES_DIRS = [os.path.join(SITE_ROOT, 'pinry/static')] STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', - 'compressor.finders.CompressorFinder', ) TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', @@ -64,7 +63,6 @@ AUTHENTICATION_BACKENDS = ( ) -COMPRESS_CSS_FILTERS = ['compressor.filters.cssmin.CSSMinFilter'] ROOT_URLCONF = 'pinry.urls' LOGIN_REDIRECT_URL = '/' INTERNAL_IPS = ['127.0.0.1'] @@ -84,7 +82,6 @@ INSTALLED_APPS = ( 'django.contrib.messages', 'django.contrib.staticfiles', 'south', - 'compressor', 'taggit', 'django_images', 'pinry.core', diff --git a/pinry/templates/404.html b/pinry/templates/404.html index 956dd02..060bcdd 100644 --- a/pinry/templates/404.html +++ b/pinry/templates/404.html @@ -1,5 +1,4 @@ -{% extends 'core/base.html' %} - +{% extends "base.html" %} {% block title %}404{% endblock %} diff --git a/pinry/templates/500.html b/pinry/templates/500.html index 2aa6607..6018614 100644 --- a/pinry/templates/500.html +++ b/pinry/templates/500.html @@ -1,5 +1,4 @@ -{% extends 'core/base.html' %} - +{% extends "base.html" %} {% block title %}500{% endblock %} diff --git a/pinry/templates/base.html b/pinry/templates/base.html new file mode 100644 index 0000000..129454c --- /dev/null +++ b/pinry/templates/base.html @@ -0,0 +1,79 @@ + + + + + + + + {{ SITE_NAME }} - {% block title %}{% endblock %} + + + + + + + + {% block extra_css %}{% endblock %} + + + + + + + + + + {% block yield %}{% endblock %} + + + + {% include "includes/messages.html" %} + + + + {% include "includes/lightbox.html" %} + {% include "includes/pins.html" %} + {% include "includes/pin_form.html" %} + {% block extra_templates %}{% endblock %} + + + + + + + + + + + + {% block extra_js %}{% endblock %} + + + diff --git a/pinry/templates/core/base.html b/pinry/templates/core/base.html deleted file mode 100644 index 34eab0a..0000000 --- a/pinry/templates/core/base.html +++ /dev/null @@ -1,67 +0,0 @@ -{% spaceless %} -{% load compress new_pin %} - - - - - {{ SITE_NAME }} - {% block title %}{% endblock %} - - - - {% compress css %} - - - - {% endcompress %} - - - - - {% if messages %} - - {% endif %} - - {% block yield %}{% endblock %} - - {% block templates %}{% endblock %} - - {% compress js inline %} - - {% endcompress %} - - - - - {% compress js %} - - - - - {% endcompress %} - - -{% endspaceless %} diff --git a/pinry/templates/core/recent_pins.html b/pinry/templates/core/recent_pins.html new file mode 100644 index 0000000..fb163f8 --- /dev/null +++ b/pinry/templates/core/recent_pins.html @@ -0,0 +1,14 @@ +{% extends "base.html" %} + +{% block title %}Recent Pins{% endblock %} + +{% block yield %} +
+
+
+
+ Loader +
+
+
+{% endblock %} diff --git a/pinry/templates/core/templatetags/bootstrap_field.html b/pinry/templates/includes/field.html similarity index 100% rename from pinry/templates/core/templatetags/bootstrap_field.html rename to pinry/templates/includes/field.html diff --git a/pinry/templates/includes/lightbox.html b/pinry/templates/includes/lightbox.html new file mode 100644 index 0000000..a37525b --- /dev/null +++ b/pinry/templates/includes/lightbox.html @@ -0,0 +1,23 @@ +{% verbatim %} + +{% endverbatim %} diff --git a/pinry/templates/includes/messages.html b/pinry/templates/includes/messages.html new file mode 100644 index 0000000..2cd34c6 --- /dev/null +++ b/pinry/templates/includes/messages.html @@ -0,0 +1,7 @@ +{% if messages %} + +{% endif %} diff --git a/pinry/templates/includes/pin_form.html b/pinry/templates/includes/pin_form.html new file mode 100644 index 0000000..13b782d --- /dev/null +++ b/pinry/templates/includes/pin_form.html @@ -0,0 +1,38 @@ +{% verbatim %} + +{% endverbatim %} diff --git a/pinry/templates/includes/pins.html b/pinry/templates/includes/pins.html new file mode 100644 index 0000000..242558a --- /dev/null +++ b/pinry/templates/includes/pins.html @@ -0,0 +1,35 @@ +{% verbatim %} + +{% endverbatim %} diff --git a/pinry/templates/pins/bookmarklet.html b/pinry/templates/pins/bookmarklet.html deleted file mode 100644 index bf45322..0000000 --- a/pinry/templates/pins/bookmarklet.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends 'core/base.html' %} - -{% block title %}Bookmarket{% endblock %} - -{% block yield %} - Test -{% endblock %} diff --git a/pinry/templates/pins/pin_form.html b/pinry/templates/pins/pin_form.html deleted file mode 100644 index 3318847..0000000 --- a/pinry/templates/pins/pin_form.html +++ /dev/null @@ -1,26 +0,0 @@ -{% extends 'core/base.html' %} - -{% load bootstrap_field %} - - -{% block title %}New Pin{% endblock %} - -{% block yield %} -
-
-
-

New Pin

- {{ form.non_field_errors }} -
- {% for field in form %} - {% bootstrap_field field %} - {% endfor %} -
- - Cancel -
-
-
-
-
-{% endblock %} diff --git a/pinry/templates/pins/recent_pins.html b/pinry/templates/pins/recent_pins.html deleted file mode 100644 index 328422c..0000000 --- a/pinry/templates/pins/recent_pins.html +++ /dev/null @@ -1,111 +0,0 @@ -{% extends 'core/base.html' %} - -{% block title %}Recent Pins{% endblock %} - -{% block yield %} -
-
-
-
- Loader -
-
-
-{% endblock %} - -{% block templates %} - {% verbatim %} - - - - - - {% endverbatim %} -{% endblock %} diff --git a/pinry/templates/pins/templatetags/new_pin.html b/pinry/templates/pins/templatetags/new_pin.html deleted file mode 100644 index 9a84a2a..0000000 --- a/pinry/templates/pins/templatetags/new_pin.html +++ /dev/null @@ -1,18 +0,0 @@ -{% load bootstrap_field %} - - diff --git a/pinry/templates/core/login.html b/pinry/templates/user/login.html similarity index 69% rename from pinry/templates/core/login.html rename to pinry/templates/user/login.html index e9ca6ce..1807bd7 100644 --- a/pinry/templates/core/login.html +++ b/pinry/templates/user/login.html @@ -1,7 +1,4 @@ -{% extends 'core/base.html' %} - -{% load bootstrap_field %} - +{% extends "base.html" %} {% block title %}Login{% endblock %} @@ -10,14 +7,13 @@

Login

-
+ {% csrf_token %} {% for field in form %} - {% bootstrap_field field %} + {% include "includes/field.html" %} {% endfor %}
- Cancel
diff --git a/pinry/templates/core/private.html b/pinry/templates/user/private.html similarity index 86% rename from pinry/templates/core/private.html rename to pinry/templates/user/private.html index 07e2212..5b3096b 100644 --- a/pinry/templates/core/private.html +++ b/pinry/templates/user/private.html @@ -1,7 +1,4 @@ -{% extends 'core/base.html' %} - -{% load bootstrap_field %} - +{% extends "base.html" %} {% block title %}Private{% endblock %} diff --git a/pinry/templates/core/register.html b/pinry/templates/user/register.html similarity index 65% rename from pinry/templates/core/register.html rename to pinry/templates/user/register.html index 68b4f92..8e43124 100644 --- a/pinry/templates/core/register.html +++ b/pinry/templates/user/register.html @@ -1,23 +1,19 @@ -{% extends 'core/base.html' %} +{% extends "base.html" %} -{% load bootstrap_field %} - - -{% block title %}Login{% endblock %} +{% block title %}Register{% endblock %} {% block yield %}

Register

-
+ {% csrf_token %} {% for field in form %} - {% bootstrap_field field %} + {% include "includes/field.html" %} {% endfor %}
- Cancel
diff --git a/requirements.txt b/requirements.txt index 8e38455..df2ee29 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,6 @@ http://github.com/django/django/tarball/stable/1.5.x#egg=Django -South Pillow +South django-tastypie -django_compressor -cssmin -jsmin django-images -http://github.com/hcarvalhoalves/django-taggit/tarball/master#egg=django-taggit \ No newline at end of file +http://github.com/hcarvalhoalves/django-taggit/tarball/master#egg=django-taggit