当前位置: 首页>>代码示例>>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;未经允许,请勿转载。