Revision 3715f954 snf-astakos-app/astakos/im/functions.py

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:

Also available in: Unified diff