本文整理汇总了Python中wye.profiles.models.Profile.is_presenter方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.is_presenter方法的具体用法?Python Profile.is_presenter怎么用?Python Profile.is_presenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wye.profiles.models.Profile
的用法示例。
在下文中一共展示了Profile.is_presenter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_context_data
# 需要导入模块: from wye.profiles.models import Profile [as 别名]
# 或者: from wye.profiles.models.Profile import is_presenter [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
示例2: dispatch
# 需要导入模块: from wye.profiles.models import Profile [as 别名]
# 或者: from wye.profiles.models.Profile import is_presenter [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)
示例3: get_context_data
# 需要导入模块: from wye.profiles.models import Profile [as 别名]
# 或者: from wye.profiles.models.Profile import is_presenter [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
示例4: get_context_data
# 需要导入模块: from wye.profiles.models import Profile [as 别名]
# 或者: from wye.profiles.models.Profile import is_presenter [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
示例5: dispatch
# 需要导入模块: from wye.profiles.models import Profile [as 别名]
# 或者: from wye.profiles.models.Profile import is_presenter [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:
raise PermissionDenied
if self.feedback_required:
return self.return_response(request)
return super(WorkshopRestrictMixin, self).dispatch(request, *args, **kwargs)