Revision 3715f954

b/snf-astakos-app/astakos/im/functions.py
65 65
from astakos.im.notifications import build_notification, NotificationError
66 66
from astakos.im.models import (
67 67
    AstakosUser, Invitation, ProjectMembership, ProjectApplication, Project,
68
    UserSetting, Chain, new_chain)
68
    Chain, new_chain)
69 69
from astakos.im.quotas import (qh_sync_user, get_pending_app_quota,
70 70
                               register_pending_apps, qh_sync_project,
71 71
                               qh_sync_locked_users, get_users_for_update,
......
839 839
            return None, application
840 840

  
841 841

  
842
def get_user_setting(user_id, key):
843
    try:
844
        setting = UserSetting.objects.get(
845
            user=user_id, setting=key)
846
        return setting.value
847
    except UserSetting.DoesNotExist:
848
        return getattr(settings, key)
849

  
850

  
851
def set_user_setting(user_id, key, value):
852
    try:
853
        setting = UserSetting.objects.get_for_update(
854
            user=user_id, setting=key)
855
    except UserSetting.DoesNotExist:
856
        setting = UserSetting(user_id=user_id, setting=key)
857
    setting.value = value
858
    setting.save()
859

  
860

  
861
def unset_user_setting(user_id, key):
862
    UserSetting.objects.filter(user=user_id, setting=key).delete()
863

  
864

  
865 842
def _partition_by(f, l):
866 843
    d = {}
867 844
    for x in l:
b/snf-astakos-app/astakos/im/management/commands/user-show.py
78 78
            raise CommandError(msg)
79 79

  
80 80
        for user in users:
81
            settings_dict = {}
82
            settings = user.settings()
83
            for setting in settings:
84
                settings_dict[setting.setting] = setting.value
85

  
86 81
            kv = OrderedDict(
87 82
                [
88 83
                    ('id', user.id),
b/snf-astakos-app/astakos/im/models.py
755 755
            return False
756 756
        return True
757 757

  
758
    def settings(self):
759
        return UserSetting.objects.filter(user=self)
760

  
761 758

  
762 759
class AstakosUserAuthProviderManager(models.Manager):
763 760

  

Also available in: Unified diff