summaryrefslogtreecommitdiff
path: root/ishtar_common/forms_common.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-02-27 20:44:52 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-06-17 13:21:27 +0200
commit86c03a98d11e93880b4568776e0939113a92a707 (patch)
treee07ad2e91e2544f7b2d61e8f3f653fdda26bfd52 /ishtar_common/forms_common.py
parent52f442699a72ff5d0341a7d15d5b966a3cc2bd60 (diff)
downloadIshtar-86c03a98d11e93880b4568776e0939113a92a707.tar.bz2
Ishtar-86c03a98d11e93880b4568776e0939113a92a707.zip
Migrate to python 3 - Clean old migrations and some old scripts
Diffstat (limited to 'ishtar_common/forms_common.py')
-rw-r--r--ishtar_common/forms_common.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index a92b53e29..0f8b4d416 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -37,11 +37,11 @@ from django.forms.models import BaseModelFormSet, BaseFormSet
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _, pgettext
-import models
-import widgets
+from . import models
+from . import widgets
from bootstrap_datepicker.widgets import DatePicker
from ishtar_common.templatetags.link_to_window import simple_link_to_window
-from forms import FinalForm, FormSet, reverse_lazy, name_validator, \
+from .forms import FinalForm, FormSet, reverse_lazy, name_validator, \
TableSelect, ManageOldType, CustomForm, FieldType, FormHeader, \
FormSetWithDeleteSwitches, BSForm, get_data_from_formset, \
file_size_validator, HistorySelect, CustomFormSearch, QAForm
@@ -87,7 +87,7 @@ def get_person_field(label=_(u"Person"), required=True, person_types=[]):
url = "/" + settings.URL_PATH + 'autocomplete-person'
if person_types:
person_types = [
- unicode(models.PersonType.objects.get(txt_idx=person_type).pk)
+ str(models.PersonType.objects.get(txt_idx=person_type).pk)
for person_type in person_types]
url += u"/" + u'_'.join(person_types)
widget = widgets.JQueryAutoComplete(url, associated_model=models.Person)
@@ -111,7 +111,7 @@ class NewItemForm(forms.Form):
if key in self.fields and hasattr(self.fields[key], 'choices'):
new_choices = []
for value, lbl in self.fields[key].choices:
- if unicode(value) in self.limits[key]:
+ if str(value) in self.limits[key]:
new_choices.append((value, lbl))
self.fields[key].choices = new_choices
if len(new_choices) == 1:
@@ -144,7 +144,7 @@ class NewImportForm(BSForm, forms.ModelForm):
self.fields.pop('associated_group')
else:
self.fields['associated_group'].choices = [(None, '--')] + \
- [(g.pk, unicode(g)) for g in groups.all()]
+ [(g.pk, str(g)) for g in groups.all()]
self.fields['importer_type'].choices = [('', '--')] + [
(imp.pk, imp.name) for imp in models.ImporterType.objects.filter(
available=True
@@ -223,7 +223,7 @@ class TargetKeyForm(forms.ModelForm):
self.fields['target'].choices = [(instance.target.pk,
instance.target.verbose_name)]
self.fields['key'].widget.attrs['readonly'] = True
- self.fields['key'].widget.attrs['title'] = unicode(instance)
+ self.fields['key'].widget.attrs['title'] = str(instance)
self.fields['value'].choices = list(
instance.target.get_choices())
self.fields['value'].choices.insert(
@@ -241,7 +241,7 @@ class TargetKeyForm(forms.ModelForm):
and (self.associated_import.associated_group.all_user_can_modify
or self.user.is_superuser):
choices += [
- ('group', unicode(_(u"the current group: {}")).format(
+ ('group', str(_(u"the current group: {}")).format(
self.associated_import.associated_group))]
if self.user.is_superuser:
choices += [('all', _("all users"))]
@@ -424,7 +424,7 @@ class MergeIntoForm(forms.Form):
continue
self.fields['main_item'].choices.append(
(item.pk, mark_safe(u"{} {}".format(simple_link_to_window(item),
- unicode(item)))))
+ str(item)))))
def merge(self):
model = self.associated_model
@@ -433,7 +433,7 @@ class MergeIntoForm(forms.Form):
except model.DoesNotExist:
return
for pk in self.items:
- if pk == unicode(main_item.pk):
+ if pk == str(main_item.pk):
continue
try:
item = model.objects.get(pk=pk)
@@ -875,7 +875,7 @@ class ProfilePersonForm(forms.Form):
if profile.current:
current_profile = profile
initial['current_profile'] = profile.pk
- choices.append((profile.pk, unicode(profile)))
+ choices.append((profile.pk, str(profile)))
if current_profile:
initial['name'] = current_profile.name or \
current_profile.profile_type
@@ -946,7 +946,7 @@ class ProfilePersonForm(forms.Form):
if self.cleaned_data.get('duplicate_profile', None):
profile_name = profile.name or profile.profile_type.label
if name == profile_name:
- name += unicode(_(u" (duplicate)"))
+ name += str(_(u" (duplicate)"))
profile.duplicate(name=name)
return
@@ -1103,11 +1103,11 @@ class MergeOrganizationForm(MergeForm):
def get_image_help():
if not settings.IMAGE_MAX_SIZE:
return max_size_help()
- return unicode(
+ return str(
_(u"Heavy images are resized to: %(width)dx%(height)d "
u"(ratio is preserved).") \
% {'width': settings.IMAGE_MAX_SIZE[0],
- 'height': settings.IMAGE_MAX_SIZE[1]}) + " " + unicode(
+ 'height': settings.IMAGE_MAX_SIZE[1]}) + " " + str(
max_size_help())