Revision c7b82fdc snf-astakos-app/astakos/im/models.py

b/snf-astakos-app/astakos/im/models.py
66 66

  
67 67
from astakos.im.settings import (
68 68
    DEFAULT_USER_LEVEL, INVITATIONS_PER_LEVEL,
69
    AUTH_TOKEN_DURATION, BILLING_FIELDS,
70
    EMAILCHANGE_ACTIVATION_DAYS, LOGGING_LEVEL,
69
    AUTH_TOKEN_DURATION, EMAILCHANGE_ACTIVATION_DAYS, LOGGING_LEVEL,
71 70
    SITENAME, SERVICES, MODERATION_ENABLED)
72 71
from astakos.im import settings as astakos_settings
73 72
from astakos.im.endpoints.qh import (
74 73
    register_users, register_resources, qh_add_quota, QuotaLimits,
75 74
    qh_query_serials, qh_ack_serials)
76 75
from astakos.im import auth_providers
77
#from astakos.im.endpoints.aquarium.producer import report_user_event
78
#from astakos.im.tasks import propagate_groupmembers_quota
79 76

  
80 77
import astakos.im.messages as astakos_messages
81 78
from .managers import ForUpdateManager
......
1713 1710
    create_astakos_user(instance)
1714 1711
post_save.connect(user_post_save, sender=User)
1715 1712

  
1716
def astakosuser_pre_save(sender, instance, **kwargs):
1717
    instance.aquarium_report = False
1718
    instance.new = False
1719
    try:
1720
        db_instance = AstakosUser.objects.get(id=instance.id)
1721
    except AstakosUser.DoesNotExist:
1722
        # create event
1723
        instance.aquarium_report = True
1724
        instance.new = True
1725
    else:
1726
        get = AstakosUser.__getattribute__
1727
        l = filter(lambda f: get(db_instance, f) != get(instance, f),
1728
                   BILLING_FIELDS)
1729
        instance.aquarium_report = True if l else False
1730
pre_save.connect(astakosuser_pre_save, sender=AstakosUser)
1731

  
1732 1713
def astakosuser_post_save(sender, instance, created, **kwargs):
1733
    if instance.aquarium_report:
1734
        report_user_event(instance, create=instance.new)
1735 1714
    if not created:
1736 1715
        return
1737 1716
    # TODO handle socket.error & IOError

Also available in: Unified diff