예제 #1
0
def fingerprint_updated(sender, **kwargs):
    fingerprint = kwargs['instance']

    if fingerprint.findName() != 'Unnamed':
        fingerprint.setSubscription(fingerprint.owner, True)

    # We also check if the fingerprint was added by a restricted user,
    # if it was we must add this fingerprint to the restricted user, otherwise he wouldnt have access to his own database
    RestrictedUserDbs.get_or_create(fingerprint.owner, fingerprint)
예제 #2
0
def fingerprint_updated(sender, **kwargs):
    fingerprint = kwargs['instance']
    created = kwargs['created']

    if created:
        fingerprint.setSubscription(fingerprint.owner, True)

        # We also check if the fingerprint was added by a restricted user,
        # if it was we must add this fingerprint to the restricted user, otherwise he wouldnt have access to his own database
        RestrictedUserDbs.get_or_create(fingerprint.owner, fingerprint)
예제 #3
0
def shared_updated(sender, **kwargs):
    action = kwargs['action']
    fingerprint = kwargs['instance']
    changed_ids = kwargs['pk_set']

    if action == 'post_add' or action == 'post_remove':
        for pk in changed_ids:
            try:
                shared_user = User.objects.get(id=pk)
                if action == 'post_add':
                    fingerprint.setSubscription(shared_user, True)

                    # we auto-add restricted users to the database when this database is shared with them
                    RestrictedUserDbs.get_or_create(shared_user, fingerprint)

                elif action == 'post_remove':
                    fingerprint.setSubscription(shared_user, False)

                    # we also remove it automatically when its unshared
                    RestrictedUserDbs.remove(shared_user, fingerprint)

            except User.DoesNotExist:
                print "-- ERROR: Couldnt get user with primary key"+pk
예제 #4
0
def shared_updated(sender, **kwargs):
    action = kwargs['action']
    fingerprint = kwargs['instance']
    changed_ids = kwargs['pk_set']

    if action == 'post_add' or action == 'post_remove':
        for pk in changed_ids:
            try:
                shared_user = User.objects.get(id=pk)
                if action == 'post_add':
                    fingerprint.setSubscription(shared_user, True)

                    # we auto-add restricted users to the database when this database is shared with them
                    RestrictedUserDbs.get_or_create(shared_user, fingerprint)

                elif action == 'post_remove':
                    fingerprint.setSubscription(shared_user, False)

                    # we also remove it automatically when its unshared
                    RestrictedUserDbs.remove(shared_user, fingerprint)

            except User.DoesNotExist:
                print "-- ERROR: Couldnt get user with primary key"+pk