diff options
| -rw-r--r-- | archaeological_context_records/models.py | 5 | ||||
| -rw-r--r-- | archaeological_files/models.py | 2 | ||||
| -rw-r--r-- | archaeological_finds/models_finds.py | 3 | ||||
| -rw-r--r-- | archaeological_finds/models_treatments.py | 4 | ||||
| -rw-r--r-- | archaeological_operations/models.py | 14 | ||||
| -rw-r--r-- | example_project/local_settings.py.gitlab-ci | 2 | ||||
| -rw-r--r-- | example_project/local_settings.py.sample | 1 | ||||
| -rwxr-xr-x | example_project/manage.py | 17 | ||||
| -rw-r--r-- | example_project/settings.py | 11 | ||||
| -rw-r--r-- | ishtar_common/__init__.py | 2 | ||||
| -rw-r--r-- | ishtar_common/model_merging.py | 4 | ||||
| -rw-r--r-- | ishtar_common/models.py | 24 | 
12 files changed, 40 insertions, 49 deletions
| diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index bb3afc899..3fdc04f21 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -234,8 +234,7 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms,          help_text=_(u"A short description of the location of the context "                      u"record"))      datings = models.ManyToManyField(Dating) -    documentations = models.ManyToManyField(DocumentationType, blank=True, -                                            null=True) +    documentations = models.ManyToManyField(DocumentationType, blank=True)      datings_comment = models.TextField(_(u"Comment on datings"), blank=True,                                         null=True)      unit = models.ForeignKey(Unit, verbose_name=_(u"Context record type"), @@ -266,7 +265,7 @@ class ContextRecord(BaseHistorizedItem, ImageModel, OwnPerms,          ExcavationTechnicType, blank=True, null=True,          verbose_name=_(u"Excavation technique"))      related_context_records = models.ManyToManyField( -        'ContextRecord', through='RecordRelations', blank=True, null=True) +        'ContextRecord', through='RecordRelations', blank=True)      point = models.PointField(_(u"Point"), blank=True, null=True, dim=3)      polygon = models.PolygonField(_(u"Polygon"), blank=True, null=True)      cached_label = models.TextField(_(u"Cached name"), null=True, blank=True) diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 52f628817..08c7edf8c 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -180,7 +180,7 @@ class File(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,      comment = models.TextField(_(u"Comment"), null=True, blank=True)      # research archaeology -->      departments = models.ManyToManyField( -        Department, verbose_name=_(u"Departments"), null=True, blank=True) +        Department, verbose_name=_(u"Departments"), blank=True)      requested_operation_type = models.ForeignKey(          OperationType, related_name='+', null=True,          blank=True, verbose_name=_(u"Requested operation type")) diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index d33933264..b5e58a98b 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -450,8 +450,7 @@ CHECK_CHOICES = (('NC', _(u"Not checked")),  class FindBasket(Basket): -    items = models.ManyToManyField('Find', blank=True, null=True, -                                   related_name='basket') +    items = models.ManyToManyField('Find', blank=True, related_name='basket')  class FirstBaseFindView(object): diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 47f60bb44..8fcf37b9c 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -297,8 +297,8 @@ pre_delete.connect(pre_delete_treatment, sender=Treatment)  class AbsFindTreatments(models.Model):      find = models.ForeignKey(Find, verbose_name=_(u"Find"),                               related_name='%(class)s_related') -    treatment = models.ForeignKey(Treatment, verbose_name=_(u"Treatment"), -                                  primary_key=True) +    treatment = models.OneToOneField(Treatment, verbose_name=_(u"Treatment"), +                                     primary_key=True)      # primary_key is set to prevent django to ask for an id column      # treatment is not a primary key      treatment_nb = models.IntegerField(_(u"Order")) diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 3826678c3..bebeba240 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -86,9 +86,9 @@ class ArchaeologicalSite(BaseHistorizedItem):      name = models.CharField(_(u"Name"), max_length=200,                              null=True, blank=True)      periods = models.ManyToManyField(Period, verbose_name=_(u"Periods"), -                                     blank=True, null=True) +                                     blank=True)      remains = models.ManyToManyField("RemainType", verbose_name=_(u'Remains'), -                                     blank=True, null=True) +                                     blank=True)      class Meta:          verbose_name = _(u"Archaeological site") @@ -270,7 +270,7 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,                                    on_delete=models.SET_NULL,                                    related_name='operation_responsability')      collaborators = models.ManyToManyField( -        Person, blank=True, null=True, verbose_name=_(u"Collaborators"), +        Person, blank=True, verbose_name=_(u"Collaborators"),          related_name='operation_collaborator'      )      year = models.IntegerField(_(u"Year"), null=True, blank=True) @@ -284,13 +284,13 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,                                         verbose_name=_(u"Operation type"))      surface = models.IntegerField(_(u"Surface (m2)"), blank=True, null=True)      remains = models.ManyToManyField("RemainType", verbose_name=_(u'Remains'), -                                     null=True, blank=True) +                                     blank=True)      towns = models.ManyToManyField(Town, verbose_name=_(u"Towns"),                                     related_name='operations')      cost = models.IntegerField(_(u"Cost (euros)"),                                 blank=True, null=True)  # preventive      periods = models.ManyToManyField(Period, verbose_name=_(u"Periods"), -                                     null=True, blank=True) +                                     blank=True)      # preventive      scheduled_man_days = models.IntegerField(_(u"Scheduled man-days"),                                               blank=True, null=True) @@ -343,7 +343,7 @@ class Operation(ClosedItem, BaseHistorizedItem, ImageModel, OwnPerms,                                      null=True, blank=True)      archaeological_sites = models.ManyToManyField(          ArchaeologicalSite, verbose_name=_(u"Archaeological sites"), -        null=True, blank=True) +        blank=True)      virtual_operation = models.BooleanField(          _(u"Virtual operation"),          default=False, help_text=_( @@ -927,7 +927,7 @@ class ActType(GeneralType):                                     choices=TYPE)      code = models.CharField(_(u"Code"), max_length=10, blank=True, null=True)      associated_template = models.ManyToManyField( -        DocumentTemplate, blank=True, null=True, +        DocumentTemplate, blank=True,          verbose_name=_(u"Associated template"), related_name='acttypes')      indexed = models.BooleanField(_(u"Indexed"), default=False) diff --git a/example_project/local_settings.py.gitlab-ci b/example_project/local_settings.py.gitlab-ci index 81196b4a0..e7f923205 100644 --- a/example_project/local_settings.py.gitlab-ci +++ b/example_project/local_settings.py.gitlab-ci @@ -13,3 +13,5 @@ LOGFILE = '/tmp/ishtar.log'  PROJECT_SLUG = "CI-instance"  USE_SPATIALITE_FOR_TESTS = False + +SECRET_KEY = "not-so-secret-key" diff --git a/example_project/local_settings.py.sample b/example_project/local_settings.py.sample index 5a7550d9a..4c07f7152 100644 --- a/example_project/local_settings.py.sample +++ b/example_project/local_settings.py.sample @@ -4,6 +4,7 @@  # rename this file to local_settings.py and overload settings in this file  # Make this string unique, and don't share it with anybody. +# Don't leave it empty  SECRET_KEY = ''  ADMINS = ( diff --git a/example_project/manage.py b/example_project/manage.py index 4981a4830..80114eb68 100755 --- a/example_project/manage.py +++ b/example_project/manage.py @@ -1,15 +1,12 @@  #!/usr/bin/env python -from django.core.management import execute_manager -import os, sys +import os +import sys  sys.path.append(os.path.abspath('..')) -try: -    import settings # Assumed to be in the same directory. -except ImportError: -    import sys -    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) -    sys.exit(1) -  if __name__ == "__main__": -    execute_manager(settings) +    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") + +    from django.core.management import execute_from_command_line + +    execute_from_command_line(sys.argv) diff --git a/example_project/settings.py b/example_project/settings.py index 78d97f0ae..eaa1fb7f5 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -137,10 +137,8 @@ INSTALLED_APPS = [      'django.contrib.sites',      'django.contrib.gis',      'django.contrib.staticfiles', -    'django.contrib.formtools',      'django.contrib.messages',      'django.contrib.humanize', -    'south',      'registration',      # 'geodjangofla',      'ishtar_pdl', @@ -242,12 +240,9 @@ except ImportError, e:  TESTING = sys.argv[1:2] == ['test'] -if TESTING: -    SOUTH_TESTS_MIGRATE = False - -    if USE_SPATIALITE_FOR_TESTS: -        DATABASES['default']['ENGINE'] = \ -            'django.contrib.gis.db.backends.spatialite' +if TESTING and USE_SPATIALITE_FOR_TESTS: +    DATABASES['default']['ENGINE'] = \ +        'django.contrib.gis.db.backends.spatialite'  PROJECT_SLUG = locals().get('PROJECT_SLUG', 'default') diff --git a/ishtar_common/__init__.py b/ishtar_common/__init__.py index 5d2eadd7d..2b432d908 100644 --- a/ishtar_common/__init__.py +++ b/ishtar_common/__init__.py @@ -2,7 +2,7 @@  # -*- coding: utf-8 -*-  # Copyright (C) 2014-2015  Étienne Loks  <etienne.loks_AT_peacefrogsDOTnet> -from django.utils.translation import ugettext as _ +from django.utils.translation import ugettext_lazy as _  # overload of translation of registration module  _(u"username") diff --git a/ishtar_common/model_merging.py b/ishtar_common/model_merging.py index c577a8cf1..b2ed68358 100644 --- a/ishtar_common/model_merging.py +++ b/ishtar_common/model_merging.py @@ -2,10 +2,10 @@  from django.db import transaction  from django.db.models import get_models, Model -from django.contrib.contenttypes.generic import GenericForeignKey +from django.contrib.contenttypes.fields import GenericForeignKey -@transaction.commit_on_success +@transaction.atomic  def merge_model_objects(primary_object, alias_objects=[], keep_old=False):      """      Use this function to merge model objects (i.e. Users, Organizations, Polls, diff --git a/ishtar_common/models.py b/ishtar_common/models.py index f1de8c60a..e1a643ea3 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -55,7 +55,7 @@ from django.template.defaultfilters import slugify  from django.contrib.auth.models import User, Group  from django.contrib.contenttypes.models import ContentType -from django.contrib.contenttypes import generic +from django.contrib.contenttypes.fields import GenericForeignKey  from django.contrib.gis.db import models  from simple_history.models import HistoricalRecords as BaseHistoricalRecords @@ -130,7 +130,7 @@ def check_model_access_control(request, model, available_perms=None):  class Imported(models.Model):      imports = models.ManyToManyField( -        'Import', blank=True, null=True, +        'Import', blank=True,          related_name="imported_%(app_label)s_%(class)s")      class Meta: @@ -772,7 +772,7 @@ class ItemKey(models.Model):      key = models.CharField(_(u"Key"), max_length=100)      content_type = models.ForeignKey(ContentType)      object_id = models.PositiveIntegerField() -    content_object = generic.GenericForeignKey('content_type', 'object_id') +    content_object = GenericForeignKey('content_type', 'object_id')      importer = models.ForeignKey(          'Import', null=True, blank=True,          help_text=_(u"Specific key to an import")) @@ -1695,10 +1695,8 @@ class Address(BaseHistorizedItem):  class Merge(models.Model):      merge_key = models.TextField(_("Merge key"), blank=True, null=True) -    merge_candidate = models.ManyToManyField("self", -                                             blank=True, null=True) -    merge_exclusion = models.ManyToManyField("self", -                                             blank=True, null=True) +    merge_candidate = models.ManyToManyField("self", blank=True) +    merge_exclusion = models.ManyToManyField("self", blank=True)      archived = models.NullBooleanField(default=False,                                         blank=True, null=True)      # 1 for one word similarity, 2 for two word similarity, etc. @@ -1837,13 +1835,13 @@ class ImporterType(models.Model):      description = models.CharField(_(u"Description"), blank=True, null=True,                                     max_length=500)      users = models.ManyToManyField('IshtarUser', verbose_name=_(u"Users"), -                                   blank=True, null=True) +                                   blank=True)      associated_models = models.ForeignKey(          ImporterModel, verbose_name=_(u"Associated model"),          related_name='+', blank=True, null=True)      created_models = models.ManyToManyField(          ImporterModel, verbose_name=_(u"Models that can accept new items"), -        blank=True, null=True, help_text=_(u"Leave blank for no restrictions"), +        blank=True, help_text=_(u"Leave blank for no restrictions"),          related_name='+')      is_template = models.BooleanField(_(u"Is template"), default=False)      unicity_keys = models.CharField(_(u"Unicity keys (separator \";\")"), @@ -2603,7 +2601,7 @@ class Organization(Address, Merge, OwnPerms, ValueGetter):  class PersonType(GeneralType):      # rights = models.ManyToManyField(WizardStep, verbose_name=_(u"Rights"))      groups = models.ManyToManyField(Group, verbose_name=_(u"Groups"), -                                    blank=True, null=True) +                                    blank=True)      class Meta:          verbose_name = _(u"Person type") @@ -2868,8 +2866,8 @@ class IshtarUser(User):      }      # fields -    person = models.ForeignKey(Person, verbose_name=_(u"Person"), unique=True, -                               related_name='ishtaruser') +    person = models.OneToOneField(Person, verbose_name=_(u"Person"), +                                  related_name='ishtaruser')      advanced_shortcut_menu = models.BooleanField(          _(u"Advanced shortcut menu"), default=False) @@ -3006,7 +3004,7 @@ class Source(OwnPerms, ImageModel, models.Model):      authors = models.ManyToManyField(Author, verbose_name=_(u"Authors"),                                       related_name="%(class)s_related")      associated_url = models.URLField( -        verify_exists=False, blank=True, null=True, +        blank=True, null=True,          verbose_name=_(u"Numerical ressource (web address)"))      receipt_date = models.DateField(blank=True, null=True,                                      verbose_name=_(u"Receipt date")) | 
