diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/admin.py | 8 | ||||
| -rw-r--r-- | ishtar_common/forms.py | 32 | ||||
| -rw-r--r-- | ishtar_common/forms_common.py | 64 | ||||
| -rw-r--r-- | ishtar_common/ishtar_menu.py | 13 | ||||
| -rw-r--r-- | ishtar_common/migrations/0052_auto__add_field_ishtarsiteprofile_file_external_id__add_field_ishtarsi.py | 441 | ||||
| -rw-r--r-- | ishtar_common/migrations/0053_auto__add_field_ishtarsiteprofile_currency.py | 410 | ||||
| -rw-r--r-- | ishtar_common/models.py | 138 | ||||
| -rw-r--r-- | ishtar_common/static/media/style.css | 14 | ||||
| -rw-r--r-- | ishtar_common/templates/base.html | 4 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/sheet_person.html | 35 | ||||
| -rw-r--r-- | ishtar_common/templatetags/window_tables.py | 4 | ||||
| -rw-r--r-- | ishtar_common/tests.py | 2 | ||||
| -rw-r--r-- | ishtar_common/urls.py | 12 | ||||
| -rw-r--r-- | ishtar_common/views.py | 118 | ||||
| -rw-r--r-- | ishtar_common/widgets.py | 6 | ||||
| -rw-r--r-- | ishtar_common/wizards.py | 80 |
16 files changed, 1274 insertions, 107 deletions
diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py index b7ad530b7..675d85ec5 100644 --- a/ishtar_common/admin.py +++ b/ishtar_common/admin.py @@ -236,7 +236,13 @@ class OperationTypeAdmin(GeneralTypeAdmin): admin.site.register(models.OperationType, OperationTypeAdmin) -basic_models = [models.IshtarUser, models.DocumentTemplate] + +class IshtarUserAdmin(admin.ModelAdmin): + readonly_fields = ('password',) + +admin.site.register(models.IshtarUser, IshtarUserAdmin) + +basic_models = [models.DocumentTemplate] if settings.COUNTRY == 'fr': basic_models += [models.Arrondissement, models.Canton] diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index 5e0d14eb8..89df1b1a5 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -124,6 +124,13 @@ class ClosingDateFormSelection(forms.Form): end_date = forms.DateField(label=_(u"Closing date"), widget=widgets.JQueryDate) + def __init__(self, *args, **kwargs): + if 'initial' not in kwargs: + kwargs['initial'] = {} + if not kwargs['initial'].get('end_date', None): + kwargs['initial']['end_date'] = datetime.date.today() + super(ClosingDateFormSelection, self).__init__(*args, **kwargs) + def get_form_selection( class_name, label, key, model, base_form, get_url, @@ -164,6 +171,29 @@ def get_form_selection( return type(class_name, (forms.Form,), attrs) +def get_data_from_formset(data): + """ + convert ['formname-wizardname-1-public_domain': [u'on'], ...] to + [{'public_domain': 'off'}, {'public_domain': 'on'}] + """ + values = [] + for k in data: + if not data[k]: + continue + keys = k.split('-') + if len(keys) < 3: + continue + try: + idx = int(keys[-2]) + except ValueError: + continue + while len(values) < (idx + 1): + values.append({}) + field_name = keys[-1] + values[idx][field_name] = data[k] + return values + + class DocumentGenerationForm(forms.Form): """ Form to generate document by choosing the template diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 1d8dc2092..6fdee55cb 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -208,8 +208,10 @@ class OrganizationFormSelection(forms.Form): currents = {'pk': models.Organization} pk = forms.IntegerField( label="", - widget=widgets.JQueryJqGrid(reverse_lazy('get-organization'), - OrganizationSelect, models.Organization), + widget=widgets.JQueryJqGrid( + reverse_lazy('get-organization'), OrganizationSelect, + models.Organization, + source_full=reverse_lazy('get-organization-full')), validators=[models.valid_id(models.Organization)]) @@ -245,8 +247,9 @@ class PersonFormSelection(forms.Form): currents = {'pk': models.Person} pk = forms.IntegerField( label="", - widget=widgets.JQueryJqGrid(reverse_lazy('get-person'), - PersonSelect, models.Person), + widget=widgets.JQueryJqGrid( + reverse_lazy('get-person'), PersonSelect, models.Person, + source_full=reverse_lazy('get-person-full')), validators=[models.valid_id(models.Person)]) @@ -306,6 +309,51 @@ class SimplePersonForm(NewItemForm): self.fields['raw_name'].widget.attrs['readonly'] = True +class PersonUserSelect(PersonSelect): + ishtaruser__isnull = forms.NullBooleanField( + label=_(u"Already has an account"), initial=False) + + +class PersonUserFormSelection(PersonFormSelection): + form_label = _(u"Person search") + associated_models = {'pk': models.Person} + currents = {'pk': models.Person} + pk = forms.IntegerField( + label="", + widget=widgets.JQueryJqGrid(reverse_lazy('get-person'), + PersonUserSelect, models.Person), + validators=[models.valid_id(models.Person)]) + + +class IshtarUserSelect(TableSelect): + 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=[]) + attached_to = forms.IntegerField( + label=_("Organization"), + widget=widgets.JQueryAutoComplete( + reverse_lazy('autocomplete-organization'), + associated_model=models.Organization), + validators=[models.valid_id(models.Organization)]) + + def __init__(self, *args, **kwargs): + super(IshtarUserSelect, self).__init__(*args, **kwargs) + self.fields['person_types'].choices = models.PersonType.get_types() + + +class AccountFormSelection(forms.Form): + form_label = _(u"Account search") + associated_models = {'pk': models.IshtarUser} + currents = {'pk': models.IshtarUser} + pk = forms.IntegerField( + label="", + widget=widgets.JQueryJqGrid(reverse_lazy('get-ishtaruser'), + IshtarUserSelect, models.IshtarUser), + validators=[models.valid_id(models.IshtarUser)]) + + class BasePersonForm(forms.ModelForm): class Meta: model = models.Person @@ -427,11 +475,11 @@ class AccountForm(forms.Form): raise forms.ValidationError(_(u"You must provide a correct " u"password.")) # check username unicity - usernames = models.IshtarUser.objects.filter( + q = models.IshtarUser.objects.filter( username=cleaned_data.get('username')) if cleaned_data.get('pk'): - usernames.exclude(pk=cleaned_data.get('pk')) - if usernames.count(): + q = q.exclude(person__pk=cleaned_data.get('pk')) + if q.count(): raise forms.ValidationError(_(u"This username already exists.")) return cleaned_data diff --git a/ishtar_common/ishtar_menu.py b/ishtar_common/ishtar_menu.py index 30cba6735..39bf7c1d6 100644 --- a/ishtar_common/ishtar_menu.py +++ b/ishtar_common/ishtar_menu.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -28,9 +28,14 @@ import models MENU_SECTIONS = [ (5, SectionItem('admin', _(u"Administration"), childs=[ - MenuItem('account_management', _(u"Account management"), - model=models.IshtarUser, - access_controls=['add_ishtaruser', ]), + SectionItem( + 'account', _(u"Account"), + childs=[MenuItem('account_management', _(u"Add/modify"), + model=models.IshtarUser, + access_controls=['add_ishtaruser', ]), + MenuItem('account_deletion', _(u"Deletion"), + model=models.IshtarUser, + access_controls=['add_ishtaruser', ]), ]), MenuItem('admin-globalvar', _(u"Global variables"), model=models.GlobalVar, access_controls=['add_globalvar', ]), diff --git a/ishtar_common/migrations/0052_auto__add_field_ishtarsiteprofile_file_external_id__add_field_ishtarsi.py b/ishtar_common/migrations/0052_auto__add_field_ishtarsiteprofile_file_external_id__add_field_ishtarsi.py new file mode 100644 index 000000000..7b902a432 --- /dev/null +++ b/ishtar_common/migrations/0052_auto__add_field_ishtarsiteprofile_file_external_id__add_field_ishtarsi.py @@ -0,0 +1,441 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'IshtarSiteProfile.file_external_id' + db.add_column('ishtar_common_ishtarsiteprofile', 'file_external_id', + self.gf('django.db.models.fields.TextField')(default='{settings__ISHTAR_LOCAL_PREFIX}{year}-{numeric_reference}'), + keep_default=False) + + # Adding field 'IshtarSiteProfile.parcel_external_id' + db.add_column('ishtar_common_ishtarsiteprofile', 'parcel_external_id', + self.gf('django.db.models.fields.TextField')(default='{associated_file__external_id}{operation__code_patriarche}-{town__numero_insee}-{section}{parcel_number}'), + keep_default=False) + + # Adding field 'IshtarSiteProfile.context_record_external_id' + db.add_column('ishtar_common_ishtarsiteprofile', 'context_record_external_id', + self.gf('django.db.models.fields.TextField')(default='{parcel__external_id}-{label}'), + keep_default=False) + + # Adding field 'IshtarSiteProfile.base_find_external_id' + db.add_column('ishtar_common_ishtarsiteprofile', 'base_find_external_id', + self.gf('django.db.models.fields.TextField')(default='{context_record__external_id}-{label}'), + keep_default=False) + + # Adding field 'IshtarSiteProfile.find_external_id' + db.add_column('ishtar_common_ishtarsiteprofile', 'find_external_id', + self.gf('django.db.models.fields.TextField')(default='{get_first_base_find__context_record__external_id}-{label}'), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'IshtarSiteProfile.file_external_id' + db.delete_column('ishtar_common_ishtarsiteprofile', 'file_external_id') + + # Deleting field 'IshtarSiteProfile.parcel_external_id' + db.delete_column('ishtar_common_ishtarsiteprofile', 'parcel_external_id') + + # Deleting field 'IshtarSiteProfile.context_record_external_id' + db.delete_column('ishtar_common_ishtarsiteprofile', 'context_record_external_id') + + # Deleting field 'IshtarSiteProfile.base_find_external_id' + db.delete_column('ishtar_common_ishtarsiteprofile', 'base_find_external_id') + + # Deleting field 'IshtarSiteProfile.find_external_id' + db.delete_column('ishtar_common_ishtarsiteprofile', 'find_external_id') + + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'ishtar_common.arrondissement': { + 'Meta': {'object_name': 'Arrondissement'}, + 'department': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Department']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}) + }, + 'ishtar_common.author': { + 'Meta': {'object_name': 'Author'}, + 'author_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.AuthorType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'person': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'author'", 'to': "orm['ishtar_common.Person']"}) + }, + 'ishtar_common.authortype': { + 'Meta': {'object_name': 'AuthorType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.canton': { + 'Meta': {'object_name': 'Canton'}, + 'arrondissement': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Arrondissement']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}) + }, + 'ishtar_common.department': { + 'Meta': {'ordering': "['number']", 'object_name': 'Department'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '30'}), + 'number': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '3'}), + 'state': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.State']", 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.documenttemplate': { + 'Meta': {'ordering': "['associated_object_name', 'name']", 'object_name': 'DocumentTemplate'}, + 'associated_object_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'template': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}) + }, + 'ishtar_common.format': { + 'Meta': {'object_name': 'Format'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.formatertype': { + 'Meta': {'ordering': "('formater_type', 'options')", 'unique_together': "(('formater_type', 'options', 'many_split'),)", 'object_name': 'FormaterType'}, + 'formater_type': ('django.db.models.fields.CharField', [], {'max_length': '20'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'many_split': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'options': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.globalvar': { + 'Meta': {'ordering': "['slug']", 'object_name': 'GlobalVar'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), + 'value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.historicalorganization': { + 'Meta': {'ordering': "('-history_date', '-history_id')", 'object_name': 'HistoricalOrganization'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_is_prefered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'alt_country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'alt_postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'alt_town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'exclude_from_merge': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), + 'history_creator_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'history_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'history_id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'history_modifier_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'history_type': ('django.db.models.fields.CharField', [], {'max_length': '1'}), + 'history_user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}), + 'id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'blank': 'True'}), + 'merge_key': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + 'organization_type_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone2': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone3': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone_desc': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc2': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc3': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'raw_phone': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.import': { + 'Meta': {'object_name': 'Import'}, + 'conservative_import': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}), + 'encoding': ('django.db.models.fields.CharField', [], {'default': "'utf-8'", 'max_length': '15'}), + 'end_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'error_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imported_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), + 'imported_images': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'importer_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.ImporterType']"}), + 'match_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'result_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'seconds_remaining': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'skip_lines': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'state': ('django.db.models.fields.CharField', [], {'default': "'C'", 'max_length': '2'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.IshtarUser']"}) + }, + 'ishtar_common.importercolumn': { + 'Meta': {'ordering': "('importer_type', 'col_number')", 'unique_together': "(('importer_type', 'col_number'),)", 'object_name': 'ImporterColumn'}, + 'col_number': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'importer_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'columns'", 'to': "orm['ishtar_common.ImporterType']"}), + 'regexp_pre_filter': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Regexp']", 'null': 'True', 'blank': 'True'}), + 'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) + }, + 'ishtar_common.importerdefault': { + 'Meta': {'object_name': 'ImporterDefault'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'importer_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'defaults'", 'to': "orm['ishtar_common.ImporterType']"}), + 'target': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.importerdefaultvalues': { + 'Meta': {'object_name': 'ImporterDefaultValues'}, + 'default_target': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'default_values'", 'to': "orm['ishtar_common.ImporterDefault']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'target': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + 'value': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.importerduplicatefield': { + 'Meta': {'object_name': 'ImporterDuplicateField'}, + 'column': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'duplicate_fields'", 'to': "orm['ishtar_common.ImporterColumn']"}), + 'concat': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'concat_str': ('django.db.models.fields.CharField', [], {'max_length': '5', 'null': 'True', 'blank': 'True'}), + 'field_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'force_new': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + 'ishtar_common.importertype': { + 'Meta': {'object_name': 'ImporterType'}, + 'associated_models': ('django.db.models.fields.CharField', [], {'max_length': '200'}), + 'description': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_template': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '100', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'unicity_keys': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}), + 'users': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['ishtar_common.IshtarUser']", 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.importtarget': { + 'Meta': {'object_name': 'ImportTarget'}, + 'column': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'targets'", 'to': "orm['ishtar_common.ImporterColumn']"}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'concat': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'concat_str': ('django.db.models.fields.CharField', [], {'max_length': '5', 'null': 'True', 'blank': 'True'}), + 'force_new': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'formater_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.FormaterType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'regexp_filter': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Regexp']", 'null': 'True', 'blank': 'True'}), + 'target': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.ishtarsiteprofile': { + 'Meta': {'ordering': "['label']", 'object_name': 'IshtarSiteProfile'}, + 'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'base_find_external_id': ('django.db.models.fields.TextField', [], {'default': "'{context_record__external_id}-{label}'"}), + 'context_record': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'context_record_external_id': ('django.db.models.fields.TextField', [], {'default': "'{parcel__external_id}-{label}'"}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'file_external_id': ('django.db.models.fields.TextField', [], {'default': "'{settings.ISHTAR_LOCAL_PREFIX}{year}-{numeric_reference}'"}), + 'files': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'find': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'find_external_id': ('django.db.models.fields.TextField', [], {'default': "'{context_record__external_id}-{label}'"}), + 'homepage': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.TextField', [], {}), + 'parcel_external_id': ('django.db.models.fields.TextField', [], {'default': "'{associated_file__external_id}{operation__code_patriarche}-{town__numero_insee}-{section}{parcel_number}'"}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), + 'warehouse': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) + }, + 'ishtar_common.ishtaruser': { + 'Meta': {'object_name': 'IshtarUser', '_ormbases': ['auth.User']}, + 'person': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ishtaruser'", 'unique': 'True', 'to': "orm['ishtar_common.Person']"}), + 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}) + }, + 'ishtar_common.itemkey': { + 'Meta': {'object_name': 'ItemKey'}, + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'importer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Import']", 'null': 'True', 'blank': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}) + }, + 'ishtar_common.operationtype': { + 'Meta': {'ordering': "['-preventive', 'order', 'label']", 'object_name': 'OperationType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'order': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'preventive': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.organization': { + 'Meta': {'object_name': 'Organization'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_is_prefered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'alt_country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'alt_postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'alt_town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'exclude_from_merge': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), + 'history_creator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imports': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'imported_ishtar_common_organization'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['ishtar_common.Import']"}), + 'merge_candidate': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_candidate_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Organization']"}), + 'merge_exclusion': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_exclusion_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Organization']"}), + 'merge_key': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + 'organization_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.OrganizationType']"}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone2': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone3': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone_desc': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc2': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc3': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'raw_phone': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.organizationtype': { + 'Meta': {'ordering': "('label',)", 'object_name': 'OrganizationType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.person': { + 'Meta': {'object_name': 'Person'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_is_prefered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'alt_country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'alt_postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'alt_town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}), + 'attached_to': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'members'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['ishtar_common.Organization']"}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'contact_type': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'exclude_from_merge': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), + 'history_creator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imports': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'imported_ishtar_common_person'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['ishtar_common.Import']"}), + 'merge_candidate': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_candidate_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Person']"}), + 'merge_exclusion': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_exclusion_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Person']"}), + 'merge_key': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'person_types': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['ishtar_common.PersonType']", 'symmetrical': 'False'}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone2': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone3': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone_desc': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc2': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc3': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'raw_name': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'raw_phone': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'surname': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.persontype': { + 'Meta': {'ordering': "('label',)", 'object_name': 'PersonType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['auth.Group']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.regexp': { + 'Meta': {'object_name': 'Regexp'}, + 'description': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'regexp': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.sourcetype': { + 'Meta': {'object_name': 'SourceType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.state': { + 'Meta': {'ordering': "['number']", 'object_name': 'State'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '30'}), + 'number': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '3'}) + }, + 'ishtar_common.supporttype': { + 'Meta': {'object_name': 'SupportType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.targetkey': { + 'Meta': {'unique_together': "(('target', 'key', 'associated_user', 'associated_import'),)", 'object_name': 'TargetKey'}, + 'associated_import': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Import']", 'null': 'True', 'blank': 'True'}), + 'associated_user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.IshtarUser']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_set': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'key': ('django.db.models.fields.TextField', [], {}), + 'target': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'keys'", 'to': "orm['ishtar_common.ImportTarget']"}), + 'value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.town': { + 'Meta': {'ordering': "['numero_insee']", 'object_name': 'Town'}, + 'canton': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Canton']", 'null': 'True', 'blank': 'True'}), + 'center': ('django.contrib.gis.db.models.fields.PointField', [], {'srid': '27572', 'null': 'True', 'blank': 'True'}), + 'departement': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Department']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'numero_insee': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '6'}), + 'surface': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) + } + } + + complete_apps = ['ishtar_common'] diff --git a/ishtar_common/migrations/0053_auto__add_field_ishtarsiteprofile_currency.py b/ishtar_common/migrations/0053_auto__add_field_ishtarsiteprofile_currency.py new file mode 100644 index 000000000..04d293b04 --- /dev/null +++ b/ishtar_common/migrations/0053_auto__add_field_ishtarsiteprofile_currency.py @@ -0,0 +1,410 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'IshtarSiteProfile.currency' + db.add_column('ishtar_common_ishtarsiteprofile', 'currency', + self.gf('django.db.models.fields.CharField')(default=u'\u20ac', max_length='5'), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'IshtarSiteProfile.currency' + db.delete_column('ishtar_common_ishtarsiteprofile', 'currency') + + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'ishtar_common.arrondissement': { + 'Meta': {'object_name': 'Arrondissement'}, + 'department': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Department']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}) + }, + 'ishtar_common.author': { + 'Meta': {'object_name': 'Author'}, + 'author_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.AuthorType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'person': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'author'", 'to': "orm['ishtar_common.Person']"}) + }, + 'ishtar_common.authortype': { + 'Meta': {'object_name': 'AuthorType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.canton': { + 'Meta': {'object_name': 'Canton'}, + 'arrondissement': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Arrondissement']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '30'}) + }, + 'ishtar_common.department': { + 'Meta': {'ordering': "['number']", 'object_name': 'Department'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '30'}), + 'number': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '3'}), + 'state': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.State']", 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.documenttemplate': { + 'Meta': {'ordering': "['associated_object_name', 'name']", 'object_name': 'DocumentTemplate'}, + 'associated_object_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'template': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}) + }, + 'ishtar_common.format': { + 'Meta': {'object_name': 'Format'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.formatertype': { + 'Meta': {'ordering': "('formater_type', 'options')", 'unique_together': "(('formater_type', 'options', 'many_split'),)", 'object_name': 'FormaterType'}, + 'formater_type': ('django.db.models.fields.CharField', [], {'max_length': '20'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'many_split': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'options': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.globalvar': { + 'Meta': {'ordering': "['slug']", 'object_name': 'GlobalVar'}, + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), + 'value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.historicalorganization': { + 'Meta': {'ordering': "('-history_date', '-history_id')", 'object_name': 'HistoricalOrganization'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_is_prefered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'alt_country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'alt_postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'alt_town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'exclude_from_merge': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), + 'history_creator_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'history_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'history_id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'history_modifier_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'history_type': ('django.db.models.fields.CharField', [], {'max_length': '1'}), + 'history_user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True'}), + 'id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'blank': 'True'}), + 'merge_key': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + 'organization_type_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone2': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone3': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone_desc': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc2': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc3': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'raw_phone': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.import': { + 'Meta': {'object_name': 'Import'}, + 'conservative_import': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'creation_date': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}), + 'encoding': ('django.db.models.fields.CharField', [], {'default': "'utf-8'", 'max_length': '15'}), + 'end_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}), + 'error_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imported_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100'}), + 'imported_images': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'importer_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.ImporterType']"}), + 'match_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'result_file': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'seconds_remaining': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'skip_lines': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'state': ('django.db.models.fields.CharField', [], {'default': "'C'", 'max_length': '2'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.IshtarUser']"}) + }, + 'ishtar_common.importercolumn': { + 'Meta': {'ordering': "('importer_type', 'col_number')", 'unique_together': "(('importer_type', 'col_number'),)", 'object_name': 'ImporterColumn'}, + 'col_number': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'importer_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'columns'", 'to': "orm['ishtar_common.ImporterType']"}), + 'regexp_pre_filter': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Regexp']", 'null': 'True', 'blank': 'True'}), + 'required': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) + }, + 'ishtar_common.importerdefault': { + 'Meta': {'object_name': 'ImporterDefault'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'importer_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'defaults'", 'to': "orm['ishtar_common.ImporterType']"}), + 'target': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.importerdefaultvalues': { + 'Meta': {'object_name': 'ImporterDefaultValues'}, + 'default_target': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'default_values'", 'to': "orm['ishtar_common.ImporterDefault']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'target': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + 'value': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.importerduplicatefield': { + 'Meta': {'object_name': 'ImporterDuplicateField'}, + 'column': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'duplicate_fields'", 'to': "orm['ishtar_common.ImporterColumn']"}), + 'concat': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'concat_str': ('django.db.models.fields.CharField', [], {'max_length': '5', 'null': 'True', 'blank': 'True'}), + 'field_name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'force_new': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}) + }, + 'ishtar_common.importertype': { + 'Meta': {'object_name': 'ImporterType'}, + 'associated_models': ('django.db.models.fields.CharField', [], {'max_length': '200'}), + 'description': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_template': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'max_length': '100', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'unicity_keys': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}), + 'users': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['ishtar_common.IshtarUser']", 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.importtarget': { + 'Meta': {'object_name': 'ImportTarget'}, + 'column': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'targets'", 'to': "orm['ishtar_common.ImporterColumn']"}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'concat': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'concat_str': ('django.db.models.fields.CharField', [], {'max_length': '5', 'null': 'True', 'blank': 'True'}), + 'force_new': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'formater_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.FormaterType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'regexp_filter': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Regexp']", 'null': 'True', 'blank': 'True'}), + 'target': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.ishtarsiteprofile': { + 'Meta': {'ordering': "['label']", 'object_name': 'IshtarSiteProfile'}, + 'active': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'base_find_external_id': ('django.db.models.fields.TextField', [], {'default': "'{context_record__external_id}-{label}'"}), + 'context_record': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'context_record_external_id': ('django.db.models.fields.TextField', [], {'default': "'{parcel__external_id}-{label}'"}), + 'currency': ('django.db.models.fields.CharField', [], {'default': "u'\\u20ac'", 'max_length': "'5'"}), + 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'file_external_id': ('django.db.models.fields.TextField', [], {'default': "'{settings__ISHTAR_LOCAL_PREFIX}{year}-{numeric_reference}'"}), + 'files': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'find': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'find_external_id': ('django.db.models.fields.TextField', [], {'default': "'{get_first_base_find__context_record__external_id}-{label}'"}), + 'homepage': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.TextField', [], {}), + 'parcel_external_id': ('django.db.models.fields.TextField', [], {'default': "'{associated_file__external_id}{operation__code_patriarche}-{town__numero_insee}-{section}{parcel_number}'"}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '50'}), + 'warehouse': ('django.db.models.fields.BooleanField', [], {'default': 'False'}) + }, + 'ishtar_common.ishtaruser': { + 'Meta': {'object_name': 'IshtarUser', '_ormbases': ['auth.User']}, + 'person': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'ishtaruser'", 'unique': 'True', 'to': "orm['ishtar_common.Person']"}), + 'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'}) + }, + 'ishtar_common.itemkey': { + 'Meta': {'object_name': 'ItemKey'}, + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'importer': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Import']", 'null': 'True', 'blank': 'True'}), + 'key': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'object_id': ('django.db.models.fields.PositiveIntegerField', [], {}) + }, + 'ishtar_common.operationtype': { + 'Meta': {'ordering': "['-preventive', 'order', 'label']", 'object_name': 'OperationType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'order': ('django.db.models.fields.IntegerField', [], {'default': '1'}), + 'preventive': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.organization': { + 'Meta': {'object_name': 'Organization'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_is_prefered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'alt_country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'alt_postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'alt_town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'exclude_from_merge': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), + 'history_creator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imports': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'imported_ishtar_common_organization'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['ishtar_common.Import']"}), + 'merge_candidate': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_candidate_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Organization']"}), + 'merge_exclusion': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_exclusion_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Organization']"}), + 'merge_key': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '500'}), + 'organization_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.OrganizationType']"}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone2': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone3': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone_desc': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc2': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc3': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'raw_phone': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.organizationtype': { + 'Meta': {'ordering': "('label',)", 'object_name': 'OrganizationType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.person': { + 'Meta': {'object_name': 'Person'}, + 'address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_complement': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'alt_address_is_prefered': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'alt_country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'alt_postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'alt_town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}), + 'attached_to': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'members'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['ishtar_common.Organization']"}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'contact_type': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '30', 'null': 'True', 'blank': 'True'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'exclude_from_merge': ('django.db.models.fields.NullBooleanField', [], {'default': 'False', 'null': 'True', 'blank': 'True'}), + 'history_creator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'history_modifier': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'+'", 'null': 'True', 'on_delete': 'models.SET_NULL', 'to': "orm['auth.User']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imports': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'imported_ishtar_common_person'", 'null': 'True', 'symmetrical': 'False', 'to': "orm['ishtar_common.Import']"}), + 'merge_candidate': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_candidate_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Person']"}), + 'merge_exclusion': ('django.db.models.fields.related.ManyToManyField', [], {'blank': 'True', 'related_name': "'merge_exclusion_rel_+'", 'null': 'True', 'to': "orm['ishtar_common.Person']"}), + 'merge_key': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'mobile_phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'person_types': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['ishtar_common.PersonType']", 'symmetrical': 'False'}), + 'phone': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone2': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone3': ('django.db.models.fields.CharField', [], {'max_length': '18', 'null': 'True', 'blank': 'True'}), + 'phone_desc': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc2': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'phone_desc3': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'raw_name': ('django.db.models.fields.CharField', [], {'max_length': '300', 'null': 'True', 'blank': 'True'}), + 'raw_phone': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'surname': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'town': ('django.db.models.fields.CharField', [], {'max_length': '70', 'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.persontype': { + 'Meta': {'ordering': "('label',)", 'object_name': 'PersonType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['auth.Group']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.regexp': { + 'Meta': {'object_name': 'Regexp'}, + 'description': ('django.db.models.fields.CharField', [], {'max_length': '500', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'regexp': ('django.db.models.fields.CharField', [], {'max_length': '500'}) + }, + 'ishtar_common.sourcetype': { + 'Meta': {'object_name': 'SourceType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.state': { + 'Meta': {'ordering': "['number']", 'object_name': 'State'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '30'}), + 'number': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '3'}) + }, + 'ishtar_common.supporttype': { + 'Meta': {'object_name': 'SupportType'}, + 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'txt_idx': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}) + }, + 'ishtar_common.targetkey': { + 'Meta': {'unique_together': "(('target', 'key', 'associated_user', 'associated_import'),)", 'object_name': 'TargetKey'}, + 'associated_import': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Import']", 'null': 'True', 'blank': 'True'}), + 'associated_user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.IshtarUser']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_set': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'key': ('django.db.models.fields.TextField', [], {}), + 'target': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'keys'", 'to': "orm['ishtar_common.ImportTarget']"}), + 'value': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}) + }, + 'ishtar_common.town': { + 'Meta': {'ordering': "['numero_insee']", 'object_name': 'Town'}, + 'canton': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Canton']", 'null': 'True', 'blank': 'True'}), + 'center': ('django.contrib.gis.db.models.fields.PointField', [], {'srid': '27572', 'null': 'True', 'blank': 'True'}), + 'departement': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['ishtar_common.Department']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'numero_insee': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '6'}), + 'surface': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}) + } + } + + complete_apps = ['ishtar_common']
\ No newline at end of file diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 21b96d85b..87cad0d72 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -326,13 +326,34 @@ class GeneralType(models.Model, Cached): @classmethod def get_types(cls, dct={}, instances=False, exclude=[], empty_first=True, default=None): + # cache + cache_key = None + if not instances: + keys = [u"{}".format(ex) for ex in exclude] + [ + empty_first and 'empty_first' or ''] + [u"{}".format(default)] + cache_key, value = get_cache(cls, keys) + if value: + return value base_dct = dct.copy() if hasattr(cls, 'parent'): - return cls._get_parent_types( - base_dct, instances, exclude=exclude, empty_first=empty_first, - default=default) - return cls._get_types(base_dct, instances, exclude=exclude, - empty_first=empty_first, default=default) + if not cache_key: + return cls._get_parent_types( + base_dct, instances, exclude=exclude, + empty_first=empty_first, default=default) + vals = [v for v in cls._get_parent_types( + base_dct, instances, exclude=exclude, + empty_first=empty_first, default=default)] + cache.set(cache_key, vals, settings.CACHE_TIMEOUT) + return vals + + if not cache_key: + return cls._get_types(base_dct, instances, exclude=exclude, + empty_first=empty_first, default=default) + vals = [v for v in cls._get_types( + base_dct, instances, exclude=exclude, empty_first=empty_first, + default=default)] + cache.set(cache_key, vals, settings.CACHE_TIMEOUT) + return vals @classmethod def _get_types(cls, dct={}, instances=False, exclude=[], empty_first=True, @@ -564,7 +585,11 @@ class ImageModel(models.Model): save=False) if old_path != self.image.path: - os.remove(old_path) + try: + os.remove(old_path) + except OSError: + # already clean + pass # save the thumbnail self.thumbnail.save( @@ -661,6 +686,13 @@ class BaseHistorizedItem(Imported): except IndexError: return + @property + def history_creation_date(self): + try: + return self.history.order_by('history_date').all()[0].history_date + except IndexError: + return + def rollback(self, date): """ Rollback to a previous state @@ -811,6 +843,38 @@ class LightHistorizedItem(BaseHistorizedItem): super(LightHistorizedItem, self).save(*args, **kwargs) return True +PARSE_FORMULA = re.compile("{([^}]*)}") + + +def get_external_id(key, item): + profile = get_current_profile() + if not hasattr(profile, key): + return + formula = getattr(profile, key) + dct = {} + for fkey in PARSE_FORMULA.findall(formula): + if fkey.startswith('settings__'): + dct[fkey] = getattr(settings, fkey[len('settings__'):]) or '' + continue + obj = item + for k in fkey.split('__'): + try: + obj = getattr(obj, k) + except ObjectDoesNotExist: + obj = None + if callable(obj): + obj = obj() + if obj is None: + break + if obj is None: + dct[fkey] = '' + else: + dct[fkey] = obj + return formula.format(**dct) + +CURRENCY = ((u"€", _(u"Euro")), + (u"$", _(u"US dollar"))) + class IshtarSiteProfile(models.Model, Cached): slug_field = 'slug' @@ -829,7 +893,45 @@ class IshtarSiteProfile(models.Model, Cached): _(u"Home page"), null=True, blank=True, help_text=_(u"Homepage of Ishtar - if not defined a default homepage " u"will appear. Use the markdown syntax.")) + file_external_id = models.TextField( + _(u"File external id"), + default="{settings__ISHTAR_LOCAL_PREFIX}{year}-{numeric_reference}", + help_text=_(u"Formula to manage file external ID. " + u"Change this with care. With incorrect formula, the " + u"application might be unusable and import of external " + u"data can be destructive.")) + parcel_external_id = models.TextField( + _(u"Parcel external id"), + default="{associated_file__external_id}{operation__code_patriarche}-" + "{town__numero_insee}-{section}{parcel_number}", + help_text=_(u"Formula to manage parcel external ID. " + u"Change this with care. With incorrect formula, the " + u"application might be unusable and import of external " + u"data can be destructive.")) + context_record_external_id = models.TextField( + _(u"Context record external id"), + default="{parcel__external_id}-{label}", + help_text=_(u"Formula to manage context record external ID. " + u"Change this with care. With incorrect formula, the " + u"application might be unusable and import of external " + u"data can be destructive.")) + base_find_external_id = models.TextField( + _(u"Base find external id"), + default="{context_record__external_id}-{label}", + help_text=_(u"Formula to manage base find external ID. " + u"Change this with care. With incorrect formula, the " + u"application might be unusable and import of external " + u"data can be destructive.")) + find_external_id = models.TextField( + _(u"Find external id"), + default="{get_first_base_find__context_record__external_id}-{label}", + help_text=_(u"Formula to manage find external ID. " + u"Change this with care. With incorrect formula, the " + u"application might be unusable and import of external " + u"data can be destructive.")) active = models.BooleanField(_(u"Current active"), default=False) + currency = models.CharField(_(u"Currency"), default=u"€", + choices=CURRENCY, max_length='5') class Meta: verbose_name = _(u"Ishtar site profile") @@ -2239,6 +2341,21 @@ class Person(Address, Merge, OwnPerms, ValueGetter): if getattr(self, attr)] return slugify(u"-".join(values)) + def operation_docs_q(self): + from archaeological_operations.models import OperationSource + return OperationSource.objects.filter( + authors__person=self) + + def contextrecord_docs_q(self): + from archaeological_context_records.models import ContextRecordSource + return ContextRecordSource.objects.filter( + authors__person=self) + + def find_docs_q(self): + from archaeological_finds.models import FindSource + return FindSource.objects.filter( + authors__person=self) + def save(self, *args, **kwargs): super(Person, self).save(*args, **kwargs) if hasattr(self, 'responsible_town_planning_service'): @@ -2250,6 +2367,9 @@ class Person(Address, Merge, OwnPerms, ValueGetter): class IshtarUser(User): + TABLE_COLS = ('username', 'person__name', 'person__surname', + 'person__email', 'person__person_types_list', + 'person__attached_to') person = models.ForeignKey(Person, verbose_name=_(u"Person"), unique=True, related_name='ishtaruser') @@ -2296,6 +2416,9 @@ class IshtarUser(User): cache.set(cache_key, res, settings.CACHE_SMALLTIMEOUT) return res +IshtarUser._meta.get_field('password').help_text = _( + u"To modify the password use the form in Auth > User") + class AuthorType(GeneralType): class Meta: @@ -2374,7 +2497,8 @@ class Source(models.Model): additional_information = models.TextField(_(u"Additional information"), blank=True, null=True) duplicate = models.BooleanField(_(u"Has a duplicate"), default=False) - TABLE_COLS = ['title', 'source_type', 'authors', ] + TABLE_COLS = ['title', 'source_type', 'authors', 'associated_url'] + COL_LINK = ['associated_url'] class Meta: abstract = True diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css index 8916dce0b..7aef23099 100644 --- a/ishtar_common/static/media/style.css +++ b/ishtar_common/static/media/style.css @@ -277,7 +277,8 @@ div#header{ box-sizing: border-box; } -div#logo{ +#logo{ + display: block; width:200px; top:40px; left:10px; @@ -583,6 +584,10 @@ ul.form-flex label { padding-left: 10px; } +ul.form-flex li li label { + width: 300px; +} + #window ul.form-flex label { width: 150px; } @@ -1104,7 +1109,12 @@ a.remove{ } .form p.input input.widget-parcel{ - width:85px; + width:50px; +} + +.form p.input input.widget-oa, +input.widget-oa{ + width:100px; } .small, .small input{ diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index 02ddb85df..1a7c8fa54 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -61,9 +61,9 @@ <i class="fa fa-arrow-circle-up" aria-hidden="true"></i> </div> <div id="window"></div> - <div id="logo"> + <a href='{% url "start" %}' id="logo"> {% if APP_NAME %}<p id="app_name">{{APP_NAME}}</p>{%endif%} - </div> + </a> {% if not reminders %}<div id="context_menu"> {% block context %}{% if current_menu %} <form method="post" action="{% url 'update-current-item' %}"> diff --git a/ishtar_common/templates/ishtar/sheet_person.html b/ishtar_common/templates/ishtar/sheet_person.html index 90b65b72c..3c554acdf 100644 --- a/ishtar_common/templates/ishtar/sheet_person.html +++ b/ishtar_common/templates/ishtar/sheet_person.html @@ -83,27 +83,20 @@ {% dynamic_table_document af 'files' 'in_charge' item.pk '' output %} {% endif %} -<table> - <caption>{%trans "Documents"%}</caption> - <tr> - <th>{% trans "Year" %}</th> - <th>{% trans "Title" %}</th> - <th>{% trans "Type" %}</th> - <th>{% trans "Link" %}</th> - </tr> - {% for author in item.author.all %} - {% for doc in author.related_sources %} - <tr> - <td class='string'>{{ doc.creation_date|date:"Y"}}</td> - <td class='string'>{{ doc.title }}</td> - <td class='string'>{{ doc.source_type }}</td> - <td class='string'>{% if doc.associated_url %}<a href='{{doc.associated_url}}'>{% trans "Link"%}</a>{% endif %}</td> - </tr> - {% endfor %} - {% empty %} - <tr><td colspan="4" class='no_items'>{% trans "No document associated to this person" %}</td></tr> - {% endfor %} -</table> +{% if item.operation_docs_q.count %} +{% trans "Documents associated to operations" as operation_docs %} +{% dynamic_table_document operation_docs 'operation_docs' 'person' item.pk '' output %} +{% endif %} + +{% if item.contextrecord_docs_q.count %} +{% trans "Documents associated to context records" as context_records %} +{% dynamic_table_document context_records 'context_records_docs' 'person' item.pk '' output %} +{% endif %} + +{% if item.find_docs_q.count %} +{% trans "Documents associated to finds" as finds_docs %} +{% dynamic_table_document finds_docs 'finds_docs' 'person' item.pk '' output %} +{% endif %} {% endblock %} diff --git a/ishtar_common/templatetags/window_tables.py b/ishtar_common/templatetags/window_tables.py index 6710672e1..03365c207 100644 --- a/ishtar_common/templatetags/window_tables.py +++ b/ishtar_common/templatetags/window_tables.py @@ -16,7 +16,7 @@ from archaeological_files.models import File from archaeological_operations.models import OperationSource, Operation from archaeological_context_records.models import ContextRecord, \ ContextRecordSource -from archaeological_finds.models import Find, FindSource +from archaeological_finds.models import Find, FindSource, FindTreatments register = template.Library() @@ -43,6 +43,8 @@ ASSOCIATED_MODELS['finds_for_ope'] = ( Find, 'get-find-for-ope', 'get-find-full') ASSOCIATED_MODELS['finds_docs'] = ( FindSource, 'get-findsource', 'get-findsource-full') +ASSOCIATED_MODELS['finds_treatments'] = ( + FindTreatments, 'get-treatment', 'get-treatment-full') @register.simple_tag(takes_context=True) diff --git a/ishtar_common/tests.py b/ishtar_common/tests.py index 1b8601dfb..b779af221 100644 --- a/ishtar_common/tests.py +++ b/ishtar_common/tests.py @@ -17,7 +17,7 @@ # See the file COPYING for details. -from BeautifulSoup import BeautifulSoup as Soup +from bs4 import BeautifulSoup as Soup from django.conf import settings from django.contrib.auth.models import User diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index a3bcaffb5..daaac77e3 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -81,9 +81,15 @@ urlpatterns = patterns( check_rights(['change_organization', 'change_own_organization'])( views.OrganizationPersonEdit.as_view()), name='organization_person_edit'), + url(r'get-ishtaruser/(?P<type>.+)?$', + views.get_ishtaruser, + name='get-ishtaruser'), url(r'account_management/(?P<step>.+)?$', check_rights(['add_ishtaruser'])( views.account_management_wizard), name='account_management'), + url(r'account_deletion/(?P<step>.+)?$', + check_rights(['add_ishtaruser'])( + views.account_deletion_wizard), name='account_deletion'), url(r'^import-new/$', check_rights(['change_import'])( views.NewImportView.as_view()), name='new_import'), @@ -133,6 +139,8 @@ urlpatterns += patterns( name='autocomplete-person-permissive'), url(r'get-person/(?P<type>.+)?$', 'get_person', name='get-person'), + url(r'get-person-full/(?P<type>.+)?$', 'get_person', + name='get-person-full', kwargs={'full': True}), url(r'show-person(?:/(?P<pk>.+))?/(?P<type>.+)?$', 'show_person', name='show-person'), url(r'department-by-state/(?P<state_id>.+)?$', 'department_by_state', @@ -152,6 +160,8 @@ urlpatterns += patterns( 'new_organization', name='new-organization'), url(r'get-organization/(?P<type>.+)?$', 'get_organization', name='get-organization'), + url(r'get-organization-full/(?P<type>.+)?$', 'get_organization', + name='get-organization-full', kwargs={'full': True}), url(r'show-organization(?:/(?P<pk>.+))?/(?P<type>.+)?$', 'show_organization', name='show-organization'), url(r'autocomplete-organization/([0-9_]+)?$', diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 0624d13d0..bbe790efa 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -19,6 +19,7 @@ from tidylib import tidy_document as tidy +from copy import copy import csv import cStringIO as StringIO import datetime @@ -38,6 +39,7 @@ from django.contrib.auth.decorators import login_required from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import reverse, NoReverseMatch from django.db.models import Q, ImageField +from django.db.models.fields import FieldDoesNotExist from django.forms.models import modelformset_factory from django.http import HttpResponse, Http404, HttpResponseRedirect, \ HttpResponseBadRequest @@ -148,12 +150,18 @@ organization_deletion_wizard = wizards.OrganizationDeletionWizard.as_view( url_name='organization_deletion',) account_management_wizard = wizards.AccountWizard.as_view( - [('selec-account_management', forms.PersonFormSelection), + [('selec-account_management', forms.PersonUserFormSelection), ('account-account_management', forms.AccountForm), ('final-account_management', forms.FinalAccountForm)], label=_(u"Account management"), url_name='account_management',) +account_deletion_wizard = wizards.IshtarUserDeletionWizard.as_view( + [('selec-account_deletion', forms.AccountFormSelection), + ('final-account_deletion', FinalDeleteForm)], + label=_(u"Account deletion"), + url_name='account_deletion',) + def get_autocomplete_generic(model, extra={'available': True}): def func(request): @@ -335,7 +343,7 @@ HIERARCHIC_FIELDS = ['periods', 'period', 'unit', 'material_types', def get_item(model, func_name, default_name, extra_request_keys=[], base_request={}, bool_fields=[], reversed_bool_fields=[], dated_fields=[], associated_models=[], relative_session_names={}, - specific_perms=[], own_table_cols=None): + specific_perms=[], own_table_cols=None, relation_types_prefix={}): """ Generic treatment of tables """ @@ -399,11 +407,19 @@ def get_item(model, func_name, default_name, extra_request_keys=[], except ValueError: return HttpResponse('[]', mimetype='text/plain') - relation_types = set() - for k in request_items: - if k.startswith('relation_types_'): - relation_types.add(request_items[k]) - continue + # manage relations types + my_rtypes_prefix = copy(relation_types_prefix) + if 'relation_types' not in my_rtypes_prefix: + my_rtypes_prefix['relation_types'] = '' + relation_types = {} + for rtype_key in my_rtypes_prefix: + relation_types[my_rtypes_prefix[rtype_key]] = set() + for k in request_items: + if k.startswith(rtype_key): + relation_types[my_rtypes_prefix[rtype_key]].add( + request_items[k]) + continue + for k in request_keys: val = request_items.get(k) if not val: @@ -447,14 +463,19 @@ def get_item(model, func_name, default_name, extra_request_keys=[], if k in reversed_bool_fields: dct[k] = not dct[k] # check also for empty value with image field - c_field = model._meta.get_field(k.split('__')[0]) - if k.endswith('__isnull') and \ - isinstance(c_field, ImageField): - if dct[k]: - or_reqs.append( - (k, {k.split('__')[0] + '__exact': ''})) - else: - dct[k.split('__')[0] + '__regex'] = '.{1}.*' + field_name = k.split('__')[0] + # TODO: can be improved in later evrsion of Django + try: + c_field = model._meta.get_field(field_name) + if k.endswith('__isnull') and \ + isinstance(c_field, ImageField): + if dct[k]: + or_reqs.append( + (k, {k.split('__')[0] + '__exact': ''})) + else: + dct[k.split('__')[0] + '__regex'] = '.{1}.*' + except FieldDoesNotExist: + pass for k in dated_fields: if k in dct: if not dct[k]: @@ -497,14 +518,26 @@ def get_item(model, func_name, default_name, extra_request_keys=[], alt_dct.update(or_req) query = query | Q(**alt_dct) - if relation_types: + for rtype_prefix in relation_types: + vals = list(relation_types[rtype_prefix]) + if not vals: + continue alt_dct = { - 'right_relations__relation_type__pk__in': list(relation_types)} + rtype_prefix + 'right_relations__relation_type__pk__in': vals} for k in dct: val = dct[k] - if k == 'year': - k = 'year__exact' - alt_dct['right_relations__right_record__' + k] = val + if rtype_prefix: + # only get conditions related to the object + if rtype_prefix not in k: + continue + # tricky: reconstruct the key to make sense - remove the + # prefix from the key + k = k[0:k.index(rtype_prefix)] + k[ + k.index(rtype_prefix) + len(rtype_prefix):] + if k.endswith('year'): + k += '__exact' + alt_dct[rtype_prefix + 'right_relations__right_record__' + k] =\ + val if not dct: # fake condition to trick Django (1.4): without it only the # alt_dct is managed @@ -517,7 +550,9 @@ def get_item(model, func_name, default_name, extra_request_keys=[], val = or_req[j] if j == 'year': j = 'year__exact' - altor_dct['right_relations__right_record__' + j] = val + altor_dct[ + rtype_prefix + 'right_relations__right_record__' + j] =\ + val query = query | Q(**altor_dct) if own: @@ -527,6 +562,7 @@ def get_item(model, func_name, default_name, extra_request_keys=[], query = query & and_req items = model.objects.filter(query).distinct() + # print(items.query) q = request_items.get('sidx') # table cols @@ -614,7 +650,14 @@ def get_item(model, func_name, default_name, extra_request_keys=[], my_vals = [] for k in keys: vals = [item] + # foreign key may be splited by "." or "__" + splitted_k = [] for ky in k.split('.'): + if '__' in ky: + splitted_k += ky.split('__') + else: + splitted_k.append(ky) + for ky in splitted_k: new_vals = [] for val in vals: if hasattr(val, 'all'): # manage related objects @@ -669,6 +712,7 @@ def get_item(model, func_name, default_name, extra_request_keys=[], link_template = "<a class='display_details' href='#' "\ "onclick='load_window(\"%s\")'>"\ "<i class=\"fa fa-info-circle\" aria-hidden=\"true\"></i></a>" + link_ext_template = '<a href="{}" target="_blank">{}</a>' if data_type == "json": rows = [] for data in datas: @@ -685,7 +729,18 @@ def get_item(model, func_name, default_name, extra_request_keys=[], table_col = table_cols[idx] if type(table_col) not in (list, tuple): table_col = [table_col] - k = "__".join([tc.split('.')[-1] for tc in table_col]) + tab_cols = [] + # foreign key may be splited by "." or "__" + for tc in table_col: + if '.' in tc: + tab_cols.append(tc.split('.')[-1]) + elif '__' in tc: + tab_cols.append(tc.split('__')[-1]) + else: + tab_cols.append(tc) + k = "__".join(tab_cols) + if hasattr(model, 'COL_LINK') and k in model.COL_LINK: + value = link_ext_template.format(value, value) res[k] = value rows.append(res) data = json.dumps({ @@ -720,7 +775,8 @@ def get_item(model, func_name, default_name, extra_request_keys=[], unicode(field.verbose_name).encode(ENCODING)) writer.writerow(col_names) for data in datas: - writer.writerow([val.encode(ENCODING) for val in data[1:]]) + writer.writerow([val.encode(ENCODING, errors='replace') + for val in data[1:]]) return response return HttpResponse('{}', mimetype='text/plain') @@ -736,6 +792,7 @@ def show_item(model, name, extra_dct=None): doc_type = 'type' in dct and dct.pop('type') url_name = u"/".join(reverse('show-' + name, args=['0', ''] ).split('/')[:-2]) + u"/" + dct['CURRENCY'] = get_current_profile().currency dct['current_window_url'] = url_name date = 'date' in dct and dct.pop('date') dct['window_id'] = "%s-%d-%s" % ( @@ -940,11 +997,26 @@ show_person = show_item(models.Person, 'person') get_person = get_item( models.Person, 'get_person', 'person', + reversed_bool_fields=['ishtaruser__isnull'], extra_request_keys={ 'name': ['name__icontains', 'raw_name__icontains'], 'surname': ['surname__icontains', 'raw_name__icontains'], 'attached_to': 'attached_to__pk', 'person_types': 'person_types__pk__in', + 'ishtaruser__isnull': 'ishtaruser__isnull' + }) + +get_ishtaruser = get_item( + models.IshtarUser, + 'get_ishtaruser', 'ishtaruser', + extra_request_keys={ + 'username': ['username__icontains'], + 'name': ['person__name__icontains', 'person__raw_name__icontains'], + 'surname': ['person__surname__icontains', + 'person__raw_name__icontains'], + 'email': ['person__email'], + 'attached_to': 'person__attached_to__pk', + 'person_types': 'person__person_types__pk__in', }) diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 6d9600d0c..89eead988 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -144,6 +144,8 @@ class JQueryDate(forms.TextInput): self.attrs['class'] = 'date-pickup' def render(self, name, value=None, attrs=None): + if value: + value = unicode(value) # very specific... if settings.COUNTRY == 'fr' and value and '/' in value: values = value.split('/') @@ -539,7 +541,9 @@ class JQueryJqGrid(forms.RadioSelect): col_names = [col_names] for col_name in col_names: field = self.associated_model - keys = col_name.split('.') + keys = col_name.split('__') + if '.' in col_name: + keys = col_name.split('.') f_name = '' for key in keys: if hasattr(field, 'rel') and field.rel: diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py index 49abe606f..1ac28d640 100644 --- a/ishtar_common/wizards.py +++ b/ishtar_common/wizards.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (C) 2010-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> +# Copyright (C) 2010-2016 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -90,6 +90,25 @@ def check_rights_condition(rights): return False return func +# buggy and unecessary at least for the moment... +""" +def _check_right(step, condition=True): + '''Return a method to check the right for a specific step''' + def check_right(self): + cond = condition + if callable(condition): + cond = condition(self) + if not cond: + return False + return True + # TODO: to be check + if not hasattr(self.request.user, 'ishtaruser'): + return False + return self.request.user.ishtaruser.has_right( + ('administrator', step), session=self.request.session) + return check_right +""" + class Wizard(NamedUrlWizardView): model = None @@ -105,32 +124,16 @@ class Wizard(NamedUrlWizardView): filter_owns = {} current_obj_slug = '' - @staticmethod - def _check_right(step, condition=True): - '''Return a method to check the right for a specific step''' - def check_right(self): - cond = condition - if callable(condition): - cond = condition(self) - if not cond: - return False - return True - # TODO: to be check - if not hasattr(self.request.user, 'ishtaruser'): - return False - return self.request.user.ishtaruser.has_right( - ('administrator', step), session=self.request.session) - return check_right - + ''' + # buggy and unecessary... def __init__(self, *args, **kwargs): """Check right for each step of the wizard""" super(Wizard, self).__init__(*args, **kwargs) for form_key in self.form_list.keys()[:-1]: - condition = True - if form_key in self.condition_dict: - condition = self.condition_dict.get(form_key, True) - cond = self._check_right(form_key, condition) + condition = self.condition_dict.get(form_key, True) + cond = _check_right(form_key, condition) self.condition_dict[form_key] = cond + ''' def dispatch(self, request, *args, **kwargs): self.current_right = kwargs.get('current_right', None) @@ -659,19 +662,23 @@ class Wizard(NamedUrlWizardView): frm = form.form if callable(frm): frm = frm() - required_fields = [ki for ki in frm.fields - if frm.fields[ki].required] - base_key = None - if required_fields: - base_key = required_fields[-1] - elif frm.fields.keys(): - base_key = frm.fields.keys()[-1] - init = self.get_form_initial(step, data=data) + total_field = 0 - if base_key: - total_field = len([key for key in data.keys() - if base_key in key.split('-') - and data[key]]) + if hasattr(frm, 'count_valid_fields'): + total_field = frm.count_valid_fields(data) + else: + required_fields = [ki for ki in frm.fields + if frm.fields[ki].required] + base_key = None + if required_fields: + base_key = required_fields[-1] + elif frm.fields.keys(): + base_key = frm.fields.keys()[-1] + if base_key: + total_field = len([key for key in data.keys() + if base_key in key.split('-') + and data[key]]) + init = self.get_form_initial(step, data=data) if init and not to_delete and ( not hasattr(self, 'form_initialized') or not self.form_initialized): @@ -1129,6 +1136,11 @@ class PersonDeletionWizard(DeletionWizard): 'final-person_deletion': 'ishtar/wizard/wizard_person_deletion.html'} +class IshtarUserDeletionWizard(DeletionWizard): + model = models.IshtarUser + fields = model.TABLE_COLS + + class OrganizationWizard(Wizard): model = models.Organization |
