Browse Source

Upgrade to Django 1.10.

master
Nick Sergeant 6 years ago
parent
commit
bd7f2bf027
  1. 2
      accounts/templates/activate.html
  2. 15
      accounts/urls.py
  3. 2
      blogs/templates/blogs/themes/pro-adams/base.html
  4. 4
      blogs/templates/blogs/themes/pro-adams/snipt-list.html
  5. 6
      blogs/urls.py
  6. 17
      blogs/views.py
  7. 19
      requirements.txt
  8. 34
      settings.py
  9. 6
      snipts/api.py
  10. 94
      snipts/urls.py
  11. 30
      snipts/views.py
  12. 28
      teams/urls.py
  13. 0
      templates/__init__.py
  14. 2
      templates/base.html
  15. 2
      templates/homepage.html
  16. 1
      templates/pagination/pagination.html
  17. 2
      templates/registration/login.html
  18. 1
      templates/robots.txt
  19. 29
      templates/sitemap.xml
  20. 106
      urls.py
  21. 14
      views.py

2
accounts/templates/activate.html

@ -1,3 +1,5 @@
{% load static %}
{% extends "base.html" %}
{% block page-title %}Activate account{% endblock %}

15
accounts/urls.py

@ -1,9 +1,10 @@
from accounts import views
from django.conf.urls import *
from django.conf.urls import url
urlpatterns = \
patterns('',
url(r'^activate/$', views.activate,
name='account-activate'),
url(r'^stats/$', views.stats, name='account-stats'),
url(r'^', views.account, name='account-detail'))
urlpatterns = [
url(r'^activate/$', views.activate,
name='account-activate'),
url(r'^stats/$', views.stats, name='account-stats'),
url(r'^', views.account, name='account-detail')
]

2
blogs/templates/blogs/themes/pro-adams/base.html

@ -1,4 +1,4 @@
{% load snipt_tags %}
{% load snipt_tags static %}
<!DOCTYPE html>
<html lang="en" class="{% block html-class %}{% endblock %}">

4
blogs/templates/blogs/themes/pro-adams/snipt-list.html

@ -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">

6
blogs/urls.py

@ -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')]

17
blogs/views.py

@ -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),
content_type="application/rss+xml")
return render(request, 'blogs/themes/default/rss.xml', context,
content_type="application/rss+xml")

19
requirements.txt

@ -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

@ -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 *

6
snipts/api.py

@ -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 = {}

94
snipts/urls.py

@ -1,50 +1,50 @@
from django.conf.urls import *
from django.conf.urls import url
from snipts import views
urlpatterns = \
patterns('',
url(r'^s/(?P<snipt_key>[^/]+)/(?P<lexer>[^\?]+)?$',
views.redirect_snipt, name='redirect-snipt'),
url(r'^(?P<username>[^/]+)/feed/$',
views.redirect_user_feed,
name='redirect-feed'),
url(r'^public/tag/(?P<tag_slug>[^/]+)/feed/$',
views.redirect_public_tag_feed,
name='redirect-public-tag-feed'),
url(r'^(?P<username>[^/]+)/tag/(?P<tag_slug>[^/]+)/feed/$',
views.redirect_user_tag_feed,
name='redirect-user-tag-feed'),
url(r'^public/$',
views.list_public,
name='list-public'),
url(r'^public/tag/(?P<tag_slug>[^/]+)/$',
views.list_public,
name='list-public-tag'),
url(r'^download/(?P<snipt_key>[^/]+).*$',
views.download,
name='download'),
url(r'^embed/(?P<snipt_key>[^/]+)/$',
views.embed,
name='embed'),
url(r'^raw/(?P<snipt_key>[^/]+)/(?P<lexer>[^\?]+)?$',
views.raw,
name='raw'),
url(r'^report-spam/(?P<snipt_id>[^/]+)/$',
views.report_spam,
name='report-spam'),
url(r'^(?P<username_or_custom_slug>[^/]+)/$',
views.list_user,
name='list-user'),
url(r'^(?P<username_or_custom_slug>[^/]+)/tag/(?P<tag_slug>[^/]+)/$',
views.list_user,
name='list-user-tag'),
url(r'^(?P<username>[^/]+)/favorites/$',
views.favorites,
name='favorites'),
url(r'^(?P<username>[^/]+)/blog-posts/$',
views.blog_posts,
name='blog-posts'),
url(r'^(?P<username>[^/]+)/(?P<snipt_slug>[^/]+)/$',
views.detail,
name='detail'))
urlpatterns = [
url(r'^s/(?P<snipt_key>[^/]+)/(?P<lexer>[^\?]+)?$',
views.redirect_snipt, name='redirect-snipt'),
url(r'^(?P<username>[^/]+)/feed/$',
views.redirect_user_feed,
name='redirect-feed'),
url(r'^public/tag/(?P<tag_slug>[^/]+)/feed/$',
views.redirect_public_tag_feed,
name='redirect-public-tag-feed'),
url(r'^(?P<username>[^/]+)/tag/(?P<tag_slug>[^/]+)/feed/$',
views.redirect_user_tag_feed,
name='redirect-user-tag-feed'),
url(r'^public/$',
views.list_public,
name='list-public'),
url(r'^public/tag/(?P<tag_slug>[^/]+)/$',
views.list_public,
name='list-public-tag'),
url(r'^download/(?P<snipt_key>[^/]+).*$',
views.download,
name='download'),
url(r'^embed/(?P<snipt_key>[^/]+)/$',
views.embed,
name='embed'),
url(r'^raw/(?P<snipt_key>[^/]+)/(?P<lexer>[^\?]+)?$',
views.raw,
name='raw'),
url(r'^report-spam/(?P<snipt_id>[^/]+)/$',
views.report_spam,
name='report-spam'),
url(r'^(?P<username_or_custom_slug>[^/]+)/$',
views.list_user,
name='list-user'),
url(r'^(?P<username_or_custom_slug>[^/]+)/tag/(?P<tag_slug>[^/]+)/$',
views.list_user,
name='list-user-tag'),
url(r'^(?P<username>[^/]+)/favorites/$',
views.favorites,
name='favorites'),
url(r'^(?P<username>[^/]+)/blog-posts/$',
views.blog_posts,
name='blog-posts'),
url(r'^(?P<username>[^/]+)/(?P<snipt_slug>[^/]+)/$',
views.detail,
name='detail')
]

30
snipts/views.py

@ -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,10 +80,10 @@ 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',
{'lines': lines, 'snipt': snipt},
context_instance=RequestContext(request),
content_type='application/javascript')
return render(request,
'snipts/embed.html',
{'lines': lines, 'snipt': snipt},
content_type='application/javascript')
def report_spam(request, snipt_id):
@ -297,17 +297,17 @@ def raw(request, snipt_key, lexer=None):
if 'nice' in request.GET:
content_type = 'text/html'
return render_to_response('snipts/raw.html',
{'snipt': snipt},
context_instance=RequestContext(request),
content_type=content_type)
return render(request,
'snipts/raw.html',
{'snipt': snipt},
content_type=content_type)
def rss(request, context):
return render_to_response('rss.xml',
context,
context_instance=RequestContext(request),
content_type="application/rss+xml")
return render(request,
'rss.xml',
context,
content_type="application/rss+xml")
@never_cache
@ -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):

28
teams/urls.py

@ -1,17 +1,17 @@
from django.conf.urls import *
from django.conf.urls import url
from teams import views
urlpatterns = \
patterns('',
url(r'^for-teams/$', views.for_teams),
url(r'^for-teams/complete/$', views.for_teams_complete),
url(r'^(?P<username>[^/]+)/members/remove/(?P<member>[^/]+)/$',
views.remove_team_member,
name='remove-team-member'),
url(r'^(?P<username>[^/]+)/members/add/(?P<member>[^/]+)/$',
views.add_team_member,
name='add-team-member'),
url(r'^(?P<username>[^/]+)/members/$',
views.team_members,
name='team-members'))
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>[^/]+)/$',
views.remove_team_member,
name='remove-team-member'),
url(r'^(?P<username>[^/]+)/members/add/(?P<member>[^/]+)/$',
views.add_team_member,
name='add-team-member'),
url(r'^(?P<username>[^/]+)/members/$',
views.team_members,
name='team-members')
]

0
templates/__init__.py

2
templates/base.html

@ -1,4 +1,4 @@
{% load snipt_tags %}
{% load snipt_tags static %}
<!DOCTYPE html>
<html lang="en" class="{% block html-class %}{% endblock %}" ng-app="Snipt">

2
templates/homepage.html

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% load humanize %}
{% load humanize static %}
{% block sub-header %}{% endblock %}
{% block keyboard-shortcuts %}{% endblock %}

1
templates/pagination/pagination.html

@ -1,5 +1,4 @@
{% if is_paginated %}
{% load i18n %}
<div class="pagination">
<ul>
{% if page_obj.has_previous %}

2
templates/registration/login.html

@ -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
templates/robots.txt

@ -1,4 +1,3 @@
User-agent: *
Disallow:
Disallow: /admin
Sitemap: https://snipt.net/sitemap.xml

29
templates/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>

106
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,56 +28,50 @@ private_api.register(PrivateUserResource())
private_api.register(PrivateFavoriteResource())
private_api.register(PrivateUserProfileResource())
urlpatterns = \
patterns('',
url(r'^$', homepage),
url(r'^login-redirect/$', login_redirect),
url(r'^admin/', include(admin.site.urls)),
url(r'^404/$', TemplateView.as_view(template_name='404.html')),
url(r'^500/$', TemplateView.as_view(template_name='500.html')),
url(r'^robots.txt$',
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')),
url(r'^api/public/lexer/$', lexers),
url(r'^api/private/key/$', user_api_key),
url(r'^api/', include(public_api.urls)),
url(r'^api/', include(private_api.urls)),
url(r'^search/$', search),
url(r'^register/$', lambda x: HttpResponseRedirect('/signup/')),
url(r'^signup/$', SniptRegistrationView.as_view(),
name='registration_register'),
url(r'^activate/complete/$', RedirectView.as_view(
url='/login-redirect/')),
url(r'^login/?$', 'django.contrib.auth.views.login', {
'authentication_form': AuthenticationFormWithInactiveUsersOkay
}),
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', {
'document_root': os.path.join(os.path.dirname(__file__),
'static/img')
}),
)
urlpatterns += \
patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': os.path.join(os.path.dirname(__file__),
'media')
}))
urlpatterns = [
url(r'^$', homepage),
url(r'^login-redirect/$', login_redirect),
url(r'^admin/', include(admin.site.urls)),
url(r'^404/$', TemplateView.as_view(template_name='404.html')),
url(r'^500/$', TemplateView.as_view(template_name='500.html')),
url(r'^robots.txt$',
TemplateView.as_view(template_name='robots.txt')),
url(r'^humans.txt$',
TemplateView.as_view(template_name='humans.txt')),
url(r'^tags/$', tags),
url(r'^account/', include('accounts.urls')),
url(r'^api/public/lexer/$', lexers),
url(r'^api/private/key/$', user_api_key),
url(r'^api/', include(public_api.urls)),
url(r'^api/', include(private_api.urls)),
url(r'^search/$', search),
url(r'^register/$', lambda x: HttpResponseRedirect('/signup/')),
url(r'^signup/$', SniptRegistrationView.as_view(),
name='registration_register'),
url(r'^activate/complete/$', RedirectView.as_view(
url='/login-redirect/')),
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)$', serve, {
'document_root': os.path.join(os.path.dirname(__file__),
'static/img')
}),
url(r'^static/(?P<path>.*)$', serve, {
'document_root': os.path.join(os.path.dirname(__file__),
'media')
})
]

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…
Cancel
Save