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


Python Profile.is_regional_lead方法代碼示例

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


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

示例1: get_context_data

# 需要導入模塊: from wye.profiles.models import Profile [as 別名]
# 或者: from wye.profiles.models.Profile import is_regional_lead [as 別名]
 def get_context_data(self, *args, **kwargs):
     context = super(
         WorkshopList, self).get_context_data(*args, **kwargs)
     workshop_list = Workshop.objects.all()
     if Profile.is_organiser(self.request.user):
         workshop_list = workshop_list.filter(
             requester__user=self.request.user)
     elif Profile.is_presenter(self.request.user):
         workshop_list = workshop_list.filter(
             Q(presenter=self.request.user) | Q
             (requester__location__name__in=Profile.objects.get(
                 user=self.request.user).get_interested_locations))
     elif Profile.is_regional_lead(self.request.user):
         regions = RegionalLead.objects.filter(user=self.request.user)
         workshop_list = workshop_list.filter(
             location__id__in=[x.location.id for x in regions])
     context['workshop_list'] = workshop_list
     context['user'] = self.request.user
     # need to improve the part
     context['is_not_tutor'] = False
     # as user can be tutor and regional lead hence we need to verify like
     # this
     if (Profile.is_regional_lead(self.request.user) or
             Profile.is_organiser(self.request.user) or
             Profile.is_admin(self.request.user)):
         context['is_not_tutor'] = True
     return context
開發者ID:satyaakam,項目名稱:wye,代碼行數:29,代碼來源:views.py

示例2: get_organisations

# 需要導入模塊: from wye.profiles.models import Profile [as 別名]
# 或者: from wye.profiles.models.Profile import is_regional_lead [as 別名]
 def get_organisations(self, user):
     if Profile.is_admin(user):
         return Organisation.objects.all()
     elif Profile.is_regional_lead(user):
         return Organisation.objects.filter(location=user.profile.location)
     else:
         return Organisation.list_user_organisations(user)
開發者ID:farcaz,項目名稱:wye,代碼行數:9,代碼來源:forms.py

示例3: workshop_list

# 需要導入模塊: from wye.profiles.models import Profile [as 別名]
# 或者: from wye.profiles.models.Profile import is_regional_lead [as 別名]
def workshop_list(request):
    template_name = 'workshops/workshop_list.html'
    user_profile, created = Profile.objects.get_or_create(
        user__id=request.user.id)
    if not user_profile.is_profile_filled:
        return redirect('profiles:profile-edit', slug=request.user.username)
    context_dict = {}
    workshop_list = Workshop.objects.all().order_by('-expected_date')
    workshop_list = workshop_list.filter(
        requester__location__id__in=[
            x.id for x in request.user.profile.interested_locations.all()]
    )

    context_dict['workshop_list'] = workshop_list
    context_dict['user'] = request.user
    # need to improve the part
    context_dict['is_not_tutor'] = False
    # as user can be tutor and regional lead hence we need to verify like
    # this
    if (Profile.is_regional_lead(request.user) or
            Profile.is_organiser(request.user) or
            Profile.is_admin(request.user)):
        context_dict['is_not_tutor'] = True

    return render(request, template_name, context_dict)
開發者ID:harisibrahimkv,項目名稱:wye,代碼行數:27,代碼來源:views.py

示例4: dispatch

# 需要導入模塊: from wye.profiles.models import Profile [as 別名]
# 或者: from wye.profiles.models.Profile import is_regional_lead [as 別名]
    def dispatch(self, request, *args, **kwargs):
        self.user = request.user
        self.feedback_required = []

        # check if user is tutor
        if Profile.is_presenter(self.user) and self.allow_presenter:
            self.validate_presenter_feedback()
        elif (Profile.is_organiser(self.user) and
                Organisation.list_user_organisations(self.user).exists()):
            # if user is from organisation
            self.validate_organisation_feedback()
        elif (Profile.is_regional_lead(self.user) or
                Profile.is_admin(self.user)):
            pass  # don't restrict lead and admin
        else:
            msg = """
                    To request workshop you need to create organisaiton.\n\n
                 Please use organisation tab above to create your organisation"""

            # return json for ajax request
            return render(request, 'error.html', {'message': msg})

        if self.feedback_required:
            return self.return_response(request)
        return super(WorkshopRestrictMixin, self).dispatch(request, *args, **kwargs)
開發者ID:pythonindia,項目名稱:wye,代碼行數:27,代碼來源:mixins.py

示例5: workshop_list

# 需要導入模塊: from wye.profiles.models import Profile [as 別名]
# 或者: from wye.profiles.models.Profile import is_regional_lead [as 別名]
def workshop_list(request):
    template_name = 'workshops/workshop_list.html'
    user_profile, created = Profile.objects.get_or_create(
        user__id=request.user.id)
    if not user_profile.is_profile_filled:
        return redirect('profiles:profile-edit', slug=request.user.username)
    context_dict = {}
    workshop_list = Workshop.objects.all().order_by('-expected_date')
    workshop_list = workshop_list.filter(
        requester__location__id__in=[
            x.id for x in request.user.profile.interested_locations.all()]
    )

    location_list = request.GET.getlist("location")
    if location_list:
        workshop_list = workshop_list.filter(
            location__id__in=location_list
        )

    presenter_list = request.GET.getlist("presenter")
    if presenter_list:
        workshop_list = workshop_list.filter(
            presenter__id__in=presenter_list
        )

    workshop_level_list = request.GET.getlist("level")
    if workshop_level_list:
        workshop_list = workshop_list.filter(
            workshop_level__in=workshop_level_list
        )

    workshop_section_list = request.GET.getlist("section")
    if workshop_section_list:
        workshop_list = workshop_list.filter(
            workshop_section__id__in=workshop_section_list
        )

    status_list = request.GET.getlist("status")
    if status_list:
        workshop_list = workshop_list.filter(
            status__in=status_list
        )

    context_dict['workshop_list'] = workshop_list
    context_dict['user'] = request.user
    # need to improve the part
    context_dict['is_not_tutor'] = False
    # as user can be tutor and regional lead hence we need to verify like
    # this
    if (Profile.is_regional_lead(request.user) or
            Profile.is_organiser(request.user) or
            Profile.is_admin(request.user)):
        context_dict['is_not_tutor'] = True
    context_dict['form'] = WorkshopListForm(user=request.user)

    return render(request, template_name, context_dict)
開發者ID:pythonindia,項目名稱:wye,代碼行數:58,代碼來源:views.py

示例6: get_context_data

# 需要導入模塊: from wye.profiles.models import Profile [as 別名]
# 或者: from wye.profiles.models.Profile import is_regional_lead [as 別名]
 def get_context_data(self, *args, **kwargs):
     context = super(OrganisationList, self).get_context_data(
         *args, **kwargs)
     if Profile.is_organiser(self.request.user):
         context['org_created_list'] = self.get_queryset().filter(
             created_by=self.request.user)
         context['org_belongs_list'] = self.get_queryset().exclude(
             created_by=self.request.user)
     elif Profile.is_regional_lead(self.request.user):
         regions = RegionalLead.objects.filter(leads=self.request.user)
         context['regional_org_list'] = self.get_queryset().filter(
             location__id__in=[x.location.id for x in regions])
     elif Profile.is_presenter(self.request.user):
         pass
     context['user'] = self.request.user
     context['is_not_tutor'] = True if (Profile.is_regional_lead(
         self.request.user) or Profile.is_organiser(
         self.request.user)) else not Profile.is_presenter(
         self.request.user)
     return context
開發者ID:shrayasr,項目名稱:wye,代碼行數:22,代碼來源:views.py

示例7: dispatch

# 需要導入模塊: from wye.profiles.models import Profile [as 別名]
# 或者: from wye.profiles.models.Profile import is_regional_lead [as 別名]
 def dispatch(self, request, *args, **kwargs):
     user = request.user
     pk = self.kwargs.get(self.pk_url_kwarg, None)
     workshop = Workshop.objects.get(id=pk)
     is_admin = Profile.is_admin(user)
     is_lead = (Profile.is_regional_lead(user) and
                RegionalLead.is_regional_lead(user, workshop.location))
     is_presenter = (Profile.is_organiser(user) and
                     user in workshop.requester.user.all())
     if not (is_admin or is_lead or is_presenter):
         return HttpResponseForbidden("Not sufficent permission")
     return super(WorkshopAccessMixin, self).dispatch(request, *args, **kwargs)
開發者ID:CuriousLearner,項目名稱:wye,代碼行數:14,代碼來源:mixins.py

示例8: get_context_data

# 需要導入模塊: from wye.profiles.models import Profile [as 別名]
# 或者: from wye.profiles.models.Profile import is_regional_lead [as 別名]
 def get_context_data(self, *args, **kwargs):
     context = super(
         WorkshopList, self).get_context_data(*args, **kwargs)
     workshop_list = Workshop.objects.all()
     if Profile.is_organiser(self.request.user):
         workshop_list = workshop_list.filter(
             requester__user=self.request.user)
     elif Profile.is_presenter(self.request.user):
         workshop_list = workshop_list.filter(
             Q(presenter=self.request.user) | Q
             (requester__location__name__in=Profile.objects.get(
                 user=self.request.user).get_interested_locations))
     elif Profile.is_regional_lead(self.request.user):
         regions = RegionalLead.objects.filter(user=self.request.user)
         workshop_list = workshop_list.filter(
             location__id__in=[x.location.id for x in regions])
     context['workshop_list'] = workshop_list
     context['user'] = self.request.user
     context['is_not_tutor'] = True if Profile.is_regional_lead(
         self.request.user) else not Profile.is_presenter(self.request.user)
     return context
開發者ID:bIgBV,項目名稱:wye,代碼行數:23,代碼來源:views.py

示例9: get_context_data

# 需要導入模塊: from wye.profiles.models import Profile [as 別名]
# 或者: from wye.profiles.models.Profile import is_regional_lead [as 別名]
 def get_context_data(self, *args, **kwargs):
     context = super(OrganisationList, self).get_context_data(*args, **kwargs)
     if Profile.is_organiser(self.request.user):
         context["org_created_list"] = self.get_queryset().filter(created_by=self.request.user)
         context["org_belongs_list"] = (
             self.get_queryset().exclude(created_by=self.request.user).filter(user=self.request.user)
         )
     elif Profile.is_regional_lead(self.request.user):
         regions = RegionalLead.objects.filter(leads=self.request.user)
         context["regional_org_list"] = self.get_queryset().filter(location__id__in=[x.location.id for x in regions])
     context["user"] = self.request.user
     # need to improve the part
     # context['is_not_tutor'] = False
     # as user can be tutor and regional lead hence we need to verify like
     # this
     if (
         Profile.is_regional_lead(self.request.user)
         or Profile.is_organiser(self.request.user)
         or Profile.is_admin(self.request.user)
     ):
         context["is_not_tutor"] = True
     return context
開發者ID:pythonindia,項目名稱:wye,代碼行數:24,代碼來源:views.py

示例10: __init__

# 需要導入模塊: from wye.profiles.models import Profile [as 別名]
# 或者: from wye.profiles.models.Profile import is_regional_lead [as 別名]
 def __init__(self, *args, **kwargs):
     user = kwargs.pop('user')
     super(WorkshopListForm, self).__init__(*args, **kwargs)
     self.fields['location'].queryset = self.get_all_locations(user)
     if Profile.is_admin(user) or Profile.is_regional_lead(user):
         self.fields['presenter'].queryset = User.objects.filter(
             profile__usertype__slug="tutor"
         )
     elif 'poc' in user.profile.get_user_type:
         self.fields['presenter'].queryset = User.objects.filter(
             profile__usertype__slug="tutor",
             profile__location__in=self.get_all_locations(user)
         )
     else:
         del self.fields['presenter']
     self.fields['section'].queryset = WorkshopSections.objects.all()
開發者ID:farcaz,項目名稱:wye,代碼行數:18,代碼來源:forms.py


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