Kaynağa Gözat

Move private to users, add user filtering to JS

tags/v1.0.0
Isaac Bythewood 11 yıl önce
ebeveyn
işleme
248bd25a04
8 değiştirilmiş dosya ile 18 ekleme ve 12 silme
  1. +1
    -1
      pinry/core/middleware.py
  2. +4
    -2
      pinry/core/urls.py
  3. +1
    -6
      pinry/core/views.py
  4. +1
    -0
      pinry/static/js/pinry.js
  5. +2
    -1
      pinry/templates/base.html
  6. +2
    -1
      pinry/templates/includes/pins.html
  7. +2
    -1
      pinry/users/urls.py
  8. +5
    -0
      pinry/users/views.py

+ 1
- 1
pinry/core/middleware.py Dosyayı Görüntüle

@@ -12,4 +12,4 @@ class Public(object):
'/register/',
]
if request.path not in acceptable_paths:
return HttpResponseRedirect(reverse('core:private'))
return HttpResponseRedirect(reverse('users:private'))

+ 4
- 2
pinry/core/urls.py Dosyayı Görüntüle

@@ -20,9 +20,11 @@ urlpatterns = patterns('',
url(r'^pins/pin-form/$', TemplateView.as_view(template_name='core/pin_form.html'),
name='pin-form'),
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'),
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'),
name='recent-pins'),
)

+ 1
- 6
pinry/core/views.py Dosyayı Görüntüle

@@ -1,4 +1,3 @@
from django.template.response import TemplateResponse
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.views.generic import CreateView
@@ -9,10 +8,6 @@ from braces.views import JSONResponseMixin, LoginRequiredMixin
from .forms import ImageForm


def private(request):
return TemplateResponse(request, 'user/private.html', None)


class CreateImage(JSONResponseMixin, LoginRequiredMixin, CreateView):
template_name = None # JavaScript-only view
model = Image
@@ -32,4 +27,4 @@ class CreateImage(JSONResponseMixin, LoginRequiredMixin, CreateView):
})

def form_invalid(self, form):
return self.render_json_response({'error': form.errors})
return self.render_json_response({'error': form.errors})

+ 1
- 0
pinry/static/js/pinry.js Dosyayı Görüntüle

@@ -77,6 +77,7 @@ $(window).load(function() {
// Fetch our pins from the api using our current offset
var apiUrl = '/api/v1/pin/?format=json&order_by=-id&offset='+String(offset);
if (tagFilter) apiUrl = apiUrl + '&tag=' + tagFilter;
if (userFilter) apiUrl = apiUrl + '&submitter_username=' + userFilter;
$.get(apiUrl, function(pins) {
// Set which items are editable by the current user
for (var i=0; i < pins.objects.length; i++)


+ 2
- 1
pinry/templates/base.html Dosyayı Görüntüle

@@ -35,7 +35,8 @@
username: "{{ user.username }}",
gravatar: "{{ user.gravatar }}"
},
tagFilter = "{{ request.resolver_match.kwargs.tag }}";
tagFilter = "{{ request.resolver_match.kwargs.tag }}",
userFilter = "{{ request.resolver_match.kwargs.user }}";
</script>
<!-- End JavaScript Variables -->
</head>


+ 2
- 1
pinry/templates/includes/pins.html Dosyayı Görüntüle

@@ -23,7 +23,8 @@
<img src="http://gravatar.com/avatar/{{submitter.gravatar}}">
</div>
<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}}
<span class="dim">in</span>
{{#each tags}}


+ 2
- 1
pinry/users/urls.py Dosyayı Görüntüle

@@ -3,8 +3,9 @@ from django.conf.urls import patterns, url
from .views import CreateUser

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',
{'template_name': 'users/login.html'}, name='login'),
url(r'^logout/$', 'pinry.users.views.logout_user', name='logout'),
url(r'^register/$', CreateUser.as_view(), name='register'),
)

+ 5
- 0
pinry/users/views.py Dosyayı Görüntüle

@@ -5,6 +5,7 @@ from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import Permission
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.template.response import TemplateResponse
from django.utils.functional import lazy
from django.views.generic import CreateView

@@ -42,3 +43,7 @@ def logout_user(request):
logout(request)
messages.success(request, 'You have successfully logged out.')
return HttpResponseRedirect(reverse('core:recent-pins'))


def private(request):
return TemplateResponse(request, 'users/private.html', None)

Yükleniyor…
İptal
Kaydet