Revision e336910f snf-astakos-app/astakos/im/functions.py

b/snf-astakos-app/astakos/im/functions.py
68 68
    AstakosUser, Invitation, ProjectMembership, ProjectApplication, Project,
69 69
    UserSetting,
70 70
    get_resource_names, new_chain)
71
from astakos.im.quotas import (qh_sync_user, qh_sync_users,
71
from astakos.im.quotas import (qh_sync_user, qh_sync_project,
72 72
                               register_pending_apps)
73 73
from astakos.im.project_notif import (
74 74
    membership_change_notify, membership_enroll_notify,
......
293 293
    if not user.activation_sent:
294 294
        user.activation_sent = datetime.now()
295 295
    user.save()
296
    qh_sync_user(user.id)
296
    qh_sync_user(user)
297 297
    send_helpdesk_notification(user, helpdesk_email_template_name)
298 298
    send_greeting(user, email_template_name)
299 299

  
......
526 526

  
527 527
    user = membership.person
528 528
    membership.accept()
529
    qh_sync_user(user.id)
529
    qh_sync_user(user)
530 530
    logger.info("User %s has been accepted in %s." %
531 531
                (user.log_display, project))
532 532

  
......
593 593

  
594 594
    user = membership.person
595 595
    membership.remove()
596
    qh_sync_user(user.id)
596
    qh_sync_user(user)
597 597
    logger.info("User %s has been removed from %s." %
598 598
                (user.log_display, project))
599 599

  
......
614 614
        raise PermissionDenied(m)
615 615

  
616 616
    membership.accept()
617
    qh_sync_user(user.id)
617
    qh_sync_user(user)
618 618
    logger.info("User %s has been enrolled in %s." %
619 619
                (membership.person.log_display, project))
620 620

  
......
655 655
    leave_policy = project.application.member_leave_policy
656 656
    if leave_policy == AUTO_ACCEPT_POLICY:
657 657
        membership.remove()
658
        qh_sync_user(request_user.id)
658
        qh_sync_user(request_user)
659 659
        logger.info("User %s has left %s." %
660 660
                    (membership.person.log_display, project))
661 661
        auto_accepted = True
......
703 703
    if (join_policy == AUTO_ACCEPT_POLICY and (
704 704
            not project.violates_members_limit(adding=1))):
705 705
        membership.accept()
706
        qh_sync_user(request_user.id)
706
        qh_sync_user(request_user)
707 707
        logger.info("User %s joined %s." %
708 708
                    (membership.person.log_display, project))
709 709
        auto_accepted = True
......
844 844

  
845 845
    qh_release_pending_app(application.owner)
846 846
    project = application.approve(reason)
847
    qh_sync_projects([project])
847
    qh_sync_project(project)
848 848
    logger.info("%s has been approved." % (application.log_display))
849 849
    application_approve_notify(application)
850 850

  
......
865 865
    checkAlive(project)
866 866

  
867 867
    project.terminate()
868
    qh_sync_projects([project])
868
    qh_sync_project(project)
869 869
    logger.info("%s has been terminated." % (project))
870 870

  
871 871
    project_termination_notify(project)
872 872

  
873 873

  
874 874
def suspend(project_id, request_user=None):
875
    project = get_project_by_id(project_id)
875
    project = get_project_for_update(project_id)
876 876
    checkAllowed(project, request_user, admin_only=True)
877 877
    checkAlive(project)
878 878

  
879 879
    project.suspend()
880
    qh_sync_projects([project])
880
    qh_sync_project(project)
881 881
    logger.info("%s has been suspended." % (project))
882 882

  
883 883
    project_suspension_notify(project)
......
892 892
        raise PermissionDenied(m)
893 893

  
894 894
    project.resume()
895
    qh_sync_projects([project])
895
    qh_sync_project(project)
896 896
    logger.info("%s has been unsuspended." % (project))
897 897

  
898 898

  
......
969 969

  
970 970
def qh_release_pending_app(user):
971 971
    register_pending_apps(user, -1)
972

  
973

  
974
def qh_sync_projects(projects):
975

  
976
    memberships = ProjectMembership.objects.filter(project__in=projects)
977
    user_ids = set(m.person_id for m in memberships)
978

  
979
    qh_sync_users(user_ids)

Also available in: Unified diff