@@ -12,4 +12,4 @@ class Public(object): | |||||
'/register/', | '/register/', | ||||
] | ] | ||||
if request.path not in acceptable_paths: | if request.path not in acceptable_paths: | ||||
return HttpResponseRedirect(reverse('core:private')) | |||||
return HttpResponseRedirect(reverse('users:private')) |
@@ -20,9 +20,11 @@ urlpatterns = patterns('', | |||||
url(r'^pins/pin-form/$', TemplateView.as_view(template_name='core/pin_form.html'), | url(r'^pins/pin-form/$', TemplateView.as_view(template_name='core/pin_form.html'), | ||||
name='pin-form'), | name='pin-form'), | ||||
url(r'^pins/create-image/$', CreateImage.as_view(), name='create-image'), | url(r'^pins/create-image/$', CreateImage.as_view(), name='create-image'), | ||||
url(r'^tag/(?P<tag>(\w|-)+)/$', TemplateView.as_view(template_name='core/pins.html'), | |||||
url(r'^pins/tag/(?P<tag>(\w|-)+)/$', TemplateView.as_view(template_name='core/pins.html'), | |||||
name='tag-pins'), | name='tag-pins'), | ||||
url(r'^private/$', 'pinry.core.views.private', name='private'), | |||||
url(r'^pins/user/(?P<user>(\w|-)+)/$', TemplateView.as_view(template_name='core/pins.html'), | |||||
name='user-pins'), | |||||
url(r'^$', TemplateView.as_view(template_name='core/pins.html'), | url(r'^$', TemplateView.as_view(template_name='core/pins.html'), | ||||
name='recent-pins'), | name='recent-pins'), | ||||
) | ) |
@@ -1,4 +1,3 @@ | |||||
from django.template.response import TemplateResponse | |||||
from django.http import HttpResponseRedirect | from django.http import HttpResponseRedirect | ||||
from django.core.urlresolvers import reverse | from django.core.urlresolvers import reverse | ||||
from django.views.generic import CreateView | from django.views.generic import CreateView | ||||
@@ -9,10 +8,6 @@ from braces.views import JSONResponseMixin, LoginRequiredMixin | |||||
from .forms import ImageForm | from .forms import ImageForm | ||||
def private(request): | |||||
return TemplateResponse(request, 'user/private.html', None) | |||||
class CreateImage(JSONResponseMixin, LoginRequiredMixin, CreateView): | class CreateImage(JSONResponseMixin, LoginRequiredMixin, CreateView): | ||||
template_name = None # JavaScript-only view | template_name = None # JavaScript-only view | ||||
model = Image | model = Image | ||||
@@ -32,4 +27,4 @@ class CreateImage(JSONResponseMixin, LoginRequiredMixin, CreateView): | |||||
}) | }) | ||||
def form_invalid(self, form): | def form_invalid(self, form): | ||||
return self.render_json_response({'error': form.errors}) | |||||
return self.render_json_response({'error': form.errors}) |
@@ -77,6 +77,7 @@ $(window).load(function() { | |||||
// Fetch our pins from the api using our current offset | // Fetch our pins from the api using our current offset | ||||
var apiUrl = '/api/v1/pin/?format=json&order_by=-id&offset='+String(offset); | var apiUrl = '/api/v1/pin/?format=json&order_by=-id&offset='+String(offset); | ||||
if (tagFilter) apiUrl = apiUrl + '&tag=' + tagFilter; | if (tagFilter) apiUrl = apiUrl + '&tag=' + tagFilter; | ||||
if (userFilter) apiUrl = apiUrl + '&submitter_username=' + userFilter; | |||||
$.get(apiUrl, function(pins) { | $.get(apiUrl, function(pins) { | ||||
// Set which items are editable by the current user | // Set which items are editable by the current user | ||||
for (var i=0; i < pins.objects.length; i++) | for (var i=0; i < pins.objects.length; i++) | ||||
@@ -35,7 +35,8 @@ | |||||
username: "{{ user.username }}", | username: "{{ user.username }}", | ||||
gravatar: "{{ user.gravatar }}" | gravatar: "{{ user.gravatar }}" | ||||
}, | }, | ||||
tagFilter = "{{ request.resolver_match.kwargs.tag }}"; | |||||
tagFilter = "{{ request.resolver_match.kwargs.tag }}", | |||||
userFilter = "{{ request.resolver_match.kwargs.user }}"; | |||||
</script> | </script> | ||||
<!-- End JavaScript Variables --> | <!-- End JavaScript Variables --> | ||||
</head> | </head> | ||||
@@ -23,7 +23,8 @@ | |||||
<img src="http://gravatar.com/avatar/{{submitter.gravatar}}"> | <img src="http://gravatar.com/avatar/{{submitter.gravatar}}"> | ||||
</div> | </div> | ||||
<div class="text pull-right"> | <div class="text pull-right"> | ||||
<span class="dim">pinned by</span> {{submitter.username}} | |||||
<span class="dim">pinned by</span> | |||||
<a href="/pins/user/{{submitter.username}}/">{{submitter.username}}</a> | |||||
{{#if tags}} | {{#if tags}} | ||||
<span class="dim">in</span> | <span class="dim">in</span> | ||||
{{#each tags}} | {{#each tags}} | ||||
@@ -3,8 +3,9 @@ from django.conf.urls import patterns, url | |||||
from .views import CreateUser | from .views import CreateUser | ||||
urlpatterns = patterns('', | urlpatterns = patterns('', | ||||
url(r'^private/$', 'pinry.users.views.private', name='private'), | |||||
url(r'^register/$', CreateUser.as_view(), name='register'), | |||||
url(r'^login/$', 'django.contrib.auth.views.login', | url(r'^login/$', 'django.contrib.auth.views.login', | ||||
{'template_name': 'users/login.html'}, name='login'), | {'template_name': 'users/login.html'}, name='login'), | ||||
url(r'^logout/$', 'pinry.users.views.logout_user', name='logout'), | url(r'^logout/$', 'pinry.users.views.logout_user', name='logout'), | ||||
url(r'^register/$', CreateUser.as_view(), name='register'), | |||||
) | ) |
@@ -5,6 +5,7 @@ from django.contrib.auth.decorators import login_required | |||||
from django.contrib.auth.models import Permission | from django.contrib.auth.models import Permission | ||||
from django.core.urlresolvers import reverse | from django.core.urlresolvers import reverse | ||||
from django.http import HttpResponseRedirect | from django.http import HttpResponseRedirect | ||||
from django.template.response import TemplateResponse | |||||
from django.utils.functional import lazy | from django.utils.functional import lazy | ||||
from django.views.generic import CreateView | from django.views.generic import CreateView | ||||
@@ -42,3 +43,7 @@ def logout_user(request): | |||||
logout(request) | logout(request) | ||||
messages.success(request, 'You have successfully logged out.') | messages.success(request, 'You have successfully logged out.') | ||||
return HttpResponseRedirect(reverse('core:recent-pins')) | return HttpResponseRedirect(reverse('core:recent-pins')) | ||||
def private(request): | |||||
return TemplateResponse(request, 'users/private.html', None) |