diff options
| -rw-r--r-- | ishtar_common/models.py | 23 | 
1 files changed, 13 insertions, 10 deletions
| diff --git a/ishtar_common/models.py b/ishtar_common/models.py index e0fd05a03..7fa2d73aa 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -53,16 +53,19 @@ from ishtar_common.utils import get_cache  def post_save_user(sender, **kwargs):      user = kwargs['instance']      ishtaruser = None -    q = IshtarUser.objects.filter(username=user.username) -    if not q.count(): -        ishtaruser = IshtarUser.create_from_user(user) -    else: -        ishtaruser = q.all()[0] -    ADMINISTRATOR, created = PersonType.objects.get_or_create( -                                            txt_idx='administrator') -    if ishtaruser.is_superuser \ -       and not ishtaruser.has_right('administrator'): -        ishtaruser.person.person_types.add(ADMINISTRATOR) +    try: +        q = IshtarUser.objects.filter(username=user.username) +        if not q.count(): +            ishtaruser = IshtarUser.create_from_user(user) +        else: +            ishtaruser = q.all()[0] +        ADMINISTRATOR, created = PersonType.objects.get_or_create( +                                                txt_idx='administrator') +        if ishtaruser.is_superuser \ +           and not ishtaruser.has_right('administrator'): +            ishtaruser.person.person_types.add(ADMINISTRATOR) +    except DatabaseError: # manage when db is not synced +        pass  post_save.connect(post_save_user, sender=User)  class ValueGetter(object): | 
