help_text="Name of the organisation")
require_consent = models.BooleanField(null=False, blank=False, default=True)
- def __unicode__(self):
+ def __str__(self):
return self.orgname
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")
- def __unicode__(self):
+ def __str__(self):
return self.name
class ReCaptchaWidget(forms.widgets.Widget):
def render(self, name, value, attrs=None):
if settings.NOCAPTCHA:
- return u'Captcha disabled on this system'
+ return 'Captcha disabled on this system'
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):
if settings.NOCAPTCHA:
l = request.session['oauth_lastname'].lower()
if f and l:
for u in itertools.chain([
- u"{0}{1}".format(f, l[0]),
- u"{0}{1}".format(f[0], l),
- ], (u"{0}{1}{2}".format(f, l[0], n) for n in xrange(100))):
+ "{0}{1}".format(f, l[0]),
+ "{0}{1}".format(f[0], l),
+ ], ("{0}{1}{2}".format(f, l[0], n) for n in range(100))):
if not User.objects.filter(username=u[:30]).exists():
suggested_username = u[:30]
break
purge_urls = ('/community/contributors/', )
- def __unicode__(self):
+ def __str__(self):
return self.typename
class Meta:
send_notification = True
purge_urls = ('/community/contributors/', )
- def __unicode__(self):
+ def __str__(self):
return "%s %s" % (self.firstname, self.lastname)
class Meta:
def get_item_value(self, 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):
# 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)
def handle(self, *args, **options):
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):
# Generate an email and send it off
send_template_mail(settings.NOTIFICATION_FROM,
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")
- def __unicode__(self):
+ def __str__(self):
return self.versionstring
@property
verbose_name = 'Country'
verbose_name_plural = 'Countries'
- def __unicode__(self):\r
+ def __str__(self):
return self.name
class Meta:
ordering = ('name', )
- def __unicode__(self):
+ def __str__(self):
return self.name
class OrganisationType(models.Model):
typename = models.CharField(max_length=32, null=False, blank=False)
- def __unicode__(self):
+ def __str__(self):
return self.typename
send_notification = True
send_m2m_notification = True
- def __unicode__(self):
+ def __str__(self):
return self.name
class Meta:
if self.purgepattern:
varnish_purge(self.purgepattern)
- def __unicode__(self):
+ def __str__(self):
return self.internalname
url = models.URLField(null=False, blank=False)
posttime = models.DateTimeField(null=False, blank=False)
- def __unicode__(self):
+ def __str__(self):
return self.title
@property
if pieces[0] == 'ssh-dss':
raise ValidationError("For security reasons, ssh-dss keys are not supported")
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:
base64.b64decode(pieces[1])
except:
author = models.CharField(null=False, blank=False, max_length=100)
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])
class Meta:
@register.filter(is_safe=True)
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 False
x.startElement('url', {})
x.add_xml_element('loc', 'https://www.postgresql.org/%s' % urllib.quote(p[0]))
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]:
x.add_xml_element('lastmod', p[2].isoformat() + "Z")
x.endElement('url')
file1 = 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):
- return u"%s <-> %s" % (self.file1, self.file2)
+ def __str__(self):
+ return "%s <-> %s" % (self.file1, self.file2)
# XXX: needs a unique functional index as well, see the migration!
class Meta:
catname = models.CharField(max_length=100, null=False, blank=False)
blurb = models.TextField(null=False, blank=True)
- def __unicode__(self):
+ def __str__(self):
return self.catname
class Meta:
class LicenceType(models.Model):
typename = models.CharField(max_length=100, null=False, blank=False)
- def __unicode__(self):
+ def __str__(self):
return self.typename
class Meta:
send_notification = True
markdown_fields = ('description', )
- def __unicode__(self):
+ def __str__(self):
return self.name
def verify_submitter(self, user):
purge_urls = ('/applications-v2.xml', )
- def __unicode__(self):
+ def __str__(self):
return "%s %s %s" % (self.textid, self.version, self.platform)
class Meta:
# FIXME: when to expire the front page?
yield '/$'
- def __unicode__(self):
+ def __str__(self):
return "%s: %s" % (self.startdate, self.title)
def verify_submitter(self, user):
purge_urls = ('/about/featurematrix/', )
- def __unicode__(self):
+ def __str__(self):
return self.groupname
@property
purge_urls = ('/about/featurematrix/.*', )
- def __unicode__(self):
+ def __str__(self):
# To make it look good in the admin interface, just don't render it
return ''
def negid(self):
return -self.id
- def __unicode__(self):
+ def __str__(self):
return self.groupname
class Meta:
return self.shortdesc
return self.listname
- def __unicode__(self):
+ def __str__(self):
return self.listname
class Meta:
# separately from an antispam and delivery perspective.
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)
for a in articles:
# 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={
'status': statusstr,
})
name = models.CharField(max_length=32, null=False, blank=False)
description = models.CharField(max_length=200, null=False, blank=False)
- def __unicode__(self):
+ def __str__(self):
return self.name
class Meta:
# FIXME: when to expire the front page?
yield '/$'
- def __unicode__(self):
+ def __str__(self):
return "%s: %s" % (self.date, self.title)
def verify_submitter(self, user):
class ProfessionalServiceAdmin(PgwebAdmin):
- list_display = ('__unicode__', 'approved',)
+ list_display = ('__str__', 'approved',)
list_filter = ('approved',)
search_fields = ('org__name',)
def verify_submitter(self, user):
return (len(self.org.managers.filter(pk=user.pk)) == 1)
- def __unicode__(self):
+ def __str__(self):
return self.org.name
class Meta:
purge_urls = ('/community/user-groups/', )
send_notification = True
- def __unicode__(self):
+ def __str__(self):
return self.title
purge_urls = ('/about/quotesarchive/', '/$', )
- def __unicode__(self):
+ def __str__(self):
if len(self.quote) > 75:
return "%s..." % self.quote[:75]
else:
self.cvenumber = 100000 * int(m.groups(0)[0]) + int(m.groups(0)[1])
super(SecurityPatch, self).save(force_insert, force_update)
- def __unicode__(self):
+ def __str__(self):
return self.cve
@property
purge_urls = ('/about/servers/', '/about/sponsors/', )
- def __unicode__(self):
+ def __str__(self):
return self.typename
class Meta:
purge_urls = ('/about/sponsors/', '/about/servers/', )
- def __unicode__(self):
+ def __str__(self):
return self.name
class Meta:
purge_urls = ('/about/servers/', )
- def __unicode__(self):
+ def __str__(self):
return self.name
class Meta:
purge_urls = ('/community/survey', '/community/$')
- def __unicode__(self):
+ def __str__(self):
return self.question
@property
return None
return {
'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]
}
return ''
# 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):
if not fieldlist:
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):
if not hasattr(instance, '_stored_m2m'):
instance._stored_m2m = {}
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':
- 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()))
removed = instance._stored_m2m.get(f, set()).difference(newset)
subj = '{0} id {1} has been modified'.format(instance._meta.verbose_name, instance.id)
"%s by %s" % (subj, get_current_user()),
"The following values for {0} were changed:\n\n{1}\n{2}\n\n".format(
instance._meta.get_field(f).verbose_name,
- "\n".join([u"Added: %s" % a for a in added]),
- "\n".join([u"Removed: %s" % r for r in removed]),
+ "\n".join(["Added: %s" % a for a in added]),
+ "\n".join(["Removed: %s" % r for r in removed]),
))
if float(ver) < 11 and float(ver) > 0:
tidyopts['indent'] = 'no'
- contents = unicode(rawcontents, encoding)
+ contents = str(rawcontents, encoding)
tm = re_titlematch.search(contents)
if tm:
# Semi-hacked rot13, because the one used by mhonarc is broken.
# So we copy the brokenness here.
# This code is from MHonArc/ewhutil.pl, mrot13()
- _arot13_trans = dict(zip(map(ord,
- u'@ABCDEFGHIJKLMNOPQRSTUVWXYZ[abcdefghijklmnopqrstuvwxyz'),
- u'NOPQRSTUVWXYZ[@ABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm'))
+ _arot13_trans = dict(list(zip(list(map(ord,
+ '@ABCDEFGHIJKLMNOPQRSTUVWXYZ[abcdefghijklmnopqrstuvwxyz')),
+ 'NOPQRSTUVWXYZ[@ABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm')))
def almost_rot13(self, s):
- return unicode(s).translate(self._arot13_trans)
+ return str(s).translate(self._arot13_trans)
class RobotsParser(object):
# up and do a best-effort utf8.
def lossy_unicode(s):
try:
- return unicode(s, 'utf8')
+ return str(s, 'utf8')
except UnicodeDecodeError:
try:
- return unicode(s, 'latin1')
+ return str(s, 'latin1')
except UnicodeDecodeError:
- return unicode(s, 'utf8', 'replace')
+ return str(s, 'utf8', 'replace')