當前位置: 首頁>>代碼示例>>Python>>正文


Python Member.get_memberships方法代碼示例

本文整理匯總了Python中coredata.models.Member.get_memberships方法的典型用法代碼示例。如果您正苦於以下問題:Python Member.get_memberships方法的具體用法?Python Member.get_memberships怎麽用?Python Member.get_memberships使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在coredata.models.Member的用法示例。


在下文中一共展示了Member.get_memberships方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: index

# 需要導入模塊: from coredata.models import Member [as 別名]
# 或者: from coredata.models.Member import get_memberships [as 別名]
def index(request):
    userid = request.user.username
    memberships, excluded = Member.get_memberships(userid)
    staff_memberships = [m for m in memberships if m.role in ['INST', 'TA', 'APPR']] # for docs link
    is_instructor = len([m for m in memberships if m.role == 'INST']) > 0  # For TUGs link
    news_list = _get_news_list(userid, 5)
    roles = Role.all_roles(userid)
    is_grad = GradStudent.objects.filter(person__userid=userid, current_status__in=STATUS_ACTIVE).exists()
    has_grads = Supervisor.objects.filter(supervisor__userid=userid, supervisor_type='SEN', removed=False).exists()
    form_groups = FormGroup.objects.filter(members__userid=request.user.username).exists()
    has_ras = RAAppointment.objects.filter(hiring_faculty__userid=request.user.username, deleted=False).exists()

    # Only CMPT admins should see the one different TA module.  Only non-CMPT TA Admins should see the other.
    # re-factored to take into account the very few people who should see both (mainly FAS Departmental Admins)
    cmpt_taadmn = Role.objects_fresh.filter(person__userid=userid, role='TAAD', unit__label__in=['CMPT', 'SEE']).exists()
    other_taadmn = Role.objects_fresh.filter(person__userid=userid, role='TAAD').exclude(unit__label__in=['CMPT', 'SEE']).exists()

    context = {'memberships': memberships,
               'staff_memberships': staff_memberships,
               'news_list': news_list,
               'roles': roles,
               'is_grad':is_grad,
               'has_grads': has_grads,
               'has_ras': has_ras,
               'excluded': excluded,
               'form_groups': form_groups,
               'cmpt_taadmn': cmpt_taadmn,
               'other_taadmn': other_taadmn,
               'is_instructor': is_instructor}
    return render(request, "dashboard/index.html", context)
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:32,代碼來源:views.py

示例2: get_queryset

# 需要導入模塊: from coredata.models import Member [as 別名]
# 或者: from coredata.models.Member import get_memberships [as 別名]
    def get_queryset(self):
        all = self.request.query_params.get('all', None)
        if all == 'yes':
            memberships = Member.objects.exclude(role="DROP").exclude(offering__component="CAN") \
                    .filter(offering__graded=True, person__userid=self.request.user.username)
        else:
            memberships, _ = Member.get_memberships(self.request.user.username)

        offerings = [m.offering for m in memberships]
        return offerings
開發者ID:sfu-fas,項目名稱:coursys,代碼行數:12,代碼來源:api_views.py

示例3: index

# 需要導入模塊: from coredata.models import Member [as 別名]
# 或者: from coredata.models.Member import get_memberships [as 別名]
def index(request):
    userid = request.user.username
    memberships, excluded = Member.get_memberships(userid)
    staff_memberships = [m for m in memberships if m.role in ['INST', 'TA', 'APPR']] # for docs link
    news_list = _get_news_list(userid, 5)
    roles = Role.all_roles(userid)
    is_grad = GradStudent.objects.filter(person__userid=userid, current_status__in=STATUS_ACTIVE).count() > 0
    has_grads = Supervisor.objects.filter(supervisor__userid=userid, supervisor_type='SEN', removed=False).count() > 0
    form_groups = FormGroup.objects.filter(members__userid=request.user.username).count() > 0

    #messages.add_message(request, messages.SUCCESS, 'Success message.')
    #messages.add_message(request, messages.WARNING, 'Warning message.')
    #messages.add_message(request, messages.INFO, 'Info message.')
    #messages.add_message(request, messages.ERROR, 'Error message.')

    context = {'memberships': memberships, 
                'staff_memberships': staff_memberships, 
                'news_list': news_list, 
                'roles': roles, 
                'is_grad':is_grad,
                'has_grads': has_grads, 
                'excluded': excluded, 
                'form_groups': form_groups}
    return render(request, "dashboard/index.html", context)
開發者ID:tedkirkpatrick,項目名稱:coursys,代碼行數:26,代碼來源:views.py

示例4: context_memberships

# 需要導入模塊: from coredata.models import Member [as 別名]
# 或者: from coredata.models.Member import get_memberships [as 別名]
def context_memberships(userid):
    if userid:
        return Member.get_memberships(userid)[0]
    else:
        return []
開發者ID:avacariu,項目名稱:coursys,代碼行數:7,代碼來源:context.py


注:本文中的coredata.models.Member.get_memberships方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。