mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-13 13:12:42 +00:00
Generic unicode updates
This commit is contained in:
@ -7,7 +7,7 @@ class CommunityAuthOrg(models.Model):
|
|||||||
help_text="Name of the organisation")
|
help_text="Name of the organisation")
|
||||||
require_consent = models.BooleanField(null=False, blank=False, default=True)
|
require_consent = models.BooleanField(null=False, blank=False, default=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.orgname
|
return self.orgname
|
||||||
|
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ class CommunityAuthSite(models.Model):
|
|||||||
cooloff_hours = models.IntegerField(null=False, blank=False, default=0,
|
cooloff_hours = models.IntegerField(null=False, blank=False, default=0,
|
||||||
help_text="Number of hours a user must have existed in the systems before allowed to log in to this site")
|
help_text="Number of hours a user must have existed in the systems before allowed to log in to this site")
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ log = logging.getLogger(__name__)
|
|||||||
class ReCaptchaWidget(forms.widgets.Widget):
|
class ReCaptchaWidget(forms.widgets.Widget):
|
||||||
def render(self, name, value, attrs=None):
|
def render(self, name, value, attrs=None):
|
||||||
if settings.NOCAPTCHA:
|
if settings.NOCAPTCHA:
|
||||||
return u'Captcha disabled on this system'
|
return 'Captcha disabled on this system'
|
||||||
log.info("Generated captcha")
|
log.info("Generated captcha")
|
||||||
return mark_safe(u'<div class="g-recaptcha" data-sitekey="{0}"></div>'.format(settings.RECAPTCHA_SITE_KEY))
|
return mark_safe('<div class="g-recaptcha" data-sitekey="{0}"></div>'.format(settings.RECAPTCHA_SITE_KEY))
|
||||||
|
|
||||||
def value_from_datadict(self, data, files, name):
|
def value_from_datadict(self, data, files, name):
|
||||||
if settings.NOCAPTCHA:
|
if settings.NOCAPTCHA:
|
||||||
|
@ -428,9 +428,9 @@ def signup_oauth(request):
|
|||||||
l = request.session['oauth_lastname'].lower()
|
l = request.session['oauth_lastname'].lower()
|
||||||
if f and l:
|
if f and l:
|
||||||
for u in itertools.chain([
|
for u in itertools.chain([
|
||||||
u"{0}{1}".format(f, l[0]),
|
"{0}{1}".format(f, l[0]),
|
||||||
u"{0}{1}".format(f[0], l),
|
"{0}{1}".format(f[0], l),
|
||||||
], (u"{0}{1}{2}".format(f, l[0], n) for n in xrange(100))):
|
], ("{0}{1}{2}".format(f, l[0], n) for n in range(100))):
|
||||||
if not User.objects.filter(username=u[:30]).exists():
|
if not User.objects.filter(username=u[:30]).exists():
|
||||||
suggested_username = u[:30]
|
suggested_username = u[:30]
|
||||||
break
|
break
|
||||||
|
@ -11,7 +11,7 @@ class ContributorType(models.Model):
|
|||||||
|
|
||||||
purge_urls = ('/community/contributors/', )
|
purge_urls = ('/community/contributors/', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.typename
|
return self.typename
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -32,7 +32,7 @@ class Contributor(models.Model):
|
|||||||
send_notification = True
|
send_notification = True
|
||||||
purge_urls = ('/community/contributors/', )
|
purge_urls = ('/community/contributors/', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return "%s %s" % (self.firstname, self.lastname)
|
return "%s %s" % (self.firstname, self.lastname)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -16,11 +16,11 @@ class UserLookup(ModelLookup):
|
|||||||
|
|
||||||
def get_item_value(self, item):
|
def get_item_value(self, item):
|
||||||
# Display for currently selected item
|
# Display for currently selected item
|
||||||
return u"%s (%s)" % (item.username, item.get_full_name())
|
return "%s (%s)" % (item.username, item.get_full_name())
|
||||||
|
|
||||||
def get_item_label(self, item):
|
def get_item_label(self, item):
|
||||||
# Display for choice listings
|
# Display for choice listings
|
||||||
return u"%s (%s)" % (item.username, item.get_full_name())
|
return "%s (%s)" % (item.username, item.get_full_name())
|
||||||
|
|
||||||
|
|
||||||
registry.register(UserLookup)
|
registry.register(UserLookup)
|
||||||
|
@ -20,7 +20,7 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
counts = [{'name': unicode(x['name']), 'count': len(x['entries'])} for x in get_all_pending_moderations()]
|
counts = [{'name': str(x['name']), 'count': len(x['entries'])} for x in get_all_pending_moderations()]
|
||||||
if len(counts):
|
if len(counts):
|
||||||
# Generate an email and send it off
|
# Generate an email and send it off
|
||||||
send_template_mail(settings.NOTIFICATION_FROM,
|
send_template_mail(settings.NOTIFICATION_FROM,
|
||||||
|
@ -26,7 +26,7 @@ class Version(models.Model):
|
|||||||
firstreldate = models.DateField(null=False, blank=False, help_text="The date of the .0 release in this tree")
|
firstreldate = models.DateField(null=False, blank=False, help_text="The date of the .0 release in this tree")
|
||||||
eoldate = models.DateField(null=False, blank=False, help_text="The final release date for this tree")
|
eoldate = models.DateField(null=False, blank=False, help_text="The final release date for this tree")
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.versionstring
|
return self.versionstring
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -93,7 +93,7 @@ class Country(models.Model):
|
|||||||
verbose_name = 'Country'
|
verbose_name = 'Country'
|
||||||
verbose_name_plural = 'Countries'
|
verbose_name_plural = 'Countries'
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
@ -110,14 +110,14 @@ class Language(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('name', )
|
ordering = ('name', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
class OrganisationType(models.Model):
|
class OrganisationType(models.Model):
|
||||||
typename = models.CharField(max_length=32, null=False, blank=False)
|
typename = models.CharField(max_length=32, null=False, blank=False)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.typename
|
return self.typename
|
||||||
|
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ class Organisation(models.Model):
|
|||||||
send_notification = True
|
send_notification = True
|
||||||
send_m2m_notification = True
|
send_m2m_notification = True
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -152,7 +152,7 @@ class ImportedRSSFeed(models.Model):
|
|||||||
if self.purgepattern:
|
if self.purgepattern:
|
||||||
varnish_purge(self.purgepattern)
|
varnish_purge(self.purgepattern)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.internalname
|
return self.internalname
|
||||||
|
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ class ImportedRSSItem(models.Model):
|
|||||||
url = models.URLField(null=False, blank=False)
|
url = models.URLField(null=False, blank=False)
|
||||||
posttime = models.DateTimeField(null=False, blank=False)
|
posttime = models.DateTimeField(null=False, blank=False)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -186,7 +186,7 @@ def validate_sshkey(key):
|
|||||||
if pieces[0] == 'ssh-dss':
|
if pieces[0] == 'ssh-dss':
|
||||||
raise ValidationError("For security reasons, ssh-dss keys are not supported")
|
raise ValidationError("For security reasons, ssh-dss keys are not supported")
|
||||||
if pieces[0] not in _valid_keytypes:
|
if pieces[0] not in _valid_keytypes:
|
||||||
raise ValidationError(u"Only keys of types {0} are supported, not {1}.".format(", ".join(_valid_keytypes), pieces[0]))
|
raise ValidationError("Only keys of types {0} are supported, not {1}.".format(", ".join(_valid_keytypes), pieces[0]))
|
||||||
try:
|
try:
|
||||||
base64.b64decode(pieces[1])
|
base64.b64decode(pieces[1])
|
||||||
except:
|
except:
|
||||||
@ -210,7 +210,7 @@ class ModerationNotification(models.Model):
|
|||||||
author = models.CharField(null=False, blank=False, max_length=100)
|
author = models.CharField(null=False, blank=False, max_length=100)
|
||||||
date = models.DateTimeField(null=False, blank=False, auto_now=True)
|
date = models.DateTimeField(null=False, blank=False, auto_now=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return "%s id %s (%s): %s" % (self.objecttype, self.objectid, self.date, self.text[:50])
|
return "%s id %s (%s): %s" % (self.objecttype, self.objectid, self.date, self.text[:50])
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -38,7 +38,7 @@ def ismultiplecheckboxes(obj):
|
|||||||
|
|
||||||
@register.filter(is_safe=True)
|
@register.filter(is_safe=True)
|
||||||
def isrequired_error(obj):
|
def isrequired_error(obj):
|
||||||
if obj.errors and obj.errors[0] == u"This field is required.":
|
if obj.errors and obj.errors[0] == "This field is required.":
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ def _make_sitemap(pagelist):
|
|||||||
x.startElement('url', {})
|
x.startElement('url', {})
|
||||||
x.add_xml_element('loc', 'https://www.postgresql.org/%s' % urllib.quote(p[0]))
|
x.add_xml_element('loc', 'https://www.postgresql.org/%s' % urllib.quote(p[0]))
|
||||||
if len(p) > 1 and p[1]:
|
if len(p) > 1 and p[1]:
|
||||||
x.add_xml_element('priority', unicode(p[1]))
|
x.add_xml_element('priority', str(p[1]))
|
||||||
if len(p) > 2 and p[2]:
|
if len(p) > 2 and p[2]:
|
||||||
x.add_xml_element('lastmod', p[2].isoformat() + "Z")
|
x.add_xml_element('lastmod', p[2].isoformat() + "Z")
|
||||||
x.endElement('url')
|
x.endElement('url')
|
||||||
|
@ -26,8 +26,8 @@ class DocPageAlias(models.Model):
|
|||||||
file1 = models.CharField(max_length=64, null=False, blank=False, unique=True)
|
file1 = models.CharField(max_length=64, null=False, blank=False, unique=True)
|
||||||
file2 = models.CharField(max_length=64, null=False, blank=False, unique=True)
|
file2 = models.CharField(max_length=64, null=False, blank=False, unique=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return u"%s <-> %s" % (self.file1, self.file2)
|
return "%s <-> %s" % (self.file1, self.file2)
|
||||||
|
|
||||||
# XXX: needs a unique functional index as well, see the migration!
|
# XXX: needs a unique functional index as well, see the migration!
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -7,7 +7,7 @@ class Category(models.Model):
|
|||||||
catname = models.CharField(max_length=100, null=False, blank=False)
|
catname = models.CharField(max_length=100, null=False, blank=False)
|
||||||
blurb = models.TextField(null=False, blank=True)
|
blurb = models.TextField(null=False, blank=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.catname
|
return self.catname
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -17,7 +17,7 @@ class Category(models.Model):
|
|||||||
class LicenceType(models.Model):
|
class LicenceType(models.Model):
|
||||||
typename = models.CharField(max_length=100, null=False, blank=False)
|
typename = models.CharField(max_length=100, null=False, blank=False)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.typename
|
return self.typename
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -38,7 +38,7 @@ class Product(models.Model):
|
|||||||
send_notification = True
|
send_notification = True
|
||||||
markdown_fields = ('description', )
|
markdown_fields = ('description', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def verify_submitter(self, user):
|
def verify_submitter(self, user):
|
||||||
@ -96,7 +96,7 @@ class StackBuilderApp(models.Model):
|
|||||||
|
|
||||||
purge_urls = ('/applications-v2.xml', )
|
purge_urls = ('/applications-v2.xml', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return "%s %s %s" % (self.textid, self.version, self.platform)
|
return "%s %s %s" % (self.textid, self.version, self.platform)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -32,7 +32,7 @@ class Event(models.Model):
|
|||||||
# FIXME: when to expire the front page?
|
# FIXME: when to expire the front page?
|
||||||
yield '/$'
|
yield '/$'
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return "%s: %s" % (self.startdate, self.title)
|
return "%s: %s" % (self.startdate, self.title)
|
||||||
|
|
||||||
def verify_submitter(self, user):
|
def verify_submitter(self, user):
|
||||||
|
@ -15,7 +15,7 @@ class FeatureGroup(models.Model):
|
|||||||
|
|
||||||
purge_urls = ('/about/featurematrix/', )
|
purge_urls = ('/about/featurematrix/', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.groupname
|
return self.groupname
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -49,7 +49,7 @@ class Feature(models.Model):
|
|||||||
|
|
||||||
purge_urls = ('/about/featurematrix/.*', )
|
purge_urls = ('/about/featurematrix/.*', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
# To make it look good in the admin interface, just don't render it
|
# To make it look good in the admin interface, just don't render it
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class MailingListGroup(models.Model):
|
|||||||
def negid(self):
|
def negid(self):
|
||||||
return -self.id
|
return -self.id
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.groupname
|
return self.groupname
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -33,7 +33,7 @@ class MailingList(models.Model):
|
|||||||
return self.shortdesc
|
return self.shortdesc
|
||||||
return self.listname
|
return self.listname
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.listname
|
return self.listname
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -11,5 +11,5 @@ class QueuedMail(models.Model):
|
|||||||
# separately from an antispam and delivery perspective.
|
# separately from an antispam and delivery perspective.
|
||||||
usergenerated = models.BooleanField(null=False, blank=False, default=False)
|
usergenerated = models.BooleanField(null=False, blank=False, default=False)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return "%s: %s -> %s" % (self.pk, self.sender, self.receiver)
|
return "%s: %s -> %s" % (self.pk, self.sender, self.receiver)
|
||||||
|
@ -36,7 +36,7 @@ class Command(BaseCommand):
|
|||||||
|
|
||||||
for a in articles:
|
for a in articles:
|
||||||
# We hardcode 30 chars for the URL shortener. And then 10 to cover the intro and spacing.
|
# We hardcode 30 chars for the URL shortener. And then 10 to cover the intro and spacing.
|
||||||
statusstr = u"News: {0} {1}/about/news/{2}/".format(a.title[:140 - 40], settings.SITE_ROOT, a.id)
|
statusstr = "News: {0} {1}/about/news/{2}/".format(a.title[:140 - 40], settings.SITE_ROOT, a.id)
|
||||||
r = tw.post('https://api.twitter.com/1.1/statuses/update.json', data={
|
r = tw.post('https://api.twitter.com/1.1/statuses/update.json', data={
|
||||||
'status': statusstr,
|
'status': statusstr,
|
||||||
})
|
})
|
||||||
|
@ -8,7 +8,7 @@ class NewsTag(models.Model):
|
|||||||
name = models.CharField(max_length=32, null=False, blank=False)
|
name = models.CharField(max_length=32, null=False, blank=False)
|
||||||
description = models.CharField(max_length=200, null=False, blank=False)
|
description = models.CharField(max_length=200, null=False, blank=False)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -36,7 +36,7 @@ class NewsArticle(models.Model):
|
|||||||
# FIXME: when to expire the front page?
|
# FIXME: when to expire the front page?
|
||||||
yield '/$'
|
yield '/$'
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return "%s: %s" % (self.date, self.title)
|
return "%s: %s" % (self.date, self.title)
|
||||||
|
|
||||||
def verify_submitter(self, user):
|
def verify_submitter(self, user):
|
||||||
|
@ -5,7 +5,7 @@ from .models import ProfessionalService
|
|||||||
|
|
||||||
|
|
||||||
class ProfessionalServiceAdmin(PgwebAdmin):
|
class ProfessionalServiceAdmin(PgwebAdmin):
|
||||||
list_display = ('__unicode__', 'approved',)
|
list_display = ('__str__', 'approved',)
|
||||||
list_filter = ('approved',)
|
list_filter = ('approved',)
|
||||||
search_fields = ('org__name',)
|
search_fields = ('org__name',)
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ class ProfessionalService(models.Model):
|
|||||||
def verify_submitter(self, user):
|
def verify_submitter(self, user):
|
||||||
return (len(self.org.managers.filter(pk=user.pk)) == 1)
|
return (len(self.org.managers.filter(pk=user.pk)) == 1)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.org.name
|
return self.org.name
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -16,5 +16,5 @@ class PUG(models.Model):
|
|||||||
purge_urls = ('/community/user-groups/', )
|
purge_urls = ('/community/user-groups/', )
|
||||||
send_notification = True
|
send_notification = True
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
@ -12,7 +12,7 @@ class Quote(models.Model):
|
|||||||
|
|
||||||
purge_urls = ('/about/quotesarchive/', '/$', )
|
purge_urls = ('/about/quotesarchive/', '/$', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
if len(self.quote) > 75:
|
if len(self.quote) > 75:
|
||||||
return "%s..." % self.quote[:75]
|
return "%s..." % self.quote[:75]
|
||||||
else:
|
else:
|
||||||
|
@ -86,7 +86,7 @@ class SecurityPatch(models.Model):
|
|||||||
self.cvenumber = 100000 * int(m.groups(0)[0]) + int(m.groups(0)[1])
|
self.cvenumber = 100000 * int(m.groups(0)[0]) + int(m.groups(0)[1])
|
||||||
super(SecurityPatch, self).save(force_insert, force_update)
|
super(SecurityPatch, self).save(force_insert, force_update)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.cve
|
return self.cve
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -11,7 +11,7 @@ class SponsorType(models.Model):
|
|||||||
|
|
||||||
purge_urls = ('/about/servers/', '/about/sponsors/', )
|
purge_urls = ('/about/servers/', '/about/sponsors/', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.typename
|
return self.typename
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -27,7 +27,7 @@ class Sponsor(models.Model):
|
|||||||
|
|
||||||
purge_urls = ('/about/sponsors/', '/about/servers/', )
|
purge_urls = ('/about/sponsors/', '/about/servers/', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -45,7 +45,7 @@ class Server(models.Model):
|
|||||||
|
|
||||||
purge_urls = ('/about/servers/', )
|
purge_urls = ('/about/servers/', )
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -30,7 +30,7 @@ class Survey(models.Model):
|
|||||||
|
|
||||||
purge_urls = ('/community/survey', '/community/$')
|
purge_urls = ('/community/survey', '/community/$')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return self.question
|
return self.question
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -14,7 +14,7 @@ def _get_unapproved_list(objecttype):
|
|||||||
return None
|
return None
|
||||||
return {
|
return {
|
||||||
'name': objects[0]._meta.verbose_name_plural,
|
'name': objects[0]._meta.verbose_name_plural,
|
||||||
'entries': [{'url': '/admin/%s/%s/%s/' % (x._meta.app_label, x._meta.model_name, x.pk), 'title': unicode(x)} for x in objects]
|
'entries': [{'url': '/admin/%s/%s/%s/' % (x._meta.app_label, x._meta.model_name, x.pk), 'title': str(x)} for x in objects]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ def _get_attr_value(obj, fieldname):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
# Return the value, or an empty tring if it's NULL (migrated records)
|
# Return the value, or an empty tring if it's NULL (migrated records)
|
||||||
return unicode(getattr(obj, fieldname)) or ''
|
return str(getattr(obj, fieldname)) or ''
|
||||||
|
|
||||||
|
|
||||||
def _get_full_text_representation(obj):
|
def _get_full_text_representation(obj):
|
||||||
@ -75,7 +75,7 @@ def _get_full_text_representation(obj):
|
|||||||
if not fieldlist:
|
if not fieldlist:
|
||||||
return "This object does not know how to express itself."
|
return "This object does not know how to express itself."
|
||||||
|
|
||||||
return "\n".join([u'%s: %s' % (n, _get_attr_value(obj, n)) for n in fieldlist])
|
return "\n".join(['%s: %s' % (n, _get_attr_value(obj, n)) for n in fieldlist])
|
||||||
|
|
||||||
|
|
||||||
def _get_notification_text(obj):
|
def _get_notification_text(obj):
|
||||||
@ -138,9 +138,9 @@ def my_m2m_changed_handler(sender, **kwargs):
|
|||||||
if not hasattr(instance, '_stored_m2m'):
|
if not hasattr(instance, '_stored_m2m'):
|
||||||
instance._stored_m2m = {}
|
instance._stored_m2m = {}
|
||||||
if kwargs['action'] == 'pre_clear':
|
if kwargs['action'] == 'pre_clear':
|
||||||
instance._stored_m2m[f] = set([unicode(t) for t in getattr(instance, f).all()])
|
instance._stored_m2m[f] = set([str(t) for t in getattr(instance, f).all()])
|
||||||
elif kwargs['action'] == 'post_add':
|
elif kwargs['action'] == 'post_add':
|
||||||
newset = set([unicode(t) for t in getattr(instance, f).all()])
|
newset = set([str(t) for t in getattr(instance, f).all()])
|
||||||
added = newset.difference(instance._stored_m2m.get(f, set()))
|
added = newset.difference(instance._stored_m2m.get(f, set()))
|
||||||
removed = instance._stored_m2m.get(f, set()).difference(newset)
|
removed = instance._stored_m2m.get(f, set()).difference(newset)
|
||||||
subj = '{0} id {1} has been modified'.format(instance._meta.verbose_name, instance.id)
|
subj = '{0} id {1} has been modified'.format(instance._meta.verbose_name, instance.id)
|
||||||
@ -150,8 +150,8 @@ def my_m2m_changed_handler(sender, **kwargs):
|
|||||||
"%s by %s" % (subj, get_current_user()),
|
"%s by %s" % (subj, get_current_user()),
|
||||||
"The following values for {0} were changed:\n\n{1}\n{2}\n\n".format(
|
"The following values for {0} were changed:\n\n{1}\n{2}\n\n".format(
|
||||||
instance._meta.get_field(f).verbose_name,
|
instance._meta.get_field(f).verbose_name,
|
||||||
"\n".join([u"Added: %s" % a for a in added]),
|
"\n".join(["Added: %s" % a for a in added]),
|
||||||
"\n".join([u"Removed: %s" % r for r in removed]),
|
"\n".join(["Removed: %s" % r for r in removed]),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ def load_doc_file(filename, f):
|
|||||||
if float(ver) < 11 and float(ver) > 0:
|
if float(ver) < 11 and float(ver) > 0:
|
||||||
tidyopts['indent'] = 'no'
|
tidyopts['indent'] = 'no'
|
||||||
|
|
||||||
contents = unicode(rawcontents, encoding)
|
contents = str(rawcontents, encoding)
|
||||||
|
|
||||||
tm = re_titlematch.search(contents)
|
tm = re_titlematch.search(contents)
|
||||||
if tm:
|
if tm:
|
||||||
|
@ -129,12 +129,12 @@ class ArchivesParser(object):
|
|||||||
# Semi-hacked rot13, because the one used by mhonarc is broken.
|
# Semi-hacked rot13, because the one used by mhonarc is broken.
|
||||||
# So we copy the brokenness here.
|
# So we copy the brokenness here.
|
||||||
# This code is from MHonArc/ewhutil.pl, mrot13()
|
# This code is from MHonArc/ewhutil.pl, mrot13()
|
||||||
_arot13_trans = dict(zip(map(ord,
|
_arot13_trans = dict(list(zip(list(map(ord,
|
||||||
u'@ABCDEFGHIJKLMNOPQRSTUVWXYZ[abcdefghijklmnopqrstuvwxyz'),
|
'@ABCDEFGHIJKLMNOPQRSTUVWXYZ[abcdefghijklmnopqrstuvwxyz')),
|
||||||
u'NOPQRSTUVWXYZ[@ABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm'))
|
'NOPQRSTUVWXYZ[@ABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm')))
|
||||||
|
|
||||||
def almost_rot13(self, s):
|
def almost_rot13(self, s):
|
||||||
return unicode(s).translate(self._arot13_trans)
|
return str(s).translate(self._arot13_trans)
|
||||||
|
|
||||||
|
|
||||||
class RobotsParser(object):
|
class RobotsParser(object):
|
||||||
@ -168,9 +168,9 @@ class RobotsParser(object):
|
|||||||
# up and do a best-effort utf8.
|
# up and do a best-effort utf8.
|
||||||
def lossy_unicode(s):
|
def lossy_unicode(s):
|
||||||
try:
|
try:
|
||||||
return unicode(s, 'utf8')
|
return str(s, 'utf8')
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
try:
|
try:
|
||||||
return unicode(s, 'latin1')
|
return str(s, 'latin1')
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
return unicode(s, 'utf8', 'replace')
|
return str(s, 'utf8', 'replace')
|
||||||
|
Reference in New Issue
Block a user