summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/forms_common.py355
-rw-r--r--ishtar_common/models.py4
-rw-r--r--ishtar_common/views.py7
3 files changed, 183 insertions, 183 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 390672b51..df8535240 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -60,13 +60,13 @@ from archaeological_warehouse.models import Container
def get_town_field(label=_("Town"), required=True):
help_text = _(
- u"<p>Type name, department code of the "
- u"town you would like to select. The search is insensitive to case."
- u"</p>\n<p>Only the first twenty results are displayed but specifying "
- u"the department code is generally sufficient to get the appropriate "
- u"result.</p>\n<p class='example'>For instance type \"saint denis 93\""
- u" for getting the french town Saint-Denis in the Seine-Saint-Denis "
- u"department.</p>")
+ "<p>Type name, department code of the "
+ "town you would like to select. The search is insensitive to case."
+ "</p>\n<p>Only the first twenty results are displayed but specifying "
+ "the department code is generally sufficient to get the appropriate "
+ "result.</p>\n<p class='example'>For instance type \"saint denis 93\""
+ " for getting the french town Saint-Denis in the Seine-Saint-Denis "
+ "department.</p>")
# !FIXME hard_link, reverse_lazy doen't seem to work with formsets
return forms.IntegerField(
widget=widgets.JQueryAutoComplete(
@@ -76,7 +76,7 @@ def get_town_field(label=_("Town"), required=True):
help_text=mark_safe(help_text), required=required)
-def get_advanced_town_field(label=_(u"Town"), required=True):
+def get_advanced_town_field(label=_("Town"), required=True):
# !FIXME hard_link, reverse_lazy doen't seem to work with formsets
return forms.IntegerField(
widget=widgets.JQueryTown(
@@ -85,7 +85,7 @@ def get_advanced_town_field(label=_(u"Town"), required=True):
required=required)
-def get_person_field(label=_(u"Person"), required=True, person_types=[]):
+def get_person_field(label=_("Person"), required=True, person_types=[]):
# !FIXME hard_link, reverse_lazy doen't seem to work with formsets
widget = None
url = "/" + settings.URL_PATH + 'autocomplete-person'
@@ -93,7 +93,7 @@ def get_person_field(label=_(u"Person"), required=True, person_types=[]):
person_types = [
str(models.PersonType.objects.get(txt_idx=person_type).pk)
for person_type in person_types]
- url += u"/" + u'_'.join(person_types)
+ url += "/" + u'_'.join(person_types)
widget = widgets.JQueryAutoComplete(url, associated_model=models.Person)
return forms.IntegerField(widget=widget, label=label, required=required,
validators=[models.valid_id(models.Person)])
@@ -126,7 +126,7 @@ class NewImportForm(BSForm, forms.ModelForm):
error_css_class = 'error'
required_css_class = 'required'
imported_images_link = forms.URLField(
- label=_(u"Associated images (web link to a zip file)"),
+ label=_("Associated images (web link to a zip file)"),
required=False
)
@@ -164,13 +164,13 @@ class NewImportForm(BSForm, forms.ModelForm):
and data.get('importer_type') \
and not data.get('importer_type').unicity_keys:
raise forms.ValidationError(
- _(u"This import type have no unicity type defined. "
- u"Conservative import is not possible."))
+ _("This import type have no unicity type defined. "
+ "Conservative import is not possible."))
if data.get('imported_images_link', None) \
and data.get('imported_images', None):
raise forms.ValidationError(
- _(u"You put either a file or a download link for images "
- u"but not both."))
+ _("You put either a file or a download link for images "
+ "but not both."))
return data
def clean_imported_images_link(self):
@@ -180,7 +180,7 @@ class NewImportForm(BSForm, forms.ModelForm):
assert is_downloadable(value)
except (AssertionError, requests.exceptions.RequestException):
raise forms.ValidationError(
- _(u"Invalid link or no file is available for this link."))
+ _("Invalid link or no file is available for this link."))
return value
def save(self, user, commit=True):
@@ -209,11 +209,11 @@ class TargetKeyForm(forms.ModelForm):
'key': forms.TextInput(attrs={'readonly': 'readonly'}),
}
target = widgets.SelectReadonlyField(
- model=models.ImportTarget, label=_(u"Target"))
+ model=models.ImportTarget, label=_("Target"))
value = widgets.Select2SimpleField(
- label=_(u"Value"), required=False
+ label=_("Value"), required=False
)
- remember = forms.ChoiceField(label=_(u"Remember"), choices=[],
+ remember = forms.ChoiceField(label=_("Remember"), choices=[],
required=False)
NULL_VALUE = '<NONE>'
@@ -238,14 +238,14 @@ class TargetKeyForm(forms.ModelForm):
self.fields['value'].required = False
choices = [
- ('import', _(u"this import only")),
- ('me', _(u"me")),
+ ('import', _("this import only")),
+ ('me', _("me")),
]
if self.associated_import and self.associated_import.associated_group \
and (self.associated_import.associated_group.all_user_can_modify
or self.user.is_superuser):
choices += [
- ('group', str(_(u"the current group: {}")).format(
+ ('group', str(_("the current group: {}")).format(
self.associated_import.associated_group))]
if self.user.is_superuser:
choices += [('all', _("all users"))]
@@ -323,24 +323,24 @@ class OrganizationForm(ManageOldType, NewItemForm):
associated_models = {'organization_type': models.OrganizationType,
"precise_town": models.Town}
name = forms.CharField(
- label=_(u"Name"), max_length=300, validators=[name_validator])
- organization_type = forms.ChoiceField(label=_(u"Organization type"),
+ label=_("Name"), max_length=300, validators=[name_validator])
+ organization_type = forms.ChoiceField(label=_("Organization type"),
choices=[])
url = forms.URLField(label=_("Web address"), required=False)
- address = forms.CharField(label=_(u"Address"), widget=forms.Textarea,
+ address = forms.CharField(label=_("Address"), widget=forms.Textarea,
required=False)
- address_complement = forms.CharField(label=_(u"Address complement"),
+ address_complement = forms.CharField(label=_("Address complement"),
widget=forms.Textarea, required=False)
- postal_code = forms.CharField(label=_(u"Postal code"), max_length=10,
+ postal_code = forms.CharField(label=_("Postal code"), max_length=10,
required=False)
town = forms.CharField(label=_("Town (freeform)"), max_length=30,
required=False)
precise_town = get_town_field(required=False)
- country = forms.CharField(label=_(u"Country"), max_length=30,
+ country = forms.CharField(label=_("Country"), max_length=30,
required=False)
- email = forms.EmailField(label=_(u"Email"), required=False)
- phone = forms.CharField(label=_(u"Phone"), max_length=18, required=False)
- mobile_phone = forms.CharField(label=_(u"Mobile phone"), max_length=18,
+ email = forms.EmailField(label=_("Email"), required=False)
+ phone = forms.CharField(label=_("Phone"), max_length=18, required=False)
+ mobile_phone = forms.CharField(label=_("Mobile phone"), max_length=18,
required=False)
def __init__(self, *args, **kwargs):
@@ -377,11 +377,11 @@ class OrganizationSelect(CustomForm, TableSelect):
_model = models.Organization
search_vector = forms.CharField(
- label=_(u"Full text search"), widget=widgets.SearchWidget(
+ label=_("Full text search"), widget=widgets.SearchWidget(
'ishtar-common', 'organization'
))
- name = forms.CharField(label=_(u"Name"), max_length=300)
- organization_type = forms.ChoiceField(label=_(u"Type"), choices=[])
+ name = forms.CharField(label=_("Name"), max_length=300)
+ organization_type = forms.ChoiceField(label=_("Type"), choices=[])
def __init__(self, *args, **kwargs):
super(OrganizationSelect, self).__init__(*args, **kwargs)
@@ -391,7 +391,7 @@ class OrganizationSelect(CustomForm, TableSelect):
class OrganizationFormSelection(CustomFormSearch):
SEARCH_AND_SELECT = True
- form_label = _(u"Organization search")
+ form_label = _("Organization search")
associated_models = {'pk': models.Organization}
currents = {'pk': models.Organization}
pk = forms.IntegerField(
@@ -404,7 +404,7 @@ class OrganizationFormSelection(CustomFormSearch):
class OrganizationFormMultiSelection(MultiSearchForm):
- form_label = _(u"Organization search")
+ form_label = _("Organization search")
associated_models = {'pks': models.Organization}
pk = forms.CharField(
label="",
@@ -418,7 +418,7 @@ class OrganizationFormMultiSelection(MultiSearchForm):
class QAOrganizationFormMulti(QAForm):
- form_admin_name = _(u"Organization - Quick action - Modify")
+ form_admin_name = _("Organization - Quick action - Modify")
form_slug = "organization-quickaction-modify"
base_models = ['qa_organization_type']
associated_models = {
@@ -430,7 +430,7 @@ class QAOrganizationFormMulti(QAForm):
'qa_organization_type',
]
qa_organization_type = forms.ChoiceField(
- label=_(u"Organization type"), required=False
+ label=_("Organization type"), required=False
)
TYPES = [
@@ -450,8 +450,8 @@ class ManualMerge(object):
except ValueError:
pass
if len(values) < 2:
- raise forms.ValidationError(_(u"At least two items have to be "
- u"selected."))
+ raise forms.ValidationError(_("At least two items have to be "
+ "selected."))
self.cleaned_data['to_merge'] = values
return values
@@ -481,8 +481,8 @@ class MergeIntoForm(forms.Form):
except self.associated_model.DoesNotExist:
continue
self.fields['main_item'].choices.append(
- (item.pk, mark_safe(u"{} {}".format(simple_link_to_window(item),
- str(item)))))
+ (item.pk, mark_safe("{} {}".format(simple_link_to_window(item),
+ str(item)))))
def merge(self):
model = self.associated_model
@@ -503,7 +503,7 @@ class MergeIntoForm(forms.Form):
class OrgaMergeFormSelection(ManualMerge, forms.Form):
SEARCH_AND_SELECT = True
- form_label = _(u"Organization to merge")
+ form_label = _("Organization to merge")
associated_models = {'to_merge': models.Organization}
currents = {'to_merge': models.Organization}
to_merge = forms.CharField(
@@ -532,13 +532,13 @@ class PersonSelect(CustomForm, TableSelect):
_model = models.Person
search_vector = forms.CharField(
- label=_(u"Full text search"), widget=widgets.SearchWidget(
+ label=_("Full text search"), widget=widgets.SearchWidget(
'ishtar-common', 'person'
))
- name = forms.CharField(label=_(u"Name"), max_length=200)
- surname = forms.CharField(label=_(u"Surname"), max_length=50)
- email = forms.CharField(label=_(u"Email"), max_length=75)
- person_types = forms.ChoiceField(label=_(u"Type"), choices=[])
+ name = forms.CharField(label=_("Name"), max_length=200)
+ surname = forms.CharField(label=_("Surname"), max_length=50)
+ email = forms.CharField(label=_("Email"), max_length=75)
+ person_types = forms.ChoiceField(label=_("Type"), choices=[])
attached_to = forms.IntegerField(
label=_("Organization"),
widget=widgets.JQueryAutoComplete(
@@ -553,7 +553,7 @@ class PersonSelect(CustomForm, TableSelect):
class PersonFormSelection(CustomFormSearch):
SEARCH_AND_SELECT = True
- form_label = _(u"Person search")
+ form_label = _("Person search")
associated_models = {'pk': models.Person}
currents = {'pk': models.Person}
pk = forms.IntegerField(
@@ -565,7 +565,7 @@ class PersonFormSelection(CustomFormSearch):
class PersonFormMultiSelection(MultiSearchForm):
- form_label = _(u"Person search")
+ form_label = _("Person search")
associated_models = {'pks': models.Person}
pk = forms.CharField(
@@ -579,7 +579,7 @@ class PersonFormMultiSelection(MultiSearchForm):
class QAPersonFormMulti(QAForm):
- form_admin_name = _(u"Person - Quick action - Modify")
+ form_admin_name = _("Person - Quick action - Modify")
form_slug = "person-quickaction-modify"
base_models = ['qa_title']
associated_models = {
@@ -593,7 +593,7 @@ class QAPersonFormMulti(QAForm):
'qa_attached_to'
]
qa_title = forms.ChoiceField(
- label=_(u"Title"), required=False
+ label=_("Title"), required=False
)
qa_attached_to = forms.IntegerField(
label=_("Organization"),
@@ -643,25 +643,25 @@ class SimplePersonForm(ManageOldType, NewItemForm):
title = forms.ChoiceField(label=_("Title"), choices=[], required=False)
salutation = forms.CharField(label=_("Salutation"), max_length=200,
required=False)
- surname = forms.CharField(label=_(u"Surname"), max_length=50,
+ surname = forms.CharField(label=_("Surname"), max_length=50,
validators=[name_validator])
- name = forms.CharField(label=_(u"Name"), max_length=200,
+ name = forms.CharField(label=_("Name"), max_length=200,
validators=[name_validator])
- raw_name = forms.CharField(label=_(u"Raw name"), max_length=300,
+ raw_name = forms.CharField(label=_("Raw name"), max_length=300,
required=False)
- email = forms.EmailField(label=_(u"Email"), required=False)
- phone_desc = forms.CharField(label=_(u"Phone description"), max_length=300,
+ email = forms.EmailField(label=_("Email"), required=False)
+ phone_desc = forms.CharField(label=_("Phone description"), max_length=300,
required=False)
- phone = forms.CharField(label=_(u"Phone"), max_length=18, required=False)
- phone_desc2 = forms.CharField(label=_(u"Phone description 2"),
+ phone = forms.CharField(label=_("Phone"), max_length=18, required=False)
+ phone_desc2 = forms.CharField(label=_("Phone description 2"),
max_length=300, required=False)
- phone2 = forms.CharField(label=_(u"Phone 2"), max_length=18,
+ phone2 = forms.CharField(label=_("Phone 2"), max_length=18,
required=False)
- phone_desc3 = forms.CharField(label=_(u"Phone description 3"),
+ phone_desc3 = forms.CharField(label=_("Phone description 3"),
max_length=300, required=False)
- phone3 = forms.CharField(label=_(u"Phone 3"), max_length=18,
+ phone3 = forms.CharField(label=_("Phone 3"), max_length=18,
required=False)
- mobile_phone = forms.CharField(label=_(u"Mobile phone"), max_length=18,
+ mobile_phone = forms.CharField(label=_("Mobile phone"), max_length=18,
required=False)
attached_to = forms.IntegerField(
label=_("Current organization"),
@@ -669,27 +669,27 @@ class SimplePersonForm(ManageOldType, NewItemForm):
reverse_lazy('autocomplete-organization'),
associated_model=models.Organization, new=True),
validators=[models.valid_id(models.Organization)], required=False)
- address = forms.CharField(label=_(u"Address"), widget=forms.Textarea,
+ address = forms.CharField(label=_("Address"), widget=forms.Textarea,
required=False)
address_complement = forms.CharField(
- label=_(u"Address complement"), widget=forms.Textarea, required=False)
- postal_code = forms.CharField(label=_(u"Postal code"), max_length=10,
+ label=_("Address complement"), widget=forms.Textarea, required=False)
+ postal_code = forms.CharField(label=_("Postal code"), max_length=10,
required=False)
town = forms.CharField(label=_("Town (freeform)"), max_length=30,
required=False)
precise_town = get_town_field(required=False)
- country = forms.CharField(label=_(u"Country"), max_length=30,
+ country = forms.CharField(label=_("Country"), max_length=30,
required=False)
- alt_address = forms.CharField(label=_(u"Other address: address"),
+ alt_address = forms.CharField(label=_("Other address: address"),
widget=forms.Textarea, required=False)
alt_address_complement = forms.CharField(
- label=_(u"Other address: address complement"),
+ label=_("Other address: address complement"),
widget=forms.Textarea, required=False)
- alt_postal_code = forms.CharField(label=_(u"Other address: postal code"),
+ alt_postal_code = forms.CharField(label=_("Other address: postal code"),
max_length=10, required=False)
- alt_town = forms.CharField(label=_(u"Other address: town"), max_length=30,
+ alt_town = forms.CharField(label=_("Other address: town"), max_length=30,
required=False)
- alt_country = forms.CharField(label=_(u"Other address: country"),
+ alt_country = forms.CharField(label=_("Other address: country"),
max_length=30, required=False)
def __init__(self, *args, **kwargs):
@@ -701,12 +701,12 @@ class SimplePersonForm(ManageOldType, NewItemForm):
class PersonUserSelect(PersonSelect):
ishtaruser__isnull = forms.NullBooleanField(
- label=_(u"Already has an account"))
+ label=_("Already has an account"))
class PersonUserFormSelection(PersonFormSelection):
SEARCH_AND_SELECT = True
- form_label = _(u"Person search")
+ form_label = _("Person search")
associated_models = {'pk': models.Person}
currents = {'pk': models.Person}
pk = forms.IntegerField(
@@ -721,14 +721,14 @@ class IshtarUserSelect(TableSelect):
_model = models.IshtarUser
search_vector = forms.CharField(
- label=_(u"Full text search"), widget=widgets.SearchWidget(
+ label=_("Full text search"), widget=widgets.SearchWidget(
'ishtar-common', 'ishtaruser'
))
- username = forms.CharField(label=_(u"Username"), max_length=200)
- name = forms.CharField(label=_(u"Name"), max_length=200)
- surname = forms.CharField(label=_(u"Surname"), max_length=50)
- email = forms.CharField(label=_(u"Email"), max_length=75)
- person_types = forms.ChoiceField(label=_(u"Type"), choices=[])
+ username = forms.CharField(label=_("Username"), max_length=200)
+ name = forms.CharField(label=_("Name"), max_length=200)
+ surname = forms.CharField(label=_("Surname"), max_length=50)
+ email = forms.CharField(label=_("Email"), max_length=75)
+ person_types = forms.ChoiceField(label=_("Type"), choices=[])
attached_to = forms.IntegerField(
label=_("Organization"),
widget=widgets.JQueryAutoComplete(
@@ -743,7 +743,7 @@ class IshtarUserSelect(TableSelect):
class AccountFormSelection(forms.Form):
SEARCH_AND_SELECT = True
- form_label = _(u"Account search")
+ form_label = _("Account search")
associated_models = {'pk': models.IshtarUser}
currents = {'pk': models.IshtarUser}
pk = forms.IntegerField(
@@ -854,21 +854,21 @@ class AccountForm(IshtarForm):
form_label = _("Account")
associated_models = {'pk': models.Person}
currents = {'pk': models.Person}
- pk = forms.IntegerField(label=u"", widget=forms.HiddenInput,
+ pk = forms.IntegerField(label="", widget=forms.HiddenInput,
required=False)
- username = forms.CharField(label=_(u"Account"), max_length=30)
- email = forms.CharField(label=_(u"Email"), max_length=75,
+ username = forms.CharField(label=_("Account"), max_length=30)
+ email = forms.CharField(label=_("Email"), max_length=75,
validators=[validators.validate_email])
hidden_password = forms.CharField(
- label=_(u"New password"), max_length=128, widget=forms.PasswordInput,
+ label=_("New password"), max_length=128, widget=forms.PasswordInput,
required=False, validators=[validators.MinLengthValidator(4)])
hidden_password_confirm = forms.CharField(
- label=_(u"New password (confirmation)"), max_length=128,
+ label=_("New password (confirmation)"), max_length=128,
widget=forms.PasswordInput, required=False)
HEADERS = {
'hidden_password': FormHeader(
- _(u"New password"),
+ _("New password"),
help_message=_("Keep theses fields empty if you do not want to "
"change password. On creation, if you leave these "
"fields empty, the user will not be able to "
@@ -905,20 +905,20 @@ class AccountForm(IshtarForm):
password = cleaned_data.get("hidden_password")
if password and \
password != cleaned_data.get("hidden_password_confirm"):
- raise forms.ValidationError(_(u"Your password and confirmation "
- u"password do not match."))
+ raise forms.ValidationError(_("Your password and confirmation "
+ "password do not match."))
if not cleaned_data.get("pk"):
models.is_unique(User, 'username')(cleaned_data.get("username"))
if not password:
- raise forms.ValidationError(_(u"You must provide a correct "
- u"password."))
+ raise forms.ValidationError(_("You must provide a correct "
+ "password."))
# check username unicity
q = models.IshtarUser.objects.filter(
user_ptr__username=cleaned_data.get('username'))
if cleaned_data.get('pk'):
q = q.exclude(person__pk=cleaned_data.get('pk'))
if q.count():
- raise forms.ValidationError(_(u"This username already exists."))
+ raise forms.ValidationError(_("This username already exists."))
return cleaned_data
@@ -929,9 +929,9 @@ class ProfileForm(ManageOldType):
'profile_type': models.ProfileType,
'area': models.Area
}
- profile_type = forms.ChoiceField(label=_(u"Type"), choices=[])
- area = widgets.Select2MultipleField(label=_(u"Areas"), required=False)
- name = forms.CharField(label=_(u"Name"), required=False)
+ profile_type = forms.ChoiceField(label=_("Type"), choices=[])
+ area = widgets.Select2MultipleField(label=_("Areas"), required=False)
+ name = forms.CharField(label=_("Name"), required=False)
pk = forms.IntegerField(label=" ", widget=forms.HiddenInput, required=False)
TYPES = [
@@ -943,15 +943,15 @@ class ProfileForm(ManageOldType):
ProfileFormset = formset_factory(ProfileForm, can_delete=True,
formset=FormSetWithDeleteSwitches)
ProfileFormset.form_label = _("Profiles")
-ProfileFormset.form_admin_name = _(u"Profiles")
+ProfileFormset.form_admin_name = _("Profiles")
ProfileFormset.form_slug = "profiles"
class FinalAccountForm(forms.Form):
final = True
form_label = _("Confirm")
- send_password = forms.BooleanField(label=_(u"Send the new password by "
- u"email?"), required=False)
+ send_password = forms.BooleanField(label=_("Send the new password by "
+ "email?"), required=False)
def __init__(self, *args, **kwargs):
self.is_hidden = True
@@ -962,22 +962,22 @@ class ProfilePersonForm(forms.Form):
"""
Edit the current profile
"""
- current_profile = forms.ChoiceField(label=_(u"Current profile"),
+ current_profile = forms.ChoiceField(label=_("Current profile"),
choices=[])
- name = forms.CharField(label=_(u"Name"), required=False)
- profile_type = forms.ChoiceField(label=_(u"Profile type"), required=False,
+ name = forms.CharField(label=_("Name"), required=False)
+ profile_type = forms.ChoiceField(label=_("Profile type"), required=False,
disabled=True, choices=[])
auto_pin = forms.BooleanField(
- label=_(u"Pin automatically items on creation and modification"),
+ label=_("Pin automatically items on creation and modification"),
required=False)
display_pin_menu = forms.BooleanField(
- label=_(u"Show pin menu"),
+ label=_("Show pin menu"),
required=False)
duplicate_profile = forms.BooleanField(
- label=_(u"Duplicate this profile"), required=False)
+ label=_("Duplicate this profile"), required=False)
delete_profile = forms.BooleanField(
- label=_(u"Delete this profile"), required=False,
+ label=_("Delete this profile"), required=False,
)
def __init__(self, *args, **kwargs):
@@ -1028,7 +1028,7 @@ class ProfilePersonForm(forms.Form):
person__ishtaruser=self.user.ishtaruser,
name=name).exclude(pk=profile.pk).count():
raise forms.ValidationError(
- _(u"A profile with the same name exists."))
+ _("A profile with the same name exists."))
return data
def save(self, session):
@@ -1060,7 +1060,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 += str(_(u" (duplicate)"))
+ name += str(_(" (duplicate)"))
profile.duplicate(name=name)
return
@@ -1088,7 +1088,7 @@ class TownFormSet(FormSet):
TownFormset = formset_factory(TownForm, can_delete=True, formset=TownFormSet)
TownFormset.form_label = _("Towns")
-TownFormset.form_admin_name = _(u"Towns")
+TownFormset.form_admin_name = _("Towns")
TownFormset.form_slug = "towns"
@@ -1161,7 +1161,7 @@ class MergeFormSet(BaseModelFormSet):
class MergeForm(forms.ModelForm):
id = forms.IntegerField(
- label=u"", widget=forms.HiddenInput, required=False)
+ label="", widget=forms.HiddenInput, required=False)
a_is_duplicate_b = forms.BooleanField(required=False)
b_is_duplicate_a = forms.BooleanField(required=False)
not_duplicate = forms.BooleanField(required=False)
@@ -1170,7 +1170,7 @@ class MergeForm(forms.ModelForm):
checked = [True for k in ['a_is_duplicate_b', 'b_is_duplicate_a',
'not_duplicate'] if self.cleaned_data.get(k)]
if len(checked) > 1:
- raise forms.ValidationError(_(u"Only one choice can be checked."))
+ raise forms.ValidationError(_("Only one choice can be checked."))
return self.cleaned_data
def merge(self, *args, **kwargs):
@@ -1218,11 +1218,10 @@ def get_image_help():
if not settings.IMAGE_MAX_SIZE:
return max_size_help()
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]}) + " " + str(
- max_size_help())
+ _("Heavy images are resized to: %(width)dx%(height)d "
+ "(ratio is preserved).") % {
+ 'width': settings.IMAGE_MAX_SIZE[0],
+ 'height': settings.IMAGE_MAX_SIZE[1]}) + " " + str(max_size_help())
#######################
@@ -1231,7 +1230,7 @@ def get_image_help():
class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):
- form_label = _(u"Documentation")
+ form_label = _("Documentation")
form_admin_name = _("Document - General")
form_slug = "document-general"
file_upload = True
@@ -1239,48 +1238,48 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):
associated_models = {'source_type': models.SourceType}
pk = forms.IntegerField(label="", required=False, widget=forms.HiddenInput)
- title = forms.CharField(label=_(u"Title"), required=False,
+ title = forms.CharField(label=_("Title"), required=False,
validators=[validators.MaxLengthValidator(200)])
source_type = widgets.ModelChoiceField(
- model=models.SourceType, label=_(u"Source type"), choices=[],
+ model=models.SourceType, label=_("Source type"), choices=[],
required=False)
authors = widgets.ModelJQueryAutocompleteField(
- model=models.Author, multiple=True, label=_(u"Authors"), new=True,
+ model=models.Author, multiple=True, label=_("Authors"), new=True,
long_widget=True, required=False)
associated_url = forms.URLField(
max_length=1000, required=False,
- label=_(u"Numerical ressource (web address)"))
+ label=_("Numerical ressource (web address)"))
image = forms.ImageField(
- label=_(u"Image"), help_text=mark_safe(get_image_help()),
+ label=_("Image"), help_text=mark_safe(get_image_help()),
max_length=255, required=False, widget=widgets.ImageFileInput(),
validators=[file_size_validator]
)
associated_file = forms.FileField(
- label=pgettext(u"Not directory", u"File"), max_length=255,
+ label=pgettext("Not directory", "File"), max_length=255,
required=False, help_text=max_size_help(),
validators=[file_size_validator]
)
reference = forms.CharField(
- label=_(u"Reference"),
+ label=_("Reference"),
validators=[validators.MaxLengthValidator(100)], required=False)
internal_reference = forms.CharField(
- label=_(u"Internal reference"),
+ label=_("Internal reference"),
validators=[validators.MaxLengthValidator(100)], required=False)
- receipt_date = forms.DateField(label=_(u"Receipt date"), required=False,
+ receipt_date = forms.DateField(label=_("Receipt date"), required=False,
widget=DatePicker)
- creation_date = forms.DateField(label=_(u"Creation date"), required=False,
+ creation_date = forms.DateField(label=_("Creation date"), required=False,
widget=DatePicker)
receipt_date_in_documentation = forms.DateField(
- label=_(u"Receipt date in documentation"), required=False,
+ label=_("Receipt date in documentation"), required=False,
widget=DatePicker)
- comment = forms.CharField(label=_(u"Comment"), widget=forms.Textarea,
+ comment = forms.CharField(label=_("Comment"), widget=forms.Textarea,
required=False)
- description = forms.CharField(label=_(u"Description"),
+ description = forms.CharField(label=_("Description"),
widget=forms.Textarea, required=False)
additional_information = forms.CharField(
- label=_(u"Additional information"), widget=forms.Textarea,
+ label=_("Additional information"), widget=forms.Textarea,
required=False)
- duplicate = forms.NullBooleanField(label=_(u"Has a duplicate"),
+ duplicate = forms.NullBooleanField(label=_("Has a duplicate"),
required=False)
TYPES = [
@@ -1298,12 +1297,12 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):
]
HEADERS = {
- 'title': FormHeader(_(u"Identification")),
- 'image': FormHeader(_(u"Content")),
- 'authors': FormHeader(_(u"Authors")),
- 'receipt_date': FormHeader(_(u"Dates")),
- 'comment': FormHeader(_(u"Advanced"), collapse=True),
- 'finds': FormHeader(_(u"Related items")),
+ 'title': FormHeader(_("Identification")),
+ 'image': FormHeader(_("Content")),
+ 'authors': FormHeader(_("Authors")),
+ 'receipt_date': FormHeader(_("Dates")),
+ 'comment': FormHeader(_("Advanced"), collapse=True),
+ 'finds': FormHeader(_("Related items")),
}
def __init__(self, *args, **kwargs):
@@ -1341,8 +1340,8 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):
for rel in models.Document.RELATED_MODELS:
if cleaned_data.get(rel, None):
return cleaned_data
- raise forms.ValidationError(_(u"A document has to be attached at least "
- u"to one item"))
+ raise forms.ValidationError(_("A document has to be attached at least "
+ "to one item"))
def save(self, commit=True):
if not self.cleaned_data.get('authors', None):
@@ -1378,38 +1377,38 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):
class DocumentSelect(HistorySelect):
_model = models.Document
- form_admin_name = _(u"Document - 001 - Search")
+ form_admin_name = _("Document - 001 - Search")
form_slug = "document-001-search"
search_vector = forms.CharField(
- label=_(u"Full text search"), widget=widgets.SearchWidget(
+ label=_("Full text search"), widget=widgets.SearchWidget(
'ishtar-common', 'document'
))
authors = forms.IntegerField(
widget=widgets.JQueryAutoComplete(
"/" + settings.URL_PATH + 'autocomplete-author',
associated_model=models.Author),
- validators=[models.valid_id(models.Author)], label=_(u"Author"),
+ validators=[models.valid_id(models.Author)], label=_("Author"),
required=False)
- title = forms.CharField(label=_(u"Title"))
+ title = forms.CharField(label=_("Title"))
source_type = forms.ChoiceField(label=_("Source type"), choices=[])
- reference = forms.CharField(label=_(u"Reference"))
- internal_reference = forms.CharField(label=_(u"Internal reference"))
- description = forms.CharField(label=_(u"Description"))
- comment = forms.CharField(label=_(u"Comment"))
+ reference = forms.CharField(label=_("Reference"))
+ internal_reference = forms.CharField(label=_("Internal reference"))
+ description = forms.CharField(label=_("Description"))
+ comment = forms.CharField(label=_("Comment"))
additional_information = forms.CharField(
- label=_(u"Additional informations"))
- duplicate = forms.NullBooleanField(label=_(u"Has a duplicate"))
- image__isnull = forms.NullBooleanField(label=_(u"Has an image?"))
+ label=_("Additional informations"))
+ duplicate = forms.NullBooleanField(label=_("Has a duplicate"))
+ image__isnull = forms.NullBooleanField(label=_("Has an image?"))
operation = forms.IntegerField(
- label=_(u"Operation"), required=False,
+ label=_("Operation"), required=False,
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-operation'),
associated_model=Operation),
validators=[models.valid_id(Operation)])
context_record = forms.IntegerField(
- label=_(u"Context record"), required=False,
+ label=_("Context record"), required=False,
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-contextrecord'),
associated_model=ContextRecord),
@@ -1421,15 +1420,15 @@ class DocumentSelect(HistorySelect):
associated_model=FindBasket),
validators=[models.valid_id(FindBasket)], required=False)
find = forms.IntegerField(
- label=_(u"Find"), required=False,
+ label=_("Find"), required=False,
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-find'),
associated_model=Find),
validators=[models.valid_id(Find)])
- find__denomination = forms.CharField(label=_(u"Find - denomination"),
+ find__denomination = forms.CharField(label=_("Find - denomination"),
required=False)
container = forms.IntegerField(
- label=_(u"Container"), required=False,
+ label=_("Container"), required=False,
widget=widgets.JQueryAutoComplete(
reverse_lazy('autocomplete-container'),
associated_model=Container),
@@ -1448,7 +1447,7 @@ class DocumentSelect(HistorySelect):
class DocumentFormSelection(LockForm, CustomFormSearch):
SEARCH_AND_SELECT = True
- form_label = _(u"Document search")
+ form_label = _("Document search")
associated_models = {'pk': models.Document}
currents = {'pk': models.Document}
@@ -1463,7 +1462,7 @@ class DocumentFormSelection(LockForm, CustomFormSearch):
class DocumentFormMultiSelection(LockForm, MultiSearchForm):
- form_label = _(u"Document search")
+ form_label = _("Document search")
associated_models = {'pks': models.Document}
pk_key = 'pks'
@@ -1479,7 +1478,7 @@ class DocumentFormMultiSelection(LockForm, MultiSearchForm):
class QADocumentFormMulti(QAForm):
- form_admin_name = _(u"Document - Quick action - Modify")
+ form_admin_name = _("Document - Quick action - Modify")
form_slug = "document-quickaction-modify"
base_models = ['qa_source_type']
associated_models = {
@@ -1493,10 +1492,10 @@ class QADocumentFormMulti(QAForm):
'qa_creation_date',
]
qa_source_type = forms.ChoiceField(
- label=_(u"Source type"), required=False
+ label=_("Source type"), required=False
)
qa_authors = widgets.ModelJQueryAutocompleteField(
- model=models.Author, label=_(u"Author"), new=True,
+ model=models.Author, label=_("Author"), new=True,
required=False)
qa_creation_date = forms.DateField(
label=_("Creation date"), widget=DatePicker, required=False)
@@ -1598,7 +1597,7 @@ class QALockForm(forms.Form):
class SourceDeletionForm(FinalForm):
confirm_msg = " "
- confirm_end_msg = _(u"Would you like to delete this documentation?")
+ confirm_end_msg = _("Would you like to delete this documentation?")
######################
# Authors management #
@@ -1606,15 +1605,15 @@ class SourceDeletionForm(FinalForm):
class AuthorForm(ManageOldType, NewItemForm):
- form_label = _(u"Author")
+ form_label = _("Author")
associated_models = {'person': models.Person,
'author_type': models.AuthorType}
person = forms.IntegerField(
widget=widgets.JQueryAutoComplete(
"/" + settings.URL_PATH + 'autocomplete-person',
associated_model=models.Person, new=True),
- validators=[models.valid_id(models.Person)], label=_(u"Person"))
- author_type = forms.ChoiceField(label=_(u"Author type"), choices=[])
+ validators=[models.valid_id(models.Person)], label=_("Person"))
+ author_type = forms.ChoiceField(label=_("Author type"), choices=[])
def __init__(self, *args, **kwargs):
super(AuthorForm, self).__init__(*args, **kwargs)
@@ -1642,7 +1641,7 @@ class AuthorForm(ManageOldType, NewItemForm):
class AuthorFormSelection(forms.Form):
- form_label = _(u"Author selection")
+ form_label = _("Author selection")
base_model = 'author'
associated_models = {'author': models.Author}
author = forms.IntegerField(
@@ -1650,7 +1649,7 @@ class AuthorFormSelection(forms.Form):
widget=widgets.JQueryAutoComplete(
"/" + settings.URL_PATH + 'autocomplete-author',
associated_model=models.Author, new=True),
- validators=[models.valid_id(models.Author)], label=_(u"Author"))
+ validators=[models.valid_id(models.Author)], label=_("Author"))
class AuthorFormSet(FormSet):
@@ -1663,20 +1662,20 @@ class AuthorFormSet(FormSet):
AuthorFormset = formset_factory(AuthorFormSelection, can_delete=True,
formset=AuthorFormSet)
AuthorFormset.form_label = _("Authors")
-AuthorFormset.form_admin_name = _(u"Authors")
+AuthorFormset.form_admin_name = _("Authors")
AuthorFormset.form_slug = "authors"
class SearchQueryForm(forms.Form):
- query = forms.CharField(max_length=None, label=_(u"Query"), initial='*',
+ query = forms.CharField(max_length=None, label=_("Query"), initial='*',
widget=forms.HiddenInput)
search_query = forms.ChoiceField(label="", required=False,
choices=[])
label = forms.CharField(label="", max_length=None, required=False)
- is_alert = forms.BooleanField(label=_(u"Is an alert"), required=False)
+ is_alert = forms.BooleanField(label=_("Is an alert"), required=False)
create_or_update = forms.ChoiceField(
- choices=(('create', _(u"Create")),
- ('update', _(u"Update"))), initial='create')
+ choices=(('create', _("Create")),
+ ('update', _("Update"))), initial='create')
def __init__(self, profile, content_type, *args, **kwargs):
self.profile = profile
@@ -1691,17 +1690,17 @@ class SearchQueryForm(forms.Form):
def clean(self):
data = self.cleaned_data
if data['create_or_update'] == 'create' and not data['label']:
- raise forms.ValidationError(_(u"A label is required for a new "
- u"search query."))
+ raise forms.ValidationError(_("A label is required for a new "
+ "search query."))
elif data['create_or_update'] == 'update':
if not data['search_query']:
- raise forms.ValidationError(_(u"Select the search query to "
- u"update"))
+ raise forms.ValidationError(_("Select the search query to "
+ "update"))
q = models.SearchQuery.objects.filter(
profile=self.profile, content_type=self.content_type,
pk=data['search_query'])
if not q.count():
- raise forms.ValidationError(_(u"Query does not exist."))
+ raise forms.ValidationError(_("Query does not exist."))
return data
def save(self):
@@ -1716,14 +1715,14 @@ class SearchQueryForm(forms.Form):
profile=self.profile, content_type=self.content_type,
pk=data['search_query'])
except models.SearchQuery.DoesNotExist:
- raise forms.ValidationError(_(u"Query does not exist."))
+ raise forms.ValidationError(_("Query does not exist."))
sq.query = data['query']
sq.save()
return sq
class QRSearchForm(forms.Form):
- query = forms.CharField(max_length=None, label=_(u"Query"), initial='*')
+ query = forms.CharField(max_length=None, label=_("Query"), initial='*')
current_url = forms.CharField(max_length=None, label="",
widget=forms.HiddenInput())
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 38e5b2fb4..071b05598 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -4284,8 +4284,8 @@ class Merge(models.Model):
for m in self.merge_exclusion.all():
m.delete()
- def merge(self, item):
- merge_model_objects(self, item)
+ def merge(self, item, keep_old=False):
+ merge_model_objects(self, item, keep_old=keep_old)
self.generate_merge_candidate()
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index b662c1a4d..2176c4519 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -948,7 +948,7 @@ def reset_wizards(request):
ITEM_PER_PAGE = 20
-def merge_action(model, form, key):
+def merge_action(model, form, key, name_key="name"):
def merge(request, page=1):
current_url = key + '_merge'
if not page:
@@ -974,7 +974,8 @@ def merge_action(model, form, key):
item_nb_1 = item_nb + ITEM_PER_PAGE
from_key = 'from_' + key
to_key = 'to_' + key
- queryset = q.all().order_by(from_key + '__name')[item_nb:item_nb_1]
+ queryset = q.all().order_by(
+ from_key + '__' + name_key)[item_nb:item_nb_1]
FormSet.from_key = from_key
FormSet.to_key = to_key
if request.method == 'POST':
@@ -1016,7 +1017,7 @@ organization_merge = merge_action(
class IshtarMixin(object):
- page_name = u""
+ page_name = ""
def get_context_data(self, **kwargs):
context = super(IshtarMixin, self).get_context_data(**kwargs)