Merge with piranha
authorpythy <the.pythy@gmail.com>
Tue Oct 21 21:40:08 2008 +0700 (3 days ago)
changeset 1058e1e99c66a1de
parent 105334586edd6d5f
parent 105749cf2bfe5b56
child 10595bb844ed22fb
Merge with piranha
settings.py
urls.py
       1 --- a/apps/accounts/views.py	Fri Oct 17 08:23:09 2008 +0700
       2 +++ b/apps/accounts/views.py	Tue Oct 21 21:40:08 2008 +0700
       3 @@ -83,6 +83,8 @@
       4          return {'success': _(u'Password succesfully resetted. Message with new password was sent to your email.')}
       5      else:
       6          if request.method == 'POST':
       7 +            if not request.POST['email']:
       8 +                return {'error': _(u'Please enter email.')}
       9              try:
      10                  user = User.objects.filter(is_active=True).get(email__iexact=request.POST['email'])
      11                  ActionRecord.resets.create_password_reset(user)
     1.1 --- a/apps/blog/admin.py	Fri Oct 17 08:23:09 2008 +0700
     1.2 +++ b/apps/blog/admin.py	Tue Oct 21 21:40:08 2008 +0700
     1.3 @@ -26,7 +26,7 @@
     1.4                  settings.STATIC_URL + 'js/wymeditor/jquery.wymeditor.pack.js',
     1.5                  '/' + settings.BLOG_URLCONF_ROOT + 'wysiwyg_js/',
     1.6                  )
     1.7 -        if settings.RENDER_METHOD=='markdown':
     1.8 +        if settings.RENDER_METHOD in ('html', 'markdown', 'rst'):
     1.9              js = (settings.STATIC_URL + 'js/postimage.js', )
    1.10  
    1.11      def queryset(self, request):
     2.1 --- a/apps/blog/models.py	Fri Oct 17 08:23:09 2008 +0700
     2.2 +++ b/apps/blog/models.py	Tue Oct 21 21:40:08 2008 +0700
     2.3 @@ -7,6 +7,7 @@
     2.4  from django.utils.html import strip_tags
     2.5  from django.contrib.contenttypes import generic
     2.6  
     2.7 +from lib import appcheck
     2.8  from lib.helpers import reverse
     2.9  from render import render, RENDER_METHODS
    2.10  from blog.managers import PostManager, PublicPostManager, FeaturedPostManager
    2.11 @@ -99,19 +100,20 @@
    2.12      return Post.objects.filter(date__range=r).get(slug=slug)
    2.13  
    2.14  ping_details = {'post_detail': pingback_blog_handler}
    2.15 -
    2.16  xmlrpc.dispatcher.register_function(create_ping_func(**ping_details), 'pingback.ping')
    2.17  
    2.18 -if settings.ENABLE_PINGBACK:
    2.19 -    ping_links = ping_external_links(content_attr='html', url_attr='get_absolute_url',
    2.20 -                                     filtr=lambda x: not x.is_draft)
    2.21 +
    2.22 +ping_links = ping_external_links(content_attr='html', url_attr='get_absolute_url',
    2.23 +                                 filtr=lambda x: not x.is_draft)
    2.24 +ping_dirs = ping_directories(content_attr='html', url_attr='get_absolute_url',
    2.25 +                             filtr=lambda x: not x.is_draft)
    2.26 +
    2.27 +if appcheck.pingback:
    2.28      models.signals.post_save.connect(ping_links, sender=Post)
    2.29 -if settings.ENABLE_DIRECTORY_PING:
    2.30 -    ping_dirs = ping_directories(content_attr='html', url_attr='get_absolute_url',
    2.31 -                                 filtr=lambda x: not x.is_draft)
    2.32      models.signals.post_save.connect(ping_dirs, sender=Post)
    2.33  
    2.34 -if 'watchlist' in settings.INSTALLED_APPS:
    2.35 +
    2.36 +if appcheck.watchlist:
    2.37      from watchlist.models import Subscription
    2.38      def subscribe_author(instance, created, **kwargs):
    2.39          if not created:
     3.1 --- a/apps/blog/tests.py	Fri Oct 17 08:23:09 2008 +0700
     3.2 +++ b/apps/blog/tests.py	Tue Oct 21 21:40:08 2008 +0700
     3.3 @@ -9,6 +9,8 @@
     3.4  from blog.models import Post
     3.5  from discussion.models import CommentNode
     3.6  from lib.helpers import reverse
     3.7 +from lib import appcheck
     3.8 +
     3.9  
    3.10  class PostTestCase(test.TestCase):
    3.11  
    3.12 @@ -61,8 +63,13 @@
    3.13          response = self.client.post(self.p1.get_absolute_url(),
    3.14                                      {'body': 'completely useless', 'name': 'somethingright',
    3.15                                       'email': '[email protected]', 'subscribe': True})
    3.16 -        # Expect a registrations and notification email to be sent
    3.17 -        self.assertEquals(len(mail.outbox), 3)
    3.18 +        if not appcheck.watchlist:
    3.19 +            # Expect a registrations and notification email to be sent
    3.20 +            mailcount = 3
    3.21 +        else:
    3.22 +            # Additionally two notification for comment author
    3.23 +            mailcount = 5
    3.24 +        self.assertEquals(len(mail.outbox), mailcount)
    3.25  
    3.26      def testDeleteComments(self):
    3.27          c = CommentNode(approved=False, body="just test", user=self.user, object=self.p1)
     4.1 --- a/apps/context_processors.py	Fri Oct 17 08:23:09 2008 +0700
     4.2 +++ b/apps/context_processors.py	Tue Oct 21 21:40:08 2008 +0700
     4.3 @@ -4,11 +4,14 @@
     4.4  from django.contrib.sites.models import Site
     4.5  from blog.models import Post
     4.6  
     4.7 +from lib import appcheck
     4.8 +
     4.9  def settings_vars(request):
    4.10      return {
    4.11          'STATIC_URL': settings.STATIC_URL,
    4.12          'THEME_STATIC_URL': settings.THEME_STATIC_URL,
    4.13          'settings': settings,
    4.14 +        'appcheck': appcheck,
    4.15          }
    4.16  
    4.17  def featured_posts(request):
     5.1 --- a/apps/lib/__init__.py	Fri Oct 17 08:23:09 2008 +0700
     5.2 +++ b/apps/lib/__init__.py	Tue Oct 21 21:40:08 2008 +0700
     5.3 @@ -0,0 +1,8 @@
     5.4 +from django.conf import settings
     5.5 +
     5.6 +
     5.7 +class ApplicationChecker(object):
     5.8 +    "Checks if application is enabled"
     5.9 +    def __getattr__(self, attr):
    5.10 +        return attr in settings.INSTALLED_APPS
    5.11 +appcheck = ApplicationChecker()
     6.1 --- a/apps/livejournal/admin.py	Fri Oct 17 08:23:09 2008 +0700
     6.2 +++ b/apps/livejournal/admin.py	Tue Oct 21 21:40:08 2008 +0700
     6.3 @@ -4,7 +4,8 @@
     6.4  
     6.5  from livejournal.models import LiveJournalPost
     6.6  from livejournal.utils import lj_crosspost, lj_delete
     6.7 -
     6.8 +from blog.models import Post
     6.9 +from blog.admin import PostAdmin
    6.10  
    6.11  class LiveJournalPostAdmin(admin.ModelAdmin):
    6.12      list_display = ('post', 'need_crosspost')
    6.13 @@ -12,15 +13,14 @@
    6.14  admin.site.register(LiveJournalPost, LiveJournalPostAdmin)
    6.15  
    6.16  
    6.17 -if settings.ENABLE_LJ_CROSSPOST:
    6.18 -    from blog.models import Post
    6.19 -    from blog.admin import PostAdmin
    6.20 -    class LiveJournalPostInlineAdmin(admin.TabularInline):
    6.21 -        model = LiveJournalPost
    6.22 -        max_num = 1
    6.23 -    PostAdmin.list_display += ('lj_object', )
    6.24 -    pa = admin.site._registry[Post]
    6.25 -    pa.inline_instances.append(
    6.26 -        LiveJournalPostInlineAdmin(pa.model, pa.admin_site))
    6.27 -    models.signals.pre_save.connect(lj_crosspost, sender=LiveJournalPost)
    6.28 -    models.signals.pre_delete.connect(lj_delete, sender=LiveJournalPost)
    6.29 +class LiveJournalPostInlineAdmin(admin.TabularInline):
    6.30 +    model = LiveJournalPost
    6.31 +    max_num = 1
    6.32 +
    6.33 +PostAdmin.list_display += ('lj_object', )
    6.34 +
    6.35 +pa = admin.site._registry[Post]
    6.36 +pa.inline_instances.append(LiveJournalPostInlineAdmin(pa.model, pa.admin_site))
    6.37 +
    6.38 +models.signals.pre_save.connect(lj_crosspost, sender=LiveJournalPost)
    6.39 +models.signals.pre_delete.connect(lj_delete, sender=LiveJournalPost)
     7.1 --- a/apps/postimage/forms.py	Fri Oct 17 08:23:09 2008 +0700
     7.2 +++ b/apps/postimage/forms.py	Tue Oct 21 21:40:08 2008 +0700
     7.3 @@ -26,7 +26,7 @@
     7.4  
     7.5  
     7.6  class UploadForm(forms.Form):
     7.7 -    subdirectory = forms.CharField(_('Subdirectory'), required=False)
     7.8 +    subdirectory = forms.CharField(label=_('Subdirectory'), required=False)
     7.9      file = forms.FileField(label=_('Select a file to attach'), required=True)
    7.10  
    7.11      def clean_subdirectory(self):
     8.1 --- a/apps/postimage/views.py	Fri Oct 17 08:23:09 2008 +0700
     8.2 +++ b/apps/postimage/views.py	Tue Oct 21 21:40:08 2008 +0700
     8.3 @@ -1,4 +1,4 @@
     8.4 -from django.template import Context, loader
     8.5 +from django.template import Context, RequestContext, loader
     8.6  from django.http import HttpResponseRedirect, HttpResponse
     8.7  from django.views.decorators.cache import never_cache
     8.8  from django.core.urlresolvers import reverse
     8.9 @@ -24,7 +24,7 @@
    8.10           'postimage_url': settings.POSTIMAGE_URL,
    8.11           'postimage_root': settings.POSTIMAGE_ROOT,
    8.12           'for': request.GET['for'], }
    8.13 -    c = Context(c)
    8.14 +    c = RequestContext(request, c)
    8.15      return HttpResponse(t.render(c))
    8.16  
    8.17  
     9.1 --- a/settings.py	Fri Oct 17 08:23:09 2008 +0700
     9.2 +++ b/settings.py	Tue Oct 21 21:40:08 2008 +0700
     9.3 @@ -124,6 +124,8 @@
     9.4      os.path.join(PROJECT_ROOT, 'templates'),
     9.5  )
     9.6  
     9.7 +# Here are included application necessary for work
     9.8 +# All other should go to the ADDITIONAL_APPS
     9.9  INSTALLED_APPS = (
    9.10      'django.contrib.auth',
    9.11      'django.contrib.contenttypes',
    9.12 @@ -136,23 +138,14 @@
    9.13      'lib',
    9.14      'pytils',
    9.15      'accounts',
    9.16 +    'blog',
    9.17      'discussion',
    9.18 -    'blog',
    9.19 -    'pingback',
    9.20 -    'openidconsumer',
    9.21      'tagging',
    9.22      'typogrify',
    9.23 -    'livejournal',
    9.24      'render',
    9.25 -    'robots',
    9.26 -    'textblocks',
    9.27 -    'blogroll',
    9.28 +    'postimage',
    9.29 +    'openidconsumer',
    9.30      'openidserver',
    9.31 -    'recaptcha',
    9.32 -    'debug',
    9.33 -    'sape',
    9.34 -    'watchlist',
    9.35 -    'postimage',
    9.36  )
    9.37  
    9.38  APPEND_SLASH = False
    9.39 @@ -177,14 +170,11 @@
    9.40  OPENID_REDIRECT_NEXT = '/'
    9.41  
    9.42  # Pingback
    9.43 -ENABLE_PINGBACK = True
    9.44  PINGBACK_SERVER = {
    9.45      'post_detail': 'pingback.getters.post_get',
    9.46      }
    9.47  PINGBACK_RESPONSE_LENGTH = 200
    9.48  
    9.49 -# Blogs directory ping
    9.50 -ENABLE_DIRECTORY_PING = False
    9.51  # TODO: move this list to DB
    9.52  DIRECTORY_URLS = (
    9.53      'http://ping.blogs.yandex.ru/RPC2',
    9.54 @@ -239,14 +229,10 @@
    9.55      sys.stderr.write('Unable to read settings_local.py\n')
    9.56      sys.exit(1)
    9.57  
    9.58 -if ENABLE_IMPORT:
    9.59 -    INSTALLED_APPS += ('wpimport', )
    9.60 -
    9.61 -#if ENABLE_SAPE:
    9.62 -    #INSTALLED_APPS += ('sape', )
    9.63 -
    9.64 -if 'ADDITIONAL_APPS' in locals():
    9.65 -    INSTALLED_APPS = INSTALLED_APPS + locals()['ADDITIONAL_APPS']
    9.66 +try:
    9.67 +    INSTALLED_APPS += ADDITIONAL_APPS
    9.68 +except NameError:
    9.69 +    pass
    9.70  
    9.71  LOCALE_PATHS = (os.path.join(PROJECT_ROOT, 'locale'), )
    9.72  THEME_STATIC_URL = os.path.join('/_theme', THEME + '/')
    10.1 --- a/settings_local.py.template	Fri Oct 17 08:23:09 2008 +0700
    10.2 +++ b/settings_local.py.template	Tue Oct 21 21:40:08 2008 +0700
    10.3 @@ -37,8 +37,6 @@
    10.4  RECAPTCHA_PUBLIC_KEY = ''
    10.5  RECAPTCHA_PRIVATE_KEY =''
    10.6  
    10.7 -ENABLE_SAPE = False # Set this to true to enable Sape.ru client
    10.8 -ENABLE_IMPORT = False # Set this to true to enable WordPress importer
    10.9  GA_ACC = '' # Google Analytics account
   10.10  LI_ACC = False # Set True if you want liveinternet.ru counter
   10.11  GRAVATAR_ENABLE = False # Enable gravatars?
   10.12 @@ -62,9 +60,21 @@
   10.13  ORM_DEBUG = False
   10.14  
   10.15  # Livejournal crossposting
   10.16 -ENABLE_LJ_CROSSPOST = False
   10.17  LJ_USERNAME = ''
   10.18  LJ_PASSWORD = ''
   10.19 +
   10.20 +ADDITIONAL_APPS = (
   10.21 +    'recaptcha',
   10.22 +    'pingback',
   10.23 +    'watchlist',   # comments subscription
   10.24 +    'blogroll',
   10.25 +    'robots',
   10.26 +#    'debug',       # debug sql query
   10.27 +#    'livejournal', # livejournal crossposting
   10.28 +#    'textblocks',
   10.29 +#    'wpimport',
   10.30 +#    'sape',        # sape.ru
   10.31 +    )
   10.32  
   10.33  # DEBUG must be False in production mode
   10.34  # Please read http://byteflow.su/wiki/DEBUG
    11.1 --- a/static/js/postimage.js	Fri Oct 17 08:23:09 2008 +0700
    11.2 +++ b/static/js/postimage.js	Tue Oct 21 21:40:08 2008 +0700
    11.3 @@ -1,13 +1,23 @@
    11.4  Postimage = {
    11.5 -	showLinkOn : Array('id_text', 'id_content'),
    11.6 +	// add here the #id-s that you would like to use postimage for
    11.7 +	showLinkOn: Array('id_text', 'id_content'),
    11.8  
    11.9 -	init: function() {
   11.10 +	// what markup do you use? see the createLink function for supported markups,
   11.11 +	// defaults to markdown
   11.12 +	markup: 'markdown',
   11.13 +
   11.14 +	init: function(markup) {
   11.15 +		this.markup = (markup == null) ? this.markup : markup;
   11.16  		if( document.getElementById('postimage') ) {
   11.17  			return;
   11.18  		}
   11.19  		else {
   11.20  			this.showLink();
   11.21  		}
   11.22 +	},
   11.23 +
   11.24 +	setMarkup: function(markup) {
   11.25 +		this.markup = (markup == null) ? 'markdown' : markup;
   11.26  	},
   11.27  
   11.28  	showLink: function() {
   11.29 @@ -29,25 +39,35 @@
   11.30  	},
   11.31  
   11.32  	showLinkFor: function(elem) {
   11.33 -        elem.previousSibling.appendChild(document.createElement('br'));
   11.34 +		elem.previousSibling.appendChild(document.createElement('br'));
   11.35  		elem.previousSibling.appendChild(this.getLink(elem.id));
   11.36  	},
   11.37  
   11.38  	pathToImage: function(image) {
   11.39  		var url = document.getElementById('baseurl').value;
   11.40 -        var root = document.getElementById('image_root').value;
   11.41 -        var len = root.length;
   11.42 -        if (root[len-1] != '/') {
   11.43 -            len += 1;
   11.44 -        }
   11.45 +		var root = document.getElementById('image_root').value;
   11.46 +		var len = root.length;
   11.47 +		if (root[len-1] != '/') { len += 1; };
   11.48  		return url.concat(image.slice(len));
   11.49  	},
   11.50  
   11.51  	submit: function() {
   11.52  		var elem = document.getElementById('id_file');
   11.53  		var target = window.opener.document.getElementById(document.getElementById('for').value);
   11.54 -		target.value = target.value + '\n![' + document.getElementById('id_alt').value + '](' + this.pathToImage(elem.value) + ')\n';
   11.55 +		target.value = target.value + this.createLink(document.getElementById('id_alt').value, this.pathToImage(elem.value));
   11.56  		window.close();
   11.57 +	},
   11.58 +
   11.59 +	createLink: function(alt, src) {
   11.60 +		switch (this.markup) {
   11.61 +		case 'html':
   11.62 +			return '\n<img alt="' + alt + '" src="' + src + '" />\n';
   11.63 +		case 'rst':
   11.64 +			return '\n.. image:: ' + src + '\n  :alt: ' + alt + '\n';
   11.65 +		default:
   11.66 +			return '\n![' + alt + '](' + src + ')\n';
   11.67 +			break;
   11.68 +		}
   11.69  	}
   11.70  };
   11.71  
    12.1 --- a/templates/admin/postimage/base.html	Fri Oct 17 08:23:09 2008 +0700
    12.2 +++ b/templates/admin/postimage/base.html	Tue Oct 21 21:40:08 2008 +0700
    12.3 @@ -3,7 +3,9 @@
    12.4  <head>
    12.5  <title>{% block title %}{% endblock %}</title>
    12.6  <link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% load adminmedia %}{% admin_media_prefix %}css/forms.css{% endblock %}" />
    12.7 +<script type="text/javascript" src="{% admin_media_prefix %}js/core.js"/></script>
    12.8  <script type="text/javascript" src="{{ media_url }}js/postimage.js"></script>
    12.9 +<script type="text/javascript">Postimage.setMarkup('{{ settings.RENDER_METHOD }}');</script>
   12.10  {% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% admin_media_prefix %}css/rtl.css{% endblock %}" />{% endif %}
   12.11  {% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
   12.12  </head>
    13.1 --- a/templates/blog/post_detail.html	Fri Oct 17 08:23:09 2008 +0700
    13.2 +++ b/templates/blog/post_detail.html	Tue Oct 21 21:40:08 2008 +0700
    13.3 @@ -18,7 +18,7 @@
    13.4  {% theme_js "ajaxforms" %}
    13.5  {% ifequal settings.CAPTCHA "recaptcha" %}<script type="text/javascript" src="http://api.recaptcha.net/js/recaptcha_ajax.js"></script>{% endifequal %}
    13.6  <link rel="alternate" type="application/rss+xml" title="{{ settings.BLOG_NAME }}: comments on {{ object.name }} feed" href="{% url feed feedurl %}" />
    13.7 -<link rel="pingback" href="http://{{ site.domain }}{% url xmlrpc %}" />
    13.8 +{% if appcheck.pingback %}<link rel="pingback" href="http://{{ site.domain }}{% url xmlrpc %}" />{% endif %}
    13.9  {% endblock %}
   13.10  
   13.11  {% block content %}
    14.1 --- a/urls.py	Fri Oct 17 08:23:09 2008 +0700
    14.2 +++ b/urls.py	Tue Oct 21 21:40:08 2008 +0700
    14.3 @@ -13,13 +13,13 @@
    14.4  from tagging.models import Tag
    14.5  import watchlist.mail
    14.6  import patches
    14.7 +from lib import appcheck
    14.8  
    14.9  def error500(request, template_name='500.html'):
   14.10      try:
   14.11          output = render_to_string(template_name, {}, RequestContext(request))
   14.12      except:
   14.13          output = "Critical error. Administrator was notified."
   14.14 -    #render_to_string(template_name, {}, Context())
   14.15      return HttpResponseServerError(output)
   14.16  
   14.17  handler500 = 'urls.error500'
   14.18 @@ -70,26 +70,16 @@
   14.19  if settings.DEBUG:
   14.20      urlpatterns += patterns(
   14.21          '',
   14.22 -        url(r'^media/(.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
   14.23 -        url(r'^static/(.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
   14.24 -        url(r'^%s(.*)$' % settings.THEME_STATIC_URL[1:], 'django.views.static.serve', {'document_root': settings.THEME_STATIC_ROOT}),
   14.25 -        url(r'^admin-media/(.*)$', 'django.views.static.serve', {'document_root': join(dirname(admin.__file__), 'media')}),
   14.26 +        url(r'^media/(.*)$', 'django.views.static.serve',
   14.27 +            {'document_root': settings.MEDIA_ROOT}),
   14.28 +        url(r'^static/(.*)$', 'django.views.static.serve',
   14.29 +            {'document_root': settings.STATIC_ROOT}),
   14.30 +        url(r'^admin-media/(.*)$', 'django.views.static.serve',
   14.31 +            {'document_root': join(dirname(admin.__file__), 'media')}),
   14.32          )
   14.33  
   14.34 -if 'wpimport' in settings.INSTALLED_APPS:
   14.35 -    urlpatterns += patterns(
   14.36 -        '',
   14.37 -        url(r'^wpimport/', include('wpimport.urls')),
   14.38 -        )
   14.39 +if appcheck.wpimport:
   14.40 +    urlpatterns += patterns('', url(r'^wpimport/', include('wpimport.urls')),)
   14.41  
   14.42 -if 'wbimport' in settings.INSTALLED_APPS:
   14.43 -    urlpatterns += patterns(
   14.44 -        '',
   14.45 -        url(r'^wbimport/', include('wbimport.urls')),
   14.46 -        )
   14.47 -
   14.48 -if 'debug' in settings.INSTALLED_APPS:
   14.49 -    urlpatterns += patterns(
   14.50 -        '',
   14.51 -        url('', include('debug.urls')),
   14.52 -        )
   14.53 +if appcheck.debug:
   14.54 +    urlpatterns += patterns('', url('', include('debug.urls')),)