mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Upgrading django from 1.3 to 1.5.
This commit is contained in:
parent
cd9b9929b4
commit
90c2425db0
15 changed files with 60 additions and 49 deletions
|
@ -7,7 +7,7 @@ import re
|
|||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.hashcompat import sha_constructor
|
||||
import hashlib
|
||||
|
||||
from apps.push import signals
|
||||
from apps.rss_feeds.models import Feed
|
||||
|
@ -120,7 +120,7 @@ class PushSubscription(models.Model):
|
|||
def generate_token(self, mode):
|
||||
assert self.pk is not None, \
|
||||
'Subscription must be saved before generating token'
|
||||
token = mode[:20] + sha_constructor('%s%i%s' % (
|
||||
token = mode[:20] + haslib.sha1('%s%i%s' % (
|
||||
settings.SECRET_KEY, self.pk, mode)).hexdigest()
|
||||
self.verify_token = token
|
||||
self.save()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fabric
|
||||
django==1.3.1
|
||||
django==1.5
|
||||
readline
|
||||
chardet
|
||||
pyflakes
|
||||
|
|
34
fabfile.py
vendored
34
fabfile.py
vendored
|
@ -74,7 +74,12 @@ env.roledefs ={
|
|||
'db10.newsblur.com',
|
||||
'db11.newsblur.com',
|
||||
'db12.newsblur.com',
|
||||
'db20.newsblur.com',
|
||||
'db21.newsblur.com',
|
||||
],
|
||||
'dbdo':['198.211.115.113',
|
||||
'198.211.115.153',
|
||||
],
|
||||
'task': ['task01.newsblur.com',
|
||||
'task02.newsblur.com',
|
||||
'task03.newsblur.com',
|
||||
|
@ -342,6 +347,7 @@ def setup_common():
|
|||
setup_installs()
|
||||
setup_user()
|
||||
setup_sudoers()
|
||||
setup_ulimit()
|
||||
setup_repo()
|
||||
setup_repo_local_settings()
|
||||
setup_local_files()
|
||||
|
@ -435,7 +441,7 @@ def setup_installs():
|
|||
sudo('chsh %s -s /bin/zsh' % env.user)
|
||||
with settings(warn_only=True):
|
||||
sudo('mkdir -p %s' % env.VENDOR_PATH)
|
||||
sudo('chown %s.%s %s' % (env.user, env.user, env.VENDOR_PATH))
|
||||
sudo('chown %s.%s %s' % (env.user, env.user, env.VENDOR_PATH))
|
||||
|
||||
def setup_user():
|
||||
# run('useradd -c "NewsBlur" -m newsblur -s /bin/zsh')
|
||||
|
@ -457,8 +463,8 @@ def setup_repo():
|
|||
with settings(warn_only=True):
|
||||
run('git clone https://github.com/samuelclay/NewsBlur.git ~/newsblur')
|
||||
sudo('mkdir -p /srv')
|
||||
with settings(warn_only=True):
|
||||
sudo('ln -f -s /home/%s/code /srv/' % env.user)
|
||||
# with settings(warn_only=True):
|
||||
# sudo('ln -f -s /home/%s/code /srv/' % env.user)
|
||||
sudo('ln -f -s /home/%s/newsblur /srv/' % env.user)
|
||||
|
||||
def setup_repo_local_settings():
|
||||
|
@ -596,15 +602,15 @@ def setup_logrotate():
|
|||
|
||||
def setup_ulimit():
|
||||
# Increase File Descriptor limits.
|
||||
run('export FILEMAX=`sysctl -n fs.file-max`')
|
||||
sudo('mv /etc/security/limits.conf /etc/security/limits.conf.bak')
|
||||
sudo('touch /etc/security/limits.conf')
|
||||
sudo('chmod 666 /etc/security/limits.conf')
|
||||
run('echo "root soft nofile $FILEMAX" >> /etc/security/limits.conf')
|
||||
run('"root hard nofile $FILEMAX" >> /etc/security/limits.conf')
|
||||
run('echo "* soft nofile $FILEMAX" >> /etc/security/limits.conf')
|
||||
run('echo "* hard nofile $FILEMAX" >> /etc/security/limits.conf')
|
||||
sudo('chmod 644 /etc/security/limits.conf')
|
||||
run('export FILEMAX=`sysctl -n fs.file-max`', pty=False)
|
||||
sudo('mv /etc/security/limits.conf /etc/security/limits.conf.bak', pty=False)
|
||||
sudo('touch /etc/security/limits.conf', pty=False)
|
||||
sudo('chmod 666 /etc/security/limits.conf', pty=False)
|
||||
run('echo "root soft nofile $FILEMAX" >> /etc/security/limits.conf', pty=False)
|
||||
run('echo "root hard nofile $FILEMAX" >> /etc/security/limits.conf', pty=False)
|
||||
run('echo "* soft nofile $FILEMAX" >> /etc/security/limits.conf', pty=False)
|
||||
run('echo "* hard nofile $FILEMAX" >> /etc/security/limits.conf', pty=False)
|
||||
sudo('chmod 644 /etc/security/limits.conf', pty=False)
|
||||
|
||||
# run('touch /home/ubuntu/.bash_profile')
|
||||
# run('echo "ulimit -n $FILEMAX" >> /home/ubuntu/.bash_profile')
|
||||
|
@ -780,7 +786,7 @@ def setup_db_firewall():
|
|||
sudo('ufw allow proto tcp from 199.15.248.0/21 to any port %s ' % ','.join(map(str, ports)))
|
||||
|
||||
# DigitalOcean
|
||||
for ip in set(env.roledefs['app']):
|
||||
for ip in set(env.roledefs['app'] + env.roledefs['dbdo']):
|
||||
if 'newsblur.com' in ip: continue
|
||||
sudo('ufw allow proto tcp from %s to any port %s' % (
|
||||
ip,
|
||||
|
@ -844,7 +850,7 @@ def setup_mongo():
|
|||
# sudo('echo "deb http://downloads.mongodb.org/distros/ubuntu 10.10 10gen" >> /etc/apt/sources.list.d/10gen.list')
|
||||
sudo('echo "deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen" >> /etc/apt/sources.list')
|
||||
sudo('apt-get update')
|
||||
sudo('apt-get -y install mongodb-10gen numactl')
|
||||
sudo('apt-get -y install mongodb-10gen')
|
||||
put('config/mongodb.%s.conf' % ('prod' if env.user != 'ubuntu' else 'ec2'),
|
||||
'/etc/mongodb.conf', use_sudo=True)
|
||||
sudo('/etc/init.d/mongodb restart')
|
||||
|
|
|
@ -144,6 +144,7 @@ LOGGING = {
|
|||
'mail_admins': {
|
||||
'level': 'ERROR',
|
||||
'class': 'django.utils.log.AdminEmailHandler',
|
||||
'filters': ['require_debug_false'],
|
||||
'include_html': True,
|
||||
}
|
||||
},
|
||||
|
@ -168,7 +169,12 @@ LOGGING = {
|
|||
'level': 'INFO',
|
||||
'propagate': True,
|
||||
},
|
||||
}
|
||||
},
|
||||
'filters': {
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse'
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
# ==========================
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<h1><span class="error404">404</span> · NewsBlur can't find that page</h1>
|
||||
<div class="description">
|
||||
<p>Either the URL you accessed doesn't point to anything or there is no site, story, or data with these parameters.</p>
|
||||
<p><a href="{% url index %}">Return to NewsBlur</a></p>
|
||||
<p><a href="{% url "index" %}">Return to NewsBlur</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<h1>NewsBlur experienced an error</h1>
|
||||
<div class="description">
|
||||
<p>The error has been logged and will be fixed soon so you won't have to see this message again.</p>
|
||||
<p><a href="{% url index %}">Return to NewsBlur</a></p>
|
||||
<p><a href="{% url "index" %}">Return to NewsBlur</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
@ -215,7 +215,7 @@
|
|||
var self = this;
|
||||
var $submit = $('.NB-bookmarklet-button-subscribe', this.$modal);
|
||||
var folder = $('.NB-folders').val();
|
||||
var add_site_url = "http://"+this.domain+"{% url api-add-site token %}?callback=?";
|
||||
var add_site_url = "http://"+this.domain+"{% url "api-add-site" token %}?callback=?";
|
||||
|
||||
$submit.addClass('NB-disabled').text('Fetching and parsing...');
|
||||
|
||||
|
@ -272,7 +272,7 @@
|
|||
var $comments = $('textarea[name=newsblur_comment]', this.$modal);
|
||||
var $content_wrapper = $('.NB-bookmarklet-page-content-wrapper', this.$modal);
|
||||
var $content = $('.NB-bookmarklet-page-content', this.$modal);
|
||||
var check_story_url = "http://"+this.domain+"{% url api-check-share-on-site token %}?callback=?";
|
||||
var check_story_url = "http://"+this.domain+"{% url "api-check-share-on-site" token %}?callback=?";
|
||||
var data = {
|
||||
story_url: window.location.href,
|
||||
rss_url: this.get_page_rss_url()
|
||||
|
@ -416,7 +416,7 @@
|
|||
|
||||
|
||||
$.ajax({
|
||||
url: '//'+this.domain+"{% url api-share-story token %}",
|
||||
url: '//'+this.domain+"{% url "api-share-story" token %}",
|
||||
type: 'POST',
|
||||
data: {
|
||||
title: $(".NB-bookmarklet-page-title", this.$modal).html() || this.story_title,
|
||||
|
|
|
@ -72,13 +72,13 @@
|
|||
'story_share_email' : true
|
||||
};
|
||||
NEWSBLUR.URLs = {
|
||||
'google-reader-authorize' : "{% url google-reader-authorize %}",
|
||||
'upload-avatar' : "{% url upload-avatar %}",
|
||||
'opml-upload' : "{% url opml-upload %}",
|
||||
'opml-export' : "{% url opml-export %}",
|
||||
'google-reader-authorize' : "{% url "google-reader-authorize" %}",
|
||||
'upload-avatar' : "{% url "upload-avatar" %}",
|
||||
'opml-upload' : "{% url "opml-upload" %}",
|
||||
'opml-export' : "{% url "opml-export" %}",
|
||||
'domain' : "{% current_domain %}",
|
||||
'favicon' : "/rss_feeds/icon/{id}",
|
||||
'delete-account' : "{% url profile-delete-account %}"
|
||||
'delete-account' : "{% url "profile-delete-account" %}"
|
||||
};
|
||||
NEWSBLUR.Models = {};
|
||||
NEWSBLUR.Collections = {};
|
||||
|
@ -112,18 +112,18 @@
|
|||
|
||||
<div class="NB-body-inner">
|
||||
<div class="NB-splash-info NB-splash-top">
|
||||
<a href="{% url index %}"><img class="NB-splash-title" src="{{ MEDIA_URL }}/img/logo_newsblur_blur.png" /></a>
|
||||
<a href="{% url "index" %}"><img class="NB-splash-title" src="{{ MEDIA_URL }}/img/logo_newsblur_blur.png" /></a>
|
||||
</div>
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
|
||||
<div class="NB-splash-info NB-splash-bottom">
|
||||
<ul class="NB-splash-links NB-inner">
|
||||
<li class="NB-splash-link NB-splash-link-logo"><a href="{% url index %}"><img src="{{ MEDIA_URL }}/img/logo_newsblur_blur.png" style="height: 32px; width: 183px;" /></a></li>
|
||||
<li class="NB-splash-link NB-splash-link-about"><a href="{% url about %}">About</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-faq"><a href="{% url faq %}">FAQ</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-api"><a href="{% url api %}">API</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-press"><a href="{% url press %}">Press</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-logo"><a href="{% url "index" %}"><img src="{{ MEDIA_URL }}/img/logo_newsblur_blur.png" style="height: 32px; width: 183px;" /></a></li>
|
||||
<li class="NB-splash-link NB-splash-link-about"><a href="{% url "about" %}">About</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-faq"><a href="{% url "faq" %}">FAQ</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-api"><a href="{% url "api" %}">API</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-press"><a href="{% url "press" %}">Press</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-github"><a href="http://github.com/samuelclay">GitHub</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-getsatisfaction"><a href="https://getsatisfaction.com/newsblur">Feedback</a></li>
|
||||
<li class="NB-splash-link NB-splash-link-blog"><a href="http://blog.newsblur.com">The Blog</a></li>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</h5>
|
||||
|
||||
<div class="NB-import-signup" style="margin-top: 24px;">
|
||||
<form method="post" action="{% url import-signup %}">
|
||||
<form method="post" action="{% url "import-signup" %}">
|
||||
<div>
|
||||
{{ signup_form.username.label_tag }}
|
||||
{{ signup_form.username }}
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
<div class="NB-module NB-module-account">
|
||||
<h5 class="NB-module-header">
|
||||
<div class="NB-module-header-right">
|
||||
<a href="{% url logout %}?next=/" class="NB-splash-link">Logout</a>
|
||||
<a href="{% url "logout" %}?next=/" class="NB-splash-link">Logout</a>
|
||||
</div>
|
||||
Welcome, <span class="NB-module-account-username">{{ user.username }}</span>
|
||||
</h5>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
{% endfor %}
|
||||
</table>
|
||||
{% if user.is_staff %}
|
||||
<form action="{% url add-feature %}" id="add-feature-form" method="post">
|
||||
<form action="{% url "add-feature" %}" id="add-feature-form" method="post">
|
||||
{{ feature_form.description }}
|
||||
<input type="submit" value="Add feature" />
|
||||
</form>
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
<div class="NB-module-header-signup">Sign up</div>
|
||||
</div>
|
||||
<div class="NB-login">
|
||||
<form method="post" action="{% url login %}">
|
||||
<form method="post" action="{% url "login" %}">
|
||||
<div>
|
||||
{{ login_form.username.label_tag }}
|
||||
{{ login_form.username }}
|
||||
|
@ -78,7 +78,7 @@
|
|||
<div>
|
||||
<div class="NB-signup-optional">
|
||||
{% if login_form.errors and login_form.errors|length %}
|
||||
<a href="{% url profile-forgot-password %}" class="NB-splash-link">Forgot?</a>
|
||||
<a href="{% url "profile-forgot-password" %}" class="NB-splash-link">Forgot?</a>
|
||||
{% else %}
|
||||
Optional
|
||||
{% endif %}
|
||||
|
@ -99,7 +99,7 @@
|
|||
</div>
|
||||
|
||||
<div class="NB-signup">
|
||||
<form method="post" action="{% url signup %}">
|
||||
<form method="post" action="{% url "signup" %}">
|
||||
<div>
|
||||
{{ signup_form.username.label_tag }}
|
||||
{{ signup_form.username }}
|
||||
|
@ -123,7 +123,7 @@
|
|||
{% endfor %}
|
||||
{% endif %}
|
||||
<div class="NB-signup-orline {% if signup_form.errors %}NB-signup-orline-reduced{% endif %}">— <span class="NB-signup-orline-or">or</span> —</div>
|
||||
<a href="{% url google-reader-authorize %}" class="NB-splash-link NB-signup-google">Import from<br /><img src="{{ MEDIA_URL }}img/welcome/Google_Reader_logo.png" width="16" height="16" style="vertical-align: bottom;"> Google Reader</a>
|
||||
<a href="{% url "google-reader-authorize" %}" class="NB-splash-link NB-signup-google">Import from<br /><img src="{{ MEDIA_URL }}img/welcome/Google_Reader_logo.png" width="16" height="16" style="vertical-align: bottom;"> Google Reader</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -237,7 +237,7 @@
|
|||
<a href="http://github.com/samuelclay" title="GitHub"><img src="{{ MEDIA_URL }}img/welcome/github_favicon.png"></a>
|
||||
<a href="http://twitter.com/newsblur" title="Twitter"><img src="{{ MEDIA_URL }}img/welcome/twitter_favicon.png"></a>
|
||||
</div>
|
||||
<a href="{% url index %}"><img src="{{ MEDIA_URL }}/img/logo_newsblur_blur.png" style="height: 32px; width: 183px;" class="NB-footer-logo" title="NewsBlur" alt="NewsBlur" /></a>
|
||||
<a href="{% url "index" %}"><img src="{{ MEDIA_URL }}/img/logo_newsblur_blur.png" style="height: 32px; width: 183px;" class="NB-footer-logo" title="NewsBlur" alt="NewsBlur" /></a>
|
||||
is built in New York City and San Francisco by
|
||||
<a href="http://twitter.com/samuelclay" class="NB-splash-link">
|
||||
<img src="http://a0.twimg.com/profile_images/1382021023/Campeche_Steps_reasonably_small.jpg" class="NB-twitter-avatar">
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<div class="NB-thanks">
|
||||
<div style="color: #175700;font-size: 24px"><b><em>Muted!</em></b></div>
|
||||
<div>You will no longer receive email notifications for this story.</div>
|
||||
<div><a href="{% url index %}">Continue to NewsBlur »</a></div>
|
||||
<div><a href="{% url "index" %}">Continue to NewsBlur »</a></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<head>
|
||||
<title>{{ social_profile.title }}</title>
|
||||
<link rel="alternate" type="application/rss+xml" href="{% url shared-stories-rss-feed social_profile.user_id social_profile.username|slugify %}" title="{{ social_profile.feed_title }} RSS feed">
|
||||
<link rel="alternate" type="application/rss+xml" href="{% url "shared-stories-rss-feed" social_profile.user_id social_profile.username|slugify %}" title="{{ social_profile.feed_title }} RSS feed">
|
||||
<link rel="shortcut icon" href="{{ social_profile.photo_url }}">
|
||||
<link rel="icon" href="{{ social_profile.photo_url }}">
|
||||
<meta name="viewport" content="initial-scale=1, maximum-scale=1.5">
|
||||
|
@ -148,7 +148,7 @@
|
|||
|
||||
</h1>
|
||||
<div class="NB-header-feed">
|
||||
{# <a type="application/rss+xml" href="{% url shared-stories-rss-feed social_profile.user_id social_profile.username|slugify %}">RSS feed for this page</a> #}
|
||||
{# <a type="application/rss+xml" href="{% url "shared-stories-rss-feed" social_profile.user_id social_profile.username|slugify %}">RSS feed for this page</a> #}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from django.utils.hashcompat import sha_constructor
|
||||
import hashlib
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.cache import cache
|
||||
from django.utils.hashcompat import md5_constructor
|
||||
from django.utils.http import urlquote
|
||||
from django.http import HttpResponseForbidden
|
||||
from django.conf import settings
|
||||
|
@ -63,14 +62,14 @@ def get_user(request):
|
|||
return user
|
||||
|
||||
def invalidate_template_cache(fragment_name, *variables):
|
||||
args = md5_constructor(u':'.join([urlquote(var) for var in variables]))
|
||||
args = hashlib.md5(u':'.join([urlquote(var) for var in variables]))
|
||||
cache_key = 'template.cache.%s.%s' % (fragment_name, args.hexdigest())
|
||||
cache.delete(cache_key)
|
||||
|
||||
def generate_secret_token(phrase, size=12):
|
||||
"""Generate a (SHA1) security hash from the provided info."""
|
||||
info = (phrase, settings.SECRET_KEY)
|
||||
return sha_constructor("".join(info)).hexdigest()[:size]
|
||||
return hashlib.sha1("".join(info)).hexdigest()[:size]
|
||||
|
||||
def extract_user_agent(request):
|
||||
user_agent = request.environ.get('HTTP_USER_AGENT', '')
|
||||
|
|
Loading…
Add table
Reference in a new issue