Upgrade to Django 1.10.
parent
9828c47783
commit
bd7f2bf027
|
@ -1,3 +1,5 @@
|
|||
{% load static %}
|
||||
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block page-title %}Activate account{% endblock %}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from accounts import views
|
||||
from django.conf.urls import *
|
||||
from django.conf.urls import url
|
||||
|
||||
urlpatterns = \
|
||||
patterns('',
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^activate/$', views.activate,
|
||||
name='account-activate'),
|
||||
url(r'^stats/$', views.stats, name='account-stats'),
|
||||
url(r'^', views.account, name='account-detail'))
|
||||
url(r'^', views.account, name='account-detail')
|
||||
]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load snipt_tags %}
|
||||
{% load snipt_tags static %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="{% block html-class %}{% endblock %}">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load snipt_tags typogrify_tags %}
|
||||
{% load snipt_tags %}
|
||||
|
||||
<article class="group {% if detail %}detail{% endif %}">
|
||||
{% if snipt.title != 'Work' %}
|
||||
|
@ -17,7 +17,7 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<div class="content-inner">
|
||||
<h1><a href="{{ snipt.get_full_absolute_url }}">{% firstof snipt.title|typogrify 'Untitled' %}</a></h1>
|
||||
<h1><a href="{{ snipt.get_full_absolute_url }}">{% firstof snipt.title 'Untitled' %}</a></h1>
|
||||
<div class="post-content autumn">
|
||||
{% if snipt.lexer == 'markdown' %}
|
||||
<div class="markdown">
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from django.conf.urls import *
|
||||
from blogs import views
|
||||
from django.conf.urls import url
|
||||
|
||||
urlpatterns = patterns('', url(r'^$', views.blog, name='blog'))
|
||||
|
||||
urlpatterns = [url(r'^$', views.blog, name='blog')]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import datetime
|
||||
|
||||
from annoying.functions import get_object_or_None
|
||||
from django.shortcuts import get_object_or_404, render_to_response
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.template import RequestContext
|
||||
from snipts.models import Snipt
|
||||
|
||||
|
@ -58,10 +58,11 @@ def blog_list(request, username_or_custom_slug=None):
|
|||
|
||||
template = '{}/list.html'.format(template)
|
||||
|
||||
return render_to_response(
|
||||
return render(
|
||||
request,
|
||||
template,
|
||||
context,
|
||||
context_instance=RequestContext(request))
|
||||
)
|
||||
|
||||
|
||||
def blog_post(request, username_or_custom_slug):
|
||||
|
@ -115,13 +116,9 @@ def blog_post(request, username_or_custom_slug):
|
|||
|
||||
template = '{}/post.html'.format(template)
|
||||
|
||||
return render_to_response(template,
|
||||
context,
|
||||
context_instance=RequestContext(request))
|
||||
return render(request, template, context)
|
||||
|
||||
|
||||
def rss(request, context):
|
||||
return render_to_response('blogs/themes/default/rss.xml',
|
||||
context,
|
||||
context_instance=RequestContext(request),
|
||||
return render(request, 'blogs/themes/default/rss.xml', context,
|
||||
content_type="application/rss+xml")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Django==1.8.14
|
||||
Django==1.10.3
|
||||
Fabric==1.10.2
|
||||
PyYAML==3.11
|
||||
Pygments==2.0.2
|
||||
|
@ -6,21 +6,21 @@ biplist==0.9
|
|||
defusedxml==0.4.1
|
||||
dj-database-url==0.3.0
|
||||
dj-static==0.0.6
|
||||
django-annoying==0.8.3
|
||||
django-annoying==0.10.3
|
||||
django-bcrypt==0.9.2
|
||||
django-debug-toolbar==1.3.2
|
||||
django-extensions==1.5.7
|
||||
django-extensions==1.7.4
|
||||
django-haystack==2.4.0
|
||||
django-markdown-deux==1.0.5
|
||||
django-pagination-py3==1.1.0
|
||||
django-registration-redux==1.2
|
||||
django-pagination-py3==1.1.2
|
||||
django-registration-redux==1.4
|
||||
django-storages==1.1.8
|
||||
django-taggit==0.16.2
|
||||
django-tastypie==0.12.2
|
||||
django-templatetag-sugar==1.0
|
||||
django-taggit==0.21.3
|
||||
django-tastypie==0.13.3
|
||||
-e git+ssh://git@github.com/nicksergeant/django-templatetag-sugar.git#egg=django-templatetag-sugar
|
||||
ecdsa==0.13
|
||||
elasticsearch==1.6.0
|
||||
gunicorn==19.3.0
|
||||
gunicorn==19.6.0
|
||||
lxml==3.4.4
|
||||
markdown2==2.3.0
|
||||
paramiko==1.15.2
|
||||
|
@ -37,5 +37,4 @@ six==1.9.0
|
|||
smartypants==1.8.6
|
||||
sqlparse==0.1.15
|
||||
stripe==1.23.0
|
||||
typogrify==2.0.7
|
||||
urllib3==1.11
|
||||
|
|
34
settings.py
34
settings.py
|
@ -79,8 +79,24 @@ STATIC_URL = '/static/'
|
|||
TASTYPIE_CANNED_ERROR = """There was an error with your request. The site
|
||||
developers have a record of this error, please email api@snipt.net and
|
||||
we'll help you out."""
|
||||
TEMPLATE_DIRS = (os.path.join(PROJECT_PATH, 'templates'),)
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [os.path.join(PROJECT_PATH, 'templates')],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.template.context_processors.static',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
TIME_ZONE = 'America/New_York'
|
||||
USE_HTTPS = True if 'USE_SSL' in os.environ else False
|
||||
USE_I18N = True
|
||||
|
@ -111,7 +127,6 @@ INSTALLED_APPS = (
|
|||
'taggit',
|
||||
'tastypie',
|
||||
'teams',
|
||||
'typogrify',
|
||||
'user-admin',
|
||||
'utils',
|
||||
)
|
||||
|
@ -136,19 +151,6 @@ MIDDLEWARE_CLASSES = (
|
|||
'pagination.middleware.PaginationMiddleware',
|
||||
'blogs.middleware.BlogMiddleware',
|
||||
)
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.core.context_processors.debug',
|
||||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.request',
|
||||
'django.core.context_processors.static',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
)
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
)
|
||||
|
||||
try:
|
||||
from settings_local import *
|
||||
|
|
|
@ -205,7 +205,7 @@ class PublicTagResource(ModelResource):
|
|||
max_limit = 200
|
||||
cache = SimpleCache()
|
||||
|
||||
def build_filters(self, filters=None):
|
||||
def build_filters(self, filters=None, **kwargs):
|
||||
if filters is None:
|
||||
filters = {}
|
||||
|
||||
|
@ -268,7 +268,7 @@ class PublicSniptResource(ModelResource):
|
|||
|
||||
return bundle
|
||||
|
||||
def build_filters(self, filters=None):
|
||||
def build_filters(self, filters=None, **kwargs):
|
||||
if filters is None:
|
||||
filters = {}
|
||||
|
||||
|
@ -478,7 +478,7 @@ class PrivateSniptResource(ModelResource):
|
|||
|
||||
return bundle
|
||||
|
||||
def build_filters(self, filters=None):
|
||||
def build_filters(self, filters=None, **kwargs):
|
||||
if filters is None:
|
||||
filters = {}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from django.conf.urls import *
|
||||
from django.conf.urls import url
|
||||
from snipts import views
|
||||
|
||||
|
||||
urlpatterns = \
|
||||
patterns('',
|
||||
urlpatterns = [
|
||||
url(r'^s/(?P<snipt_key>[^/]+)/(?P<lexer>[^\?]+)?$',
|
||||
views.redirect_snipt, name='redirect-snipt'),
|
||||
url(r'^(?P<username>[^/]+)/feed/$',
|
||||
|
@ -47,4 +46,5 @@ urlpatterns = \
|
|||
name='blog-posts'),
|
||||
url(r'^(?P<username>[^/]+)/(?P<snipt_slug>[^/]+)/$',
|
||||
views.detail,
|
||||
name='detail'))
|
||||
name='detail')
|
||||
]
|
||||
|
|
|
@ -8,7 +8,7 @@ from django.core.paginator import Paginator, InvalidPage
|
|||
from django.db.models import Count
|
||||
from django.db.models import Q
|
||||
from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseBadRequest
|
||||
from django.shortcuts import get_object_or_404, render_to_response
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.template import RequestContext
|
||||
from django.views.decorators.cache import never_cache
|
||||
from haystack.forms import ModelSearchForm
|
||||
|
@ -80,9 +80,9 @@ def embed(request, snipt_key):
|
|||
snipt = get_object_or_404(Snipt, key=snipt_key)
|
||||
|
||||
lines = snipt.embedded.split('\n')
|
||||
return render_to_response('snipts/embed.html',
|
||||
return render(request,
|
||||
'snipts/embed.html',
|
||||
{'lines': lines, 'snipt': snipt},
|
||||
context_instance=RequestContext(request),
|
||||
content_type='application/javascript')
|
||||
|
||||
|
||||
|
@ -297,16 +297,16 @@ def raw(request, snipt_key, lexer=None):
|
|||
if 'nice' in request.GET:
|
||||
content_type = 'text/html'
|
||||
|
||||
return render_to_response('snipts/raw.html',
|
||||
return render(request,
|
||||
'snipts/raw.html',
|
||||
{'snipt': snipt},
|
||||
context_instance=RequestContext(request),
|
||||
content_type=content_type)
|
||||
|
||||
|
||||
def rss(request, context):
|
||||
return render_to_response('rss.xml',
|
||||
return render(request,
|
||||
'rss.xml',
|
||||
context,
|
||||
context_instance=RequestContext(request),
|
||||
content_type="application/rss+xml")
|
||||
|
||||
|
||||
|
@ -379,9 +379,7 @@ def search(request, template='search/search.html', load_all=True,
|
|||
if extra_context:
|
||||
context.update(extra_context)
|
||||
|
||||
return render_to_response(template,
|
||||
context,
|
||||
context_instance=context_class(request))
|
||||
return render(request, template, context)
|
||||
|
||||
|
||||
def redirect_snipt(request, snipt_key, lexer=None):
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from django.conf.urls import *
|
||||
from django.conf.urls import url
|
||||
from teams import views
|
||||
|
||||
|
||||
urlpatterns = \
|
||||
patterns('',
|
||||
urlpatterns = [
|
||||
url(r'^for-teams/$', views.for_teams),
|
||||
url(r'^for-teams/complete/$', views.for_teams_complete),
|
||||
url(r'^(?P<username>[^/]+)/members/remove/(?P<member>[^/]+)/$',
|
||||
|
@ -14,4 +13,5 @@ urlpatterns = \
|
|||
name='add-team-member'),
|
||||
url(r'^(?P<username>[^/]+)/members/$',
|
||||
views.team_members,
|
||||
name='team-members'))
|
||||
name='team-members')
|
||||
]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% load snipt_tags %}
|
||||
{% load snipt_tags static %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="{% block html-class %}{% endblock %}" ng-app="Snipt">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load humanize %}
|
||||
{% load humanize static %}
|
||||
|
||||
{% block sub-header %}{% endblock %}
|
||||
{% block keyboard-shortcuts %}{% endblock %}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{% if is_paginated %}
|
||||
{% load i18n %}
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
{% if page_obj.has_previous %}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{% block body-class %}{{ block.super }} static login{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<form class="form-horizontal static-box" method="post" action="{% url 'django.contrib.auth.views.login' %}">
|
||||
<form class="form-horizontal static-box" method="post" action="{% url 'login' %}">
|
||||
{% if request.GET.activationcomplete %}
|
||||
<div class="alert alert-success">
|
||||
Successfully confirmed email! Log in below.
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
User-agent: *
|
||||
Disallow:
|
||||
Disallow: /admin
|
||||
Sitemap: https://snipt.net/sitemap.xml
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://snipt.net/api/</loc>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://snipt.net/todo/</loc>
|
||||
<changefreq>daily</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://snipt.net/public/</loc>
|
||||
<changefreq>always</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://blog.snipt.net/</loc>
|
||||
<changefreq>weekly</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
{% for tag in tags %}
|
||||
<url>
|
||||
<loc>https://snipt.net/public/tag/{{ tag.slug }}</loc>
|
||||
<priority>0.9</priority>
|
||||
</url>
|
||||
{% endfor %}
|
||||
</urlset>
|
26
urls.py
26
urls.py
|
@ -1,9 +1,11 @@
|
|||
import os
|
||||
|
||||
from django.conf.urls import include, patterns, url
|
||||
from django.conf.urls import include, url
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.views import login
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.views.generic import RedirectView, TemplateView
|
||||
from django.views.static import serve
|
||||
from forms import AuthenticationFormWithInactiveUsersOkay
|
||||
from snipts.api import (PublicSniptResource,
|
||||
PublicUserResource, PrivateSniptResource,
|
||||
|
@ -12,7 +14,7 @@ from snipts.api import (PublicSniptResource,
|
|||
from snipts.views import search
|
||||
from tastypie.api import Api
|
||||
from utils.views import SniptRegistrationView
|
||||
from views import (homepage, lexers, login_redirect, sitemap,
|
||||
from views import (homepage, lexers, login_redirect,
|
||||
tags, user_api_key)
|
||||
|
||||
public_api = Api(api_name='public')
|
||||
|
@ -26,9 +28,7 @@ private_api.register(PrivateUserResource())
|
|||
private_api.register(PrivateFavoriteResource())
|
||||
private_api.register(PrivateUserProfileResource())
|
||||
|
||||
urlpatterns = \
|
||||
patterns('',
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', homepage),
|
||||
url(r'^login-redirect/$', login_redirect),
|
||||
|
||||
|
@ -41,7 +41,6 @@ urlpatterns = \
|
|||
TemplateView.as_view(template_name='robots.txt')),
|
||||
url(r'^humans.txt$',
|
||||
TemplateView.as_view(template_name='humans.txt')),
|
||||
url(r'^sitemap.xml$', sitemap),
|
||||
url(r'^tags/$', tags),
|
||||
|
||||
url(r'^account/', include('accounts.urls')),
|
||||
|
@ -59,23 +58,20 @@ urlpatterns = \
|
|||
name='registration_register'),
|
||||
url(r'^activate/complete/$', RedirectView.as_view(
|
||||
url='/login-redirect/')),
|
||||
url(r'^login/?$', 'django.contrib.auth.views.login', {
|
||||
url(r'^login/?$', login, {
|
||||
'authentication_form': AuthenticationFormWithInactiveUsersOkay
|
||||
}),
|
||||
}, name='login'),
|
||||
url(r'', include('registration.backends.default.urls')),
|
||||
|
||||
url(r'^', include('teams.urls')),
|
||||
url(r'^', include('snipts.urls')),
|
||||
|
||||
url(r'^(?P<path>favicon\.ico)$', 'django.views.static.serve', {
|
||||
url(r'^(?P<path>favicon\.ico)$', serve, {
|
||||
'document_root': os.path.join(os.path.dirname(__file__),
|
||||
'static/img')
|
||||
}),
|
||||
)
|
||||
|
||||
urlpatterns += \
|
||||
patterns('',
|
||||
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
|
||||
url(r'^static/(?P<path>.*)$', serve, {
|
||||
'document_root': os.path.join(os.path.dirname(__file__),
|
||||
'media')
|
||||
}))
|
||||
})
|
||||
]
|
||||
|
|
14
views.py
14
views.py
|
@ -6,7 +6,7 @@ from blogs.views import blog_list
|
|||
from django.contrib.auth.models import User
|
||||
from django.db.models import Count
|
||||
from django.http import HttpResponseRedirect, HttpResponseBadRequest
|
||||
from django.shortcuts import render_to_response
|
||||
from django.shortcuts import render
|
||||
from django.template import RequestContext
|
||||
from snipts.models import Snipt
|
||||
from snipts.utils import get_lexers_list
|
||||
|
@ -78,18 +78,6 @@ def login_redirect(request):
|
|||
return HttpResponseRedirect('/')
|
||||
|
||||
|
||||
def sitemap(request):
|
||||
|
||||
tags = Tag.objects.filter(snipt__public=True)
|
||||
tags = tags.annotate(count=Count('taggit_taggeditem_items__id'))
|
||||
tags = tags.order_by('-count')[:1000]
|
||||
|
||||
return render_to_response('sitemap.xml',
|
||||
{'tags': tags},
|
||||
context_instance=RequestContext(request),
|
||||
content_type='application/xml')
|
||||
|
||||
|
||||
@render_to('tags.html')
|
||||
def tags(request):
|
||||
|
||||
|
|
Loading…
Reference in New Issue