Skip to content

Commit

Permalink
django 1.4 compatibility - exchanged message_set to messages contrib …
Browse files Browse the repository at this point in the history
…and MEDIA_URL vs. STATIC_URL
  • Loading branch information
hpoul committed Mar 17, 2012
1 parent b59677c commit 17c9449
Show file tree
Hide file tree
Showing 34 changed files with 65 additions and 64 deletions.
4 changes: 2 additions & 2 deletions sphenecoll/sphene/community/__init__.py
Expand Up @@ -14,8 +14,8 @@ class PermissionDenied(Exception):
from django.utils.translation import ugettext as _

jsincludes = get_sph_setting( 'community_jsincludes', [])
jsincludes.append(settings.STATIC_URL + 'sphene/community/jquery-1.2.3.min.js')
jsincludes.append(settings.STATIC_URL + 'sphene/community/jquery.autocomplete.js')
jsincludes.append(settings.MEDIA_URL + 'sphene/community/jquery-1.2.3.min.js')
jsincludes.append(settings.MEDIA_URL + 'sphene/community/jquery.autocomplete.js')
sphsettings.set_sph_setting( 'community_jsincludes', jsincludes )


Expand Down
1 change: 0 additions & 1 deletion sphenecoll/sphene/community/context_processors.py
Expand Up @@ -20,7 +20,6 @@ def navigation(request):
sph_settings = getattr( settings, 'SPH_SETTINGS', None )
sphdata['installed_apps'] = settings.INSTALLED_APPS
sphdata['current_url'] = request.path
sphdata['login_url'] = settings.LOGIN_URL
querystring = request.META.get('QUERY_STRING', None)
if querystring:
sphdata['current_url'] += '?'+querystring
Expand Down
3 changes: 0 additions & 3 deletions sphenecoll/sphene/community/management/__init__.py
Expand Up @@ -2,11 +2,8 @@
from sphene.community import models
from django.conf import settings

import os

def init_data(app, created_models, verbosity, **kwargs):
from sphene.community.models import Group, Navigation, CommunityUserProfileField
os.environ['sph_init_data'] = 'true'
if Group in created_models:
group, created = Group.objects.get_or_create( name = 'example',
longname = 'Example Group',
Expand Down
2 changes: 1 addition & 1 deletion sphenecoll/sphene/community/models.py
Expand Up @@ -651,7 +651,7 @@ def community_profile_edit_save_form(sender, instance, signal, request, *args, *
else:
if value.id: value.delete()

messages.success(request, message = _("Successfully saved community profile.") )
messages.success(request, message = _("Successfully saved community profile.") )

def community_profile_display(sender, signal, request, user, **kwargs):
try:
Expand Down
2 changes: 1 addition & 1 deletion sphenecoll/sphene/community/sphsettings.py
Expand Up @@ -10,7 +10,7 @@
'django096compatibility': False,


'community_avatar_default': settings.STATIC_URL + 'sphene/community/default_avatar.png',
'community_avatar_default': settings.MEDIA_URL + 'sphene/community/default_avatar.png',
'community_avatar_default_width': 48,
'community_avatar_default_height': 48,
'community_avatar_max_width': 150,
Expand Down
4 changes: 2 additions & 2 deletions sphenecoll/sphene/community/sphutils.py
Expand Up @@ -268,7 +268,7 @@ def include_js(jspath, prefix = None):
return

if prefix is None:
prefix = settings.STATIC_URL
prefix = settings.MEDIA_URL
jsincludes.append(prefix + jspath)

sphsettings.set_sph_setting( 'community_jsincludes', jsincludes )
Expand All @@ -281,7 +281,7 @@ def include_css(csspath, prefix = None):
return

if prefix is None:
prefix = settings.STATIC_URL
prefix = settings.MEDIA_URL
styleincludes.append(prefix + csspath)
sphsettings.set_sph_setting( 'community_styleincludes', styleincludes )

Expand Down
2 changes: 1 addition & 1 deletion sphenecoll/sphene/community/templates/sphene/base.html
Expand Up @@ -2,7 +2,7 @@

{% block head %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}sphene/community/styles/base.css" />
<link rel="stylesheet" href="{{ MEDIA_URL }}sphene/community/styles/base.css" />
{% if sph.rss %}
{% for rss in sph.rss %}
<link rel="alternate" title="{{ rss.label }}" href="{{ rss.url }}" type="application/rss+xml">
Expand Down
Expand Up @@ -5,7 +5,7 @@

{% block head %}
{{ block.super }}
<script type="text/javascript" src="{{ STATIC_URL }}sphene/community/jquery-1.2.3.min.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}sphene/community/jquery-1.2.3.min.js"></script>

<script type="text/javascript">

Expand Down
4 changes: 2 additions & 2 deletions sphenecoll/sphene/community/templatetags/sph_extras.py
Expand Up @@ -137,7 +137,7 @@ def handleMacroCall(self, doc, params):

url = categoryObj.get_absolute_url_rss_latest_threads()
add_rss_feed( url, 'RSS Feed of latest threads' )
return HTML( '<a href="%(url)s"><img src="%(media_url)ssphene/community/icons/feed-icon-14x14.png" border="0" alt="RSS Feed of latest threads" title="RSS Feed of latest threads" /></a>' % { 'url': url, 'media_url': settings.STATIC_URL } )
return HTML( '<a href="%(url)s"><img src="%(media_url)ssphene/community/icons/feed-icon-14x14.png" border="0" alt="RSS Feed of latest threads" title="RSS Feed of latest threads" /></a>' % { 'url': url, 'media_url': settings.MEDIA_URL } )


@register.filter
Expand Down Expand Up @@ -391,7 +391,7 @@ def resize(file, size='200x200'):
basename, format = file.name.rsplit('.', 1)
miniature = basename + '_' + size + '.thumb.' + format
miniature_filename = os.path.join(settings.MEDIA_ROOT, miniature)
miniature_url = os.path.join(settings.STATIC_URL, miniature)
miniature_url = os.path.join(settings.MEDIA_URL, miniature)

image = Image.open(file)

Expand Down
2 changes: 1 addition & 1 deletion sphenecoll/sphene/community/widgets.py
Expand Up @@ -43,7 +43,7 @@ def render(self, name, value, attrs=None):
}
//-->
</script>""" % { 'name': name,
'media_url': settings.STATIC_URL,
'media_url': settings.MEDIA_URL,
'content_type_id': self.content_type_id,
'url': sph_reverse( 'sph_tags_json_autocompletion', (), {} ), };

Expand Down
14 changes: 7 additions & 7 deletions sphenecoll/sphene/sphblockframework/__init__.py
Expand Up @@ -6,12 +6,12 @@

jsincludes = get_sph_setting( 'community_jsincludes', [])
# jquery is already added by the community application.
#jsincludes.append(settings.STATIC_URL + 'sphene/community/jquery-1.2.3.min.js')
jsincludes.append(settings.STATIC_URL + 'sphene/community/jquery.dimensions.js')
jsincludes.append(settings.STATIC_URL + 'sphene/community/ui.mouse.js')
#jsincludes.append(settings.STATIC_URL + 'sphene/community/ui.draggable.js')
jsincludes.append(settings.STATIC_URL + 'sphene/community/ui.droppable.js')
jsincludes.append(settings.STATIC_URL + 'sphene/community/ui.sortable.js')
jsincludes.append(settings.STATIC_URL + 'sphene/sphblockframework/blocksorting.js')
#jsincludes.append(settings.MEDIA_URL + 'sphene/community/jquery-1.2.3.min.js')
jsincludes.append(settings.MEDIA_URL + 'sphene/community/jquery.dimensions.js')
jsincludes.append(settings.MEDIA_URL + 'sphene/community/ui.mouse.js')
#jsincludes.append(settings.MEDIA_URL + 'sphene/community/ui.draggable.js')
jsincludes.append(settings.MEDIA_URL + 'sphene/community/ui.droppable.js')
jsincludes.append(settings.MEDIA_URL + 'sphene/community/ui.sortable.js')
jsincludes.append(settings.MEDIA_URL + 'sphene/sphblockframework/blocksorting.js')

sphsettings.set_sph_setting( 'community_jsincludes', jsincludes )
2 changes: 1 addition & 1 deletion sphenecoll/sphene/sphblog/categorytypes.py
Expand Up @@ -86,7 +86,7 @@ def save_post(self, newpost, data):
# If enabled, ping google blogsearch.
import urllib
url = self.category.group.get_baseurl()
blog_feed_url = reverse('sphblog-feeds', urlconf=get_current_urlconf(), kwargs = { 'url': 'latestposts/%s' % self.category.id })
blog_feed_url = reverse('sphblog-feeds', urlconf=get_current_urlconf(), kwargs = { 'category_id': self.category.id })
pingurl = 'http://blogsearch.google.com/ping?%s' % \
urllib.urlencode( \
{ 'name': self.category.name,
Expand Down
8 changes: 4 additions & 4 deletions sphenecoll/sphene/sphblog/feeds.py
@@ -1,7 +1,7 @@


from django.http import Http404
from django.contrib.syndication.feeds import Feed
from django.contrib.syndication.views import Feed

from sphene.community.middleware import get_current_group
from sphene.sphblog.models import BlogPostExtension
Expand All @@ -17,12 +17,12 @@ class LatestBlogPosts(Feed):
title_template = 'sphene/sphblog/feeds/latestposts_title.html'
description_template = 'sphene/sphblog/feeds/latestposts_description.html'

def get_object(self, bits):
def get_object(self, request, category_id = None):
group = get_current_group()
categories = get_board_categories(group)
if len(bits) != 1:
if not category_id:
return categories
category_id = int(bits[0])
#category_id = int(bits[0])
categories = [category for category in categories \
if category.id == category_id]
if not categories:
Expand Down
Expand Up @@ -2,5 +2,5 @@

{% block stylesheets %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}sphene/sphblog/styles/base.css" />
<link rel="stylesheet" href="{{ MEDIA_URL }}sphene/sphblog/styles/base.css" />
{% endblock %}
Expand Up @@ -102,7 +102,7 @@ <h1>{{ category.name }}</h1>
</div>

<p>
<a href="{% sph_url2 sphblog-feeds url="latestposts" %}">{% trans "RSS Feed" %}</a>
<a href="{% sph_url2 sphblog-feeds %}">{% trans "RSS Feed" %}</a>
</p>

{% endblock %}
Expand Up @@ -7,7 +7,7 @@

{% block stylesheets %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}sphene/sphblog/styles/base.css" />
<link rel="stylesheet" href="{{ MEDIA_URL }}sphene/sphblog/styles/base.css" />
{% endblock %}

{% block sphboard_breadcrumb %}
Expand Down
15 changes: 10 additions & 5 deletions sphenecoll/sphene/sphblog/urls.py
Expand Up @@ -2,13 +2,18 @@

from sphene.sphblog.feeds import LatestBlogPosts

feeds = {
'latestposts': LatestBlogPosts,
}
#feeds = {
# 'latestposts': LatestBlogPosts,
#}

urlpatterns = patterns('',
url(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
{ 'feed_dict': feeds,
url(r'^feeds/latestposts/$', LatestBlogPosts(),
{
'noGroup': True,
},
name = 'sphblog-feeds'),
url(r'^feeds/latestposts/(?P<category_id>\d+)/$', LatestBlogPosts(),
{
'noGroup': True,
},
name = 'sphblog-feeds'),
Expand Down
2 changes: 1 addition & 1 deletion sphenecoll/sphene/sphblog/views.py
Expand Up @@ -140,7 +140,7 @@ def blogindex(request, group, category_id = None, category_slug = None, page = 1

allowpostcategories = filter(Category.has_post_thread_permission, category_info[0])
#blog_feed_url = reverse('sphblog-feeds', urlconf=get_current_urlconf(), args = ('latestposts',), kwargs = { 'groupName': group.name })
blog_feed_url = sph_reverse('sphblog-feeds', kwargs = { 'url': 'latestposts' })
blog_feed_url = sph_reverse('sphblog-feeds');#, kwargs = { 'url': 'latestposts' })
add_rss_feed( blog_feed_url, 'Blog RSS Feed' )
all_tags = get_tags_for_categories( category_info[0] )

Expand Down
4 changes: 2 additions & 2 deletions sphenecoll/sphene/sphboard/__init__.py
Expand Up @@ -45,7 +45,7 @@
# sph extended BBCODE wiki label.
'board_auto_wiki_link_enabled': True,
# default location of emoticons
'board_emoticons_root': settings.STATIC_URL + 'sphene/emoticons/',
'board_emoticons_root': settings.MEDIA_URL + 'sphene/emoticons/',
'board_emoticons_list': {
'0:-)': 'angel.gif',
'O:-)':'angel.gif',
Expand Down Expand Up @@ -124,5 +124,5 @@


styleincludes = sphsettings.get_sph_setting( 'community_styleincludes', [])
styleincludes.append(settings.STATIC_URL + 'sphene/sphboard/styles/base.css')
styleincludes.append(settings.MEDIA_URL + 'sphene/sphboard/styles/base.css')
sphsettings.set_sph_setting( 'community_styleincludes', styleincludes )
4 changes: 2 additions & 2 deletions sphenecoll/sphene/sphboard/lists.py
Expand Up @@ -15,8 +15,8 @@ def makelink(object, column, value):

class NewPostIndicator(objlist.Column):
def _get_value(self, object):
# {{ STATIC_URL }}sphene/sphboard/icons/{% if thread.has_new_posts %}new{% endif %}folder.gif" width='16px' height='16px' title='Heat: {{ thread.heat }}' /></td
return mark_safe( '<img src="%ssphene/sphboard/icons/%sfolder.gif" width="16px" height="16px" />' % (settings.STATIC_URL, object.has_new_posts() and 'new' or '' ) )
# {{ MEDIA_URL }}sphene/sphboard/icons/{% if thread.has_new_posts %}new{% endif %}folder.gif" width='16px' height='16px' title='Heat: {{ thread.heat }}' /></td
return mark_safe( '<img src="%ssphene/sphboard/icons/%sfolder.gif" width="16px" height="16px" />' % (settings.MEDIA_URL, object.has_new_posts() and 'new' or '' ) )


class ThreadList(objlist.AdvancedObjectList):
Expand Down
Expand Up @@ -6,7 +6,7 @@
{% for test in level|sphrange %}
<td width='5px'>&nbsp;</td>
{% endfor %}
<td width="20px"><img src="{{ STATIC_URL }}sphene/sphboard/icons/{% if category.has_new_posts %}new{% endif %}folder.gif" width='16px' height='16px' /></td>
<td width="20px"><img src="{{ MEDIA_URL }}sphene/sphboard/icons/{% if category.has_new_posts %}new{% endif %}folder.gif" width='16px' height='16px' /></td>
{% ifequal category.category_type "sphseparator" %}
<td class="sphboard_categoryname" colspan="{{ maxDepth|sphminus:level|sph_plus:3 }}"><a href="{{ category.get_absolute_url }}">{{ category.name }}</a></td>
{% else %}
Expand Down
Expand Up @@ -2,10 +2,10 @@
{% load sph_extras %}
{% load sphboard_extras %}
{% if bbcodewysiwyg %}
<link rel="stylesheet" href="{{ STATIC_URL }}sphene/sphboard/styles/editor.css" />
<script type="text/javascript" src="{{ STATIC_URL }}sphene/sphboard/js/editor.js"></script>
<link rel="stylesheet" href="{{ MEDIA_URL }}sphene/sphboard/styles/editor.css" />
<script type="text/javascript" src="{{ MEDIA_URL }}sphene/sphboard/js/editor.js"></script>
{% endif %}
<script language="JavaScript" type="text/javascript" src="{{ STATIC_URL }}sphene/community/xmlhttp.js"></script>
<script language="JavaScript" type="text/javascript" src="{{ MEDIA_URL }}sphene/community/xmlhttp.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
function doPreview() {
Expand Down Expand Up @@ -34,9 +34,9 @@
{{ form }}
{% if bbcodewysiwyg %}
<script type="text/javascript">
var editor_static = "{{ STATIC_URL }}sphene/sphboard";
var editor_static = "{{ MEDIA_URL }}sphene/sphboard";
</script>
<script type="text/javascript" src="{{ STATIC_URL }}sphene/sphboard/js/inline.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}sphene/sphboard/js/inline.js"></script>
{% endif %}
</table>
</script>
Expand Down
Expand Up @@ -6,7 +6,7 @@

{% block head %}
{{ block.super }}
<script type="text/javascript" src="{{ STATIC_URL }}sphene/community/jquery-1.2.3.min.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}sphene/community/jquery-1.2.3.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){
Expand Down
Expand Up @@ -2,5 +2,5 @@

{% block head %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}sphene/sphboard/styles/base.css" />
<link rel="stylesheet" href="{{ MEDIA_URL }}sphene/sphboard/styles/base.css" />
{% endblock %}
Expand Up @@ -66,7 +66,7 @@
{% endblock thread_list_header %}
{% for thread in thread_list %}
<tr>
<td width="20px"><img src="{{ STATIC_URL }}sphene/sphboard/icons/{% if thread.has_new_posts %}new{% endif %}folder.gif" width='16px' height='16px' title='Heat: {{ thread.heat }}' /></td>
<td width="20px"><img src="{{ MEDIA_URL }}sphene/sphboard/icons/{% if thread.has_new_posts %}new{% endif %}folder.gif" width='16px' height='16px' title='Heat: {{ thread.heat }}' /></td>
{% if thread.is_moved %}
<td colspan="4"><small>
{% blocktrans with thread.get_absolute_url as th_url and thread.subject as th_subject and thread.root_post.category.get_absolute_url as cat_url and thread.root_post.category.name as cat_name %}Thread was moved: <a href="{{ th_url }}">{{ th_subject }}</a> into <a href="{{ cat_url }}">{{ cat_name }}</a>.{% endblocktrans %}
Expand Down
Expand Up @@ -6,12 +6,12 @@
<div class="sphquestions_answer">
{% if votecount %}
<div>
<img src="{{ STATIC_URL }}sphene/sphquestions/icons/answered.png" width="16px" height="16px" /> This answers the question. (Voted by <strong>{{ votecount }} users</strong>{% if authorvoted %} including the author of the question{% endif %}.)
<img src="{{ MEDIA_URL }}sphene/sphquestions/icons/answered.png" width="16px" height="16px" /> This answers the question. (Voted by <strong>{{ votecount }} users</strong>{% if authorvoted %} including the author of the question{% endif %}.)
</div>
{% endif %}
{% if allowvoting %}
<div>
<img src="{{ STATIC_URL }}sphene/sphquestions/icons/question_blue.png" width="16px" height="16px" /> Did this reply answer the question ? <a href="{% sph_url2 sphquestions_votereply reply_id=post.id %}">Yes</a>
<img src="{{ MEDIA_URL }}sphene/sphquestions/icons/question_blue.png" width="16px" height="16px" /> Did this reply answer the question ? <a href="{% sph_url2 sphquestions_votereply reply_id=post.id %}">Yes</a>
</div>
{% endif %}
</div>
Expand Down
Expand Up @@ -27,12 +27,12 @@
{% if qext.is_question %}
{% if qext.answered %}
{% ifequal qext.answered 3 %}
<img src="{{ STATIC_URL }}sphene/sphquestions/icons/answered.png" width="16px" height="16px" alt="Answered (Voted by the author)" title="Answered (Voted by the author)" class="sphquestion" />
<img src="{{ MEDIA_URL }}sphene/sphquestions/icons/answered.png" width="16px" height="16px" alt="Answered (Voted by the author)" title="Answered (Voted by the author)" class="sphquestion" />
{% else %}
<img src="{{ STATIC_URL }}sphene/sphquestions/icons/voted_answered.png" width="16px" height="16px" alt="Answered (Voted by a user)" title="Answered (Voted by a user)" class="sphquestion" />
<img src="{{ MEDIA_URL }}sphene/sphquestions/icons/voted_answered.png" width="16px" height="16px" alt="Answered (Voted by a user)" title="Answered (Voted by a user)" class="sphquestion" />
{% endifequal %}
{% else %}
<img src="{{ STATIC_URL }}sphene/sphquestions/icons/question_blue.png" width="16px" height="16px" alt="Unanswered question" title="Unanswered question" class="sphquestion" />
<img src="{{ MEDIA_URL }}sphene/sphquestions/icons/question_blue.png" width="16px" height="16px" alt="Unanswered question" title="Unanswered question" class="sphquestion" />
{% endif %}
{% endif %}
{% endwith %}
Expand All @@ -43,8 +43,8 @@

{% block below_thread_list %}
<ul class="sphquestions_icons">
<li><img src="{{ STATIC_URL }}sphene/sphquestions/icons/answered.png" width="16px" height="16px" alt="Answered (Voted by the author)" title="Answered (Voted by the author)" /> Answered question (Voted by the author of the question)</li>
<li><img src="{{ STATIC_URL }}sphene/sphquestions/icons/voted_answered.png" width="16px" height="16px" alt="Answered (Voted by a user)" title="Answered (Voted by a user)" /> Answered question (Voted by another user but not by the author)</li>
<li> <img src="{{ STATIC_URL }}sphene/sphquestions/icons/question_blue.png" width="16px" height="16px" alt="Unanswered question" title="Unanswered question" /> Unanswered question.</li>
<li><img src="{{ MEDIA_URL }}sphene/sphquestions/icons/answered.png" width="16px" height="16px" alt="Answered (Voted by the author)" title="Answered (Voted by the author)" /> Answered question (Voted by the author of the question)</li>
<li><img src="{{ MEDIA_URL }}sphene/sphquestions/icons/voted_answered.png" width="16px" height="16px" alt="Answered (Voted by a user)" title="Answered (Voted by a user)" /> Answered question (Voted by another user but not by the author)</li>
<li> <img src="{{ MEDIA_URL }}sphene/sphquestions/icons/question_blue.png" width="16px" height="16px" alt="Unanswered question" title="Unanswered question" /> Unanswered question.</li>
</ul>
{% endblock %}
Expand Up @@ -44,7 +44,7 @@ def sphquestions_answervoting(qext, reply):
'uservoted' : uservoted,
'authorvoted': authorvoted,
'votecount' : len(votes),
'STATIC_URL' : settings.STATIC_URL,
'MEDIA_URL' : settings.STATIC_URL,
'allowvoting': allowvoting,
}

Expand Down
Expand Up @@ -2,5 +2,5 @@

{% block head %}
{{ block.super }}
<link rel="stylesheet" href="{{ STATIC_URL }}sphene/sphsearch/styles/searchbase.css" />
<link rel="stylesheet" href="{{ MEDIA_URL }}sphene/sphsearch/styles/searchbase.css" />
{% endblock %}
2 changes: 1 addition & 1 deletion sphenecoll/sphene/sphwiki/feeds.py
@@ -1,4 +1,4 @@
from django.contrib.syndication.feeds import Feed
from django.contrib.syndication.views import Feed
from sphene.sphwiki.models import WikiSnipChange, WikiSnip
from sphene.community.middleware import get_current_group

Expand Down
2 changes: 1 addition & 1 deletion sphenecoll/sphene/sphwiki/models.py
Expand Up @@ -93,7 +93,7 @@ def pdf_generate(self):
static_filepath = settings.MEDIA_ROOT
snip_rendered_body = snip_rendered_body.replace(
'<img src="%(media_url)s' % \
{ 'media_url': settings.STATIC_URL },
{ 'media_url': settings.MEDIA_URL },
'<img src="%s/' % static_filepath )
import codecs
xmlout = codecs.open(xmlfile, mode='w', encoding='utf-8')
Expand Down

0 comments on commit 17c9449

Please sign in to comment.