Changeset 162
- Timestamp:
- 10/14/07 18:47:20 (3 years ago)
- Files:
-
- trunk/apps/accounts/forms.py (modified) (1 diff)
- trunk/apps/accounts/models.py (modified) (1 diff)
- trunk/apps/blogs/feeds.py (modified) (3 diffs)
- trunk/apps/blogs/models.py (modified) (3 diffs)
- trunk/apps/doc/feeds.py (modified) (4 diffs)
- trunk/apps/doc/models.py (modified) (2 diffs)
- trunk/apps/doc/templates/doc/doc_base.html (modified) (2 diffs)
- trunk/apps/doc/views.py (modified) (3 diffs)
- trunk/apps/forums/models.py (modified) (4 diffs)
- trunk/apps/messages/models.py (modified) (2 diffs)
- trunk/apps/pages/models.py (modified) (2 diffs)
- trunk/vertical/comments/exceptions.py (modified) (3 diffs)
- trunk/vertical/comments/models.py (modified) (2 diffs)
- trunk/vertical/core/media/css/style.css (modified) (1 diff)
- trunk/vertical/core/protocols.py (modified) (3 diffs)
- trunk/vertical/core/validators.py (modified) (2 diffs)
- trunk/vertical/history/models.py (modified) (3 diffs)
- trunk/vertical/history/templatetags/lahak_history.py (modified) (1 diff)
- trunk/vertical/reference/models.py (modified) (1 diff)
- trunk/vertical/rest/postprocessors.py (modified) (1 diff)
- trunk/vertical/rest/preprocessors.py (modified) (4 diffs)
- trunk/vertical/rest/templatetags/lahak_rest.py (modified) (1 diff)
- trunk/vertical/tags/models.py (modified) (4 diffs)
- trunk/vertical/tags/views.py (modified) (2 diffs)
- trunk/vertical/uploads/models.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/apps/accounts/forms.py
r154 r162 1 1 from django import newforms as forms 2 2 from models import ATTRIBUTE_CHOICES 3 from django.utils.translation import gettext as _3 from django.utils.translation import ugettext as _ 4 4 5 5 class AttributeForm(forms.Form): trunk/apps/accounts/models.py
r152 r162 1 1 from django.db import models 2 2 from django.contrib.auth.models import User 3 from django.utils.translation import gettext_lazy as _3 from django.utils.translation import ugettext_lazy as _ 4 4 5 5 class Profile(models.Model): trunk/apps/blogs/feeds.py
r127 r162 23 23 from lahak.vertical.tags.models import TaggedItem 24 24 from lahak.vertical.core.feeds import LahakFeed 25 25 from django.utils.translation import ugettext as _ 26 26 27 27 class LatestEntries(LahakFeed): 28 28 """Syndication for all the blogs""" 29 29 30 title = (_("%s's blogs") % LahakFeed.site_name).decode('utf-8')30 title = _("%s's blogs") % LahakFeed.site_name 31 31 link = BLOGS_ROOT 32 description = (_("Updates from all the blogs at %s") % LahakFeed.site_name).decode('utf-8')32 description = _("Updates from all the blogs at %s") % LahakFeed.site_name 33 33 34 34 title_template = 'blogs/feed_all_title.html' … … 36 36 37 37 def items(self): 38 "for this item we need a different __str__ which includesthe blog name"38 "for this item we need to include the blog name" 39 39 return Entry.objects.filter(publish=True).order_by('-updated')[:10] 40 40 … … 57 57 58 58 def title(self, obj): 59 return obj.get_blog_title() .decode('utf-8')59 return obj.get_blog_title() 60 60 61 61 def description(self,obj): 62 62 desc = _("Updates from %(name)s's blog at %(site)s") % \ 63 63 {'name':obj.author.username, 'site':self.site_name } 64 return desc .decode('utf-8')64 return desc 65 65 66 66 def link(self, obj): trunk/apps/blogs/models.py
r149 r162 24 24 from django.core.validators import isSlug, isInteger, ValidationError 25 25 from django.shortcuts import get_object_or_404 26 from django.utils.translation import ugettext_lazy as _ 26 27 27 28 class BlogManager(models.Manager): … … 65 66 blog_id = self.id 66 67 67 return "%s%s/" % (BLOGS_ROOT, blog_id)68 return u"%s%s/" % (BLOGS_ROOT, blog_id) 68 69 69 def __ str__(self):70 def __unicode__(self): 70 71 return self.get_blog_title() 71 72 … … 124 125 return crumbs 125 126 126 def __ str__(self):127 def __unicode__(self): 127 128 return self.title 128 129 trunk/apps/doc/feeds.py
r127 r162 25 25 from lahak.vertical.core.feeds import LahakFeed, LahakChangeLogFeed 26 26 from settings import DOC_ROOT 27 from django.utils.translation import ugettext as _ 27 28 28 29 class AllLatestUpdates(LahakChangeLogFeed): … … 30 31 31 32 link = '%smeta/changes' % DOC_ROOT 32 title = ( _('Documents updates at %s') % LahakFeed.site_name ).decode('utf-8')33 description = ( _('Updates to all the documents at %s') % LahakFeed.site_name).decode('utf-8')33 title = _('Documents updates at %s') % LahakFeed.site_name 34 description = _('Updates to all the documents at %s') % LahakFeed.site_name 34 35 35 36 title_template = 'doc/doc_all_title.html' … … 42 43 class NewDocuments(LahakChangeLogFeed): 43 44 44 title = (_("New documents at %s") % LahakFeed.site_name).decode('utf-8')45 description = (_("Newly created documents at %s") % LahakFeed.site_name).decode('utf-8')45 title = _("New documents at %s") % LahakFeed.site_name 46 description = _("Newly created documents at %s") % LahakFeed.site_name 46 47 link = DOC_ROOT 47 48 … … 59 60 60 61 def title(self, obj): 61 return (_('%s updates') % obj.title).decode('utf-8')62 return _('%s updates') % obj.title 62 63 63 64 def description(self, obj): 64 65 d = { 'title': obj.title, 'site':self.site_name } 65 return (_('Updates to document %(title)s at %(site)s') % d).decode('utf-8')66 return _('Updates to document %(title)s at %(site)s') % d 66 67 67 68 def get_object(self, bits): trunk/apps/doc/models.py
r149 r162 20 20 21 21 from django.db import models 22 from django.utils.translation import gettext_lazy22 from django.utils.translation import ugettext_lazy as _ 23 23 from settings import DOC_ROOT, DOC_BREADCRUMB_ROOT 24 24 … … 65 65 return crumbs 66 66 67 def __ str__(self):67 def __unicode__(self): 68 68 return self.title 69 69 trunk/apps/doc/templates/doc/doc_base.html
r127 r162 1 {% load i18n lahak_comments %}{% extends "site_with_sidebar.html" %}1 {% load i18n lahak_comments lahak_general %}{% extends "site_with_sidebar.html" %} 2 2 {% block extra_head %} 3 3 <link rel="alternate" type="application/rss+xml" title="{% trans "All documents" %}" href="/doc/meta/feeds/all/"/> … … 23 23 <ul> 24 24 <li><a href="{{ vertical_object.get_absolute_url}}edit/">{% trans "Edit" %}</a></li> 25 {% if user.is_superuser %} 26 <li><a href="/objperms/edit/{% content_type_id vertical_object %}/{{ vertical_object.id}}/">{% trans "Permissions and locking" %}</a></li> 27 {% endif %} 25 28 </ul> 26 29 {% endif %} trunk/apps/doc/views.py
r126 r162 28 28 from lahak.vertical.core.validators import DoesNotEqual 29 29 from lahak.vertical.history.models import ChangeLog 30 30 from django.utils.translation import ugettext as _ 31 31 import urllib 32 32 … … 154 154 155 155 def all_documents(request): 156 documents = [ (d.title .decode('utf-8'), d.get_absolute_url()) for d in Document.objects.order_by('title') ]156 documents = [ (d.title, d.get_absolute_url()) for d in Document.objects.order_by('title') ] 157 157 158 158 context_dict = { … … 194 194 if request.GET: 195 195 for param in ('slug','title'): 196 context_dict[param] = request.GET.get(param, "") 197 196 context_dict[param] = request.GET.get(param, "").encode('utf-8') 197 198 print context_dict[param], type(context_dict[param]) 198 199 # pass the create url to the template, we don't want to calculate it 199 200 # there trunk/apps/forums/models.py
r141 r162 20 20 21 21 from django.db import models 22 from django.utils.translation import gettext_lazy22 from django.utils.translation import ugettext_lazy as _ 23 23 from lahak.vertical.core.validators import DoesNotEqual 24 24 from lahak.apps.forums.settings import FORUMS_ROOT, FORUMS_BREADCRUMB_ROOT … … 41 41 return (FORUMS_BREADCRUMB_ROOT, (self.get_absolute_url() , self.title) ) 42 42 43 def __ str__(self):43 def __unicode__(self): 44 44 return self.title 45 45 … … 48 48 slug = models.SlugField(unique=True) 49 49 title = models.CharField(maxlength=255, unique=True) 50 content = models.TextField( gettext_lazy("Forum description"), blank=True, null=True)50 content = models.TextField(_("Forum description"), blank=True, null=True) 51 51 group = models.ForeignKey(ForumsGroup) 52 52 position = models.PositiveIntegerField(default=0) … … 55 55 return '%s%s/' % (self.group.get_absolute_url(), self.slug) 56 56 57 def __ str__(self):57 def __unicode__(self): 58 58 return self.title 59 59 trunk/apps/messages/models.py
r141 r162 20 20 21 21 from django.db import models 22 from django.utils.translation import gettext_lazy as _22 from django.utils.translation import ugettext_lazy as _ 23 23 from django.contrib.auth.models import Group 24 24 … … 51 51 search_fields = ('title', 'content') 52 52 53 def __ str__(self):53 def __unicode__(self): 54 54 from django.utils.text import truncate_words 55 55 print truncate_words(self.content, 4) trunk/apps/pages/models.py
r131 r162 21 21 from django.db import models 22 22 from django.core import validators 23 from django.utils.translation import ugettext_lazy as _ 23 24 24 25 class Page(models.Model): … … 39 40 search_fields = ('url',) 40 41 41 def __ str__(self):42 def __unicode__(self): 42 43 return self.url 43 44 trunk/vertical/comments/exceptions.py
r42 r162 19 19 # vim: set ts=4 sw=4 et: 20 20 21 from django.utils.translation import ugettext as _ 22 21 23 class ObjectNotFoundException(Exception): 22 24 "Vertical object doesn't exist" … … 25 27 self.msg = _("Object not found") 26 28 27 def __ str__(self):29 def __unicode__(self): 28 30 return repr(self.msg) 29 31 … … 35 37 self.msg = _("Comments not allowed for %s") % vertical_object._meta.verbose_name_plural 36 38 37 def __ str__(self):39 def __unicode__(self): 38 40 return repr(self.msg) 39 41 trunk/vertical/comments/models.py
r144 r162 24 24 from django.contrib.auth.models import User 25 25 from lahak.vertical.comments.exceptions import * 26 from django.utils.translation import ugettext_lazy as _ 26 27 27 28 class CommentsRootManager(models.Manager): … … 129 130 return _("Anonymous") 130 131 131 def __ str__(self):132 def __unicode__(self): 132 133 return self.title 133 134 trunk/vertical/core/media/css/style.css
r148 r162 27 27 28 28 .content_inner { padding: 5pt; border:1px solid #c0c0c0; margin: 5pt; background: #ffffff;min-height:350px; height: auto !important; height:300px;} 29 29 .content_without_sidebar { margin-right: 50px; padding-top: 20px; min-height: 300px; } 30 30 input, textarea { border : 1px solid #6d99b6; } 31 31 input[type='checkbox'] { border: none;} trunk/vertical/core/protocols.py
r149 r162 25 25 import re 26 26 27 PROTOCOL_SYNTAX= '|%s|%s|'27 PROTOCOL_SYNTAX=u'|%s|%s|' 28 28 29 29 class Protocols(object): … … 42 42 # do we have a name in the the protocol, if not, fallback to 43 43 # verbose_name 44 name = model.LahakMeta.protocol.get('name',None) or model._meta.verbose_name44 name = model.LahakMeta.protocol.get('name',None) or unicode(model._meta.verbose_name) 45 45 self.protocols[name] = model 46 47 protocol_expression = r'(\|(%s)\|\s*(.*?)\s*\|)' % '|'.join(self.protocols.keys() ) 48 self.regexp = re.compile(protocol_expression) 46 protocol_expression = ur'(\|(%s)\|\s*(.*?)\s*\|)' % '|'.join(self.protocols.keys() ) 47 self.regexp = re.compile(protocol_expression, re.UNICODE) 49 48 50 49 def get_protocols(self): … … 88 87 label = get_protocol_display(obj) 89 88 90 if type(label) is unicode:91 label = label.encode('utf-8')92 93 89 return PROTOCOL_SYNTAX % (name, label) trunk/vertical/core/validators.py
r2 r162 19 19 # vim: set ts=4 sw=4 et: 20 20 21 from django.utils.translation import gettext_lazy21 from django.utils.translation import ugettext_lazy 22 22 from django.core.validators import ValidationError 23 23 … … 30 30 def __call__(self, field_data, all_data): 31 31 if field_data == self.value: 32 raise ValidationError( gettext_lazy("This value can't be %s") % self.value)32 raise ValidationError(ugettext_lazy("This value can't be %s") % self.value) trunk/vertical/history/models.py
r144 r162 110 110 change_type = models.CharField(maxlength=1, choices=CHANGE_TYPES, db_index=True) 111 111 object = models.TextField() 112 object_dict = models.TextField() 112 113 comment = models.CharField(maxlength=255, blank=True) 113 114 stable = models.BooleanField(default=False) … … 129 130 ) 130 131 131 list_display = ('__ str__', 'user', 'change_type','comment', 'content_type', 'change_time', )132 list_display = ('__unicode__', 'user', 'change_type','comment', 'content_type', 'change_time', ) 132 133 133 def __ str__(self):134 return str(self.get_object())134 def __unicode__(self): 135 return unicode(self.get_object()) 135 136 136 137 def get_object(self): 137 138 """ Returns unpickled object. """ 138 return Pickle.loads(self.object) 139 the_model = self.content_type.model_class() 140 return the_model(**Pickle.loads(str(self.object))) 139 141 140 142 def get_rev_num(self): … … 217 219 218 220 try: 219 log.object = Pickle.dumps(instance , protocol=0)221 log.object = Pickle.dumps(instance.__dict__) 220 222 log.user = get_current_user() 221 223 log.address = get_remote_address() trunk/vertical/history/templatetags/lahak_history.py
r72 r162 23 23 from lahak.vertical.history.models import ChangeLog 24 24 from difflib import HtmlDiff 25 25 from django.utils.translation import ugettext as _ 26 26 register = template.Library() 27 27 trunk/vertical/reference/models.py
r146 r162 21 21 from django.db import models 22 22 from django.dispatch import dispatcher 23 from django.utils.translation import gettext_lazy as _23 from django.utils.translation import ugettext_lazy as _ 24 24 from django.contrib.contenttypes.models import ContentType 25 25 from django.contrib.contenttypes import generic trunk/vertical/rest/postprocessors.py
r58 r162 27 27 for tr in AdmonitionsPreProcessor.translations: 28 28 content = content.replace( r'admonition-title">%s' % tr[1], 29 r'admonition-title">%s' % tr[0] .decode('utf-8'))29 r'admonition-title">%s' % tr[0] ) 30 30 31 31 return content trunk/vertical/rest/preprocessors.py
r144 r162 24 24 from django.db.models.base import ObjectDoesNotExist 25 25 import urllib, re 26 from django.utils.translation import ugettext as _ 26 27 27 28 class ProtocolsPreProcessor(object): … … 50 51 new_path = the_model.LahakMeta.protocol.get('new_path', None) 51 52 if new_path: 52 content = content.replace(match[0], r"`%s <%s%s>`_" % ( match[2], new_path, urllib.quote_plus( match[2] )) )53 content = content.replace(match[0], r"`%s <%s%s>`_" % ( match[2], new_path, urllib.quote_plus( match[2].encode('utf-8') )) ) 53 54 else: 54 55 # we don't want to get stuck with the vertical bars, as … … 113 114 # since image params are not translatable by reST, will subst them here 114 115 115 # utf-8 in templates passed via filter might give us problems, so let's 116 # conver if needed 117 if type(content) is unicode: 118 for tr in self.translations: 119 content = content.replace( ':%s:' % tr[0].decode('utf-8'), ':%s:' % tr[1]) 120 else: 121 for tr in self.translations: 122 content = content.replace( ':%s:' % tr[0], ':%s:' % tr[1]) 116 for tr in self.translations: 117 content = content.replace( ':%s:' % tr[0], ':%s:' % tr[1]) 123 118 return content 124 119 … … 137 132 138 133 def __call__(self, content): 139 # utf-8 in templates passed via filter might give us problems, so let's 140 # conver if needed 141 if type(content) is unicode: 142 for tr in self.translations: 143 content = content.replace( ':%s:' % tr[0].decode('utf-8'), ':%s:' % tr[1]) 144 else: 145 for tr in self.translations: 146 content = content.replace( '.. %s::' % tr[0], '.. admonition:: %s' % tr[1]) 134 for tr in self.translations: 135 content = content.replace( '.. %s::' % tr[0], '.. admonition:: %s' % tr[1]) 147 136 return content 148 137 trunk/vertical/rest/templatetags/lahak_rest.py
r158 r162 32 32 """ Return the 1st n child elements of parse"document", 33 33 used mainly for feeds """ 34 35 # problems with parseString and unicode, we need to encode 36 # it as utf-8 34 37 processed = lahak_rest(value).encode('utf-8') 35 38 trunk/vertical/tags/models.py
r144 r162 26 26 from settings import ROOT, BREADCRUMB_ROOT 27 27 from lahak.vertical.core.validators import DoesNotEqual 28 from django.utils.translation import ugettext_lazy as _ 28 29 29 30 class Tag(models.Model): … … 39 40 return '/tags/%s/' % self.slug 40 41 41 def __ str__(self):42 return '%s, %s' % (self.slug, self.name)42 def __unicode__(self): 43 return u'%s, %s' % (self.slug, self.name) 43 44 44 45 … … 87 88 def get_tags_strings(self, item): 88 89 "Get the tags names as a unicode string list. Usually used for feed categories" 89 return [tagged_item.tag.name .decode('utf8')for tagged_item in self.get_tags(item)]90 return [tagged_item.tag.name for tagged_item in self.get_tags(item)] 90 91 91 92 … … 101 102 unique_together = ( ('tag', 'content_type', 'object_id'), ) 102 103 103 def __ str__(self):104 return "%s, %s: %s" % (self.content_type.name, self.object_id, self.tag.slug)104 def __unicode__(self): 105 return u"%s, %s: %s" % (self.content_type.name, self.object_id, self.tag.slug) 105 106 trunk/vertical/tags/views.py
r157 r162 170 170 object_tags = TaggedItem.objects.filter(content_type=ctype, object_id=int(object_id)) 171 171 172 current_tags = [ (tagged_item.tag.id, tagged_item.tag.slug, unicode(cgi.escape(tagged_item.tag.name),'utf-8'), urllib.quote(tagged_item.tag.get_absolute_url())) for tagged_item in object_tags ]172 current_tags = [ (tagged_item.tag.id, tagged_item.tag.slug, tagged_item.tag.name, urllib.quote(tagged_item.tag.get_absolute_url())) for tagged_item in object_tags ] 173 173 174 174 if current_tags: … … 177 177 query_set = Tag.objects.all() 178 178 179 available_tags = [ (tag.id, tag.slug, unicode(cgi.escape(tag.name),'utf-8'), urllib.quote(tag.get_absolute_url()) ) for tag in query_set.order_by('name') ]179 available_tags = [ (tag.id, tag.slug, tag.name, urllib.quote(tag.get_absolute_url()) ) for tag in query_set.order_by('name') ] 180 180 181 181 return HttpResponse(simplejson.dumps({'selected':current_tags, 'available':available_tags }, ensure_ascii=False)) trunk/vertical/uploads/models.py
r144 r162 22 22 from django.contrib.contenttypes.models import ContentType 23 23 from django.contrib.contenttypes import generic 24 from lahak.vertical.core.db import AutoImageField 24 from lahak.vertical.core.db import AutoImageField, AutoFileField 25 25 26 26 class ImageManager(models.Manager): … … 33 33 34 34 class Image(models.Model): 35 """Generic uploaded images mod ule"""35 """Generic uploaded images model""" 36 36 37 37 content_type = models.ForeignKey(ContentType) … … 47 47 objects = ImageManager() 48 48 49 class Audio(models.Model): 50 """Generic uploaded audio model""" 51 52 content_type = models.ForeignKey(ContentType) 53 parent = generic.GenericForeignKey() 54 object_id = models.PositiveIntegerField(_('object ID')) 55 56 audio = AutoFileField( ) 57 58 comment = models.CharField(null=True,blank=True,maxlength=200)
