本文整理汇总了Python中mig_main.utility.Permissions.can_manage_electee_progress方法的典型用法代码示例。如果您正苦于以下问题:Python Permissions.can_manage_electee_progress方法的具体用法?Python Permissions.can_manage_electee_progress怎么用?Python Permissions.can_manage_electee_progress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mig_main.utility.Permissions
的用法示例。
在下文中一共展示了Permissions.can_manage_electee_progress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_permissions
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def get_permissions(user):
permission_dict = get_member_permissions(user)
permission_dict.update(
{
"can_create_groups": Permissions.can_manage_electee_progress(user),
"can_edit_resources": Permissions.can_manage_electee_progress(user),
}
)
return permission_dict
示例2: get_permissions
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def get_permissions(user):
permission_dict = get_member_permissions(user)
permission_dict.update({
'can_edit_resources':Permissions.can_manage_electee_progress(user),
'can_edit_surveys':Permissions.can_manage_electee_progress(user),
'can_complete_surveys':Permissions.can_complete_electee_survey(user),
'can_submit_background_form':can_submit_background_form(user),
'can_submit_interview_followups':user_is_member(user) and user.userprofile.memberprofile.status.name=='Active',
'can_view_interview_pairings':Permissions.can_view_interview_pairings(user),
'can_view_followups':Permissions.can_see_follow_up(user),
})
return permission_dict
示例3: manually_edit_electee_group_membership
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def manually_edit_electee_group_membership(request):
if not Permissions.can_manage_electee_progress(request.user):
request.session['error_message']='You are not authorized to edit electee teams'
return redirect('electees:view_electee_groups')
e_groups = ElecteeGroup.objects.filter(term=AcademicTerm.get_current_term())
prefix = 'manual_groups'
term =AcademicTerm.get_current_term()
formset=ManualElecteeGroupMembersFormSet(request.POST or None,prefix=prefix,queryset=ElecteeGroup.objects.filter(term=term))
if request.method=='POST':
if formset.is_valid():
formset.save()
request.session['success_message']='Electee team membership updated successfully'
return redirect('electees:view_electee_groups')
else:
request.session['error_message']='Form is invalid. Please correct the noted errors.'
template = loader.get_template('generic_formset.html')
context_dict = {
'formset':formset,
'prefix':prefix,
'subsubnav':'members',
'has_files':False,
'submit_name':'Update Electee Team Membership',
'form_title':'Add Electee Team Members',
'help_text':'Add members to electee teams. This is for initial addition only, for edits use the drag-and-drop interface.',
'can_add_row':False,
'base':'electees/base_electees.html',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
return HttpResponse(template.render(context))
示例4: edit_electee_group_points
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def edit_electee_group_points(request):
if not Permissions.can_manage_electee_progress(request.user):
request.session['error_message']='You are not authorized to edit electee team points.'
return redirect('electees:view_electee_groups')
term =AcademicTerm.get_current_term()
GroupPointsFormSet = modelformset_factory(ElecteeGroupEvent,exclude=('related_event_id',),can_delete=True)
GroupPointsFormSet.form.base_fields['electee_group'].queryset=ElecteeGroup.objects.filter(term=term)
if request.method =='POST':
formset = GroupPointsFormSet(request.POST,prefix='group_points',queryset=ElecteeGroupEvent.objects.filter(related_event_id=None,electee_group__term=term))
if formset.is_valid():
formset.save()
request.session['success_message']='Electee team points updated successfully'
return redirect('electees:view_electee_groups')
else:
request.session['error_message']='Form is invalid. Please correct the noted errors.'
else:
formset = GroupPointsFormSet(prefix='group_points',queryset=ElecteeGroupEvent.objects.filter(related_event_id=None,electee_group__term=term))
template = loader.get_template('generic_formset.html')
context_dict = {
'formset':formset,
'prefix':'group_points',
'subsubnav':'points',
'has_files':False,
'submit_name':'Update Electee Team Points',
'form_title':'Update/Add Remove Electee Team Points',
'help_text':'Track the electee team points. You should not note any points from threshold participation at service or social events here. Those are tabulated automatically.',
'can_add_row':True,
'base':'electees/base_electees.html',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
return HttpResponse(template.render(context))
示例5: edit_survey_questions
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def edit_survey_questions(request):
if not Permissions.can_manage_electee_progress(request.user):
request.session['error_message']='You are not authorized to edit the electee survey.'
return redirect('electees:view_electee_groups')
SurveyQuestionFormSet = modelformset_factory(SurveyQuestion)
prefix='surveyquestions'
if request.method =='POST':
formset = SurveyQuestionFormSet(request.POST,prefix=prefix,queryset=SurveyQuestion.objects.all())
if formset.is_valid():
formset.save()
request.session['success_message']='Electee interview survey questions updated successfully'
return redirect('electees:manage_survey')
else:
request.session['error_message']='Form is invalid. Please correct the noted errors.'
else:
formset = SurveyQuestionFormSet(prefix=prefix,queryset=SurveyQuestion.objects.all())
template = loader.get_template('generic_formset.html')
context_dict = {
'formset':formset,
'prefix':prefix,
'has_files':False,
'can_add_row':True,
'submit_name':'Update Electee Survey Questions',
'form_title':'Update Electee Interview Survey Questions',
'help_text':'Add or edit the different questions for the survey. Questions will only be displayed if they are added to the current survey. There should be no need to remove survey parts. If there is no word limit for a question, leave that field blank.',
'base':'electees/base_electees.html',
'back_button':{'link':reverse('electees:manage_survey'),'text':'To Survey Manager'},
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
return HttpResponse(template.render(context))
示例6: edit_electee_group_membership
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def edit_electee_group_membership(request):
if not Permissions.can_manage_electee_progress(request.user):
request.session["error_message"] = "You are not authorized to edit electee groups"
return redirect("electees:view_electee_groups")
if request.method == "POST":
electee_groups_json = request.POST["electee_groups"]
electee_groups = json.loads(electee_groups_json)
for group_id in electee_groups:
members = electee_groups[group_id]
group = ElecteeGroup.objects.get(id=group_id)
group.members.clear()
for member in members:
group.members.add(MemberProfile.objects.get(uniqname=member))
request.session["success_message"] = "Your changes have been saved"
e_groups = ElecteeGroup.objects.filter(term=get_current_term())
template = loader.get_template("electees/edit_electee_group_membership.html")
context_dict = {
"electee_groups": e_groups,
"unassigned_electees": get_unassigned_electees(),
"subsubnav": "members",
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
return HttpResponse(template.render(context))
示例7: eligibility
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def eligibility(request):
"""
The joining page. The name eligibility is a backwards compatibility to the
old name of the page. Unfortunately changing the view names is a big hassle
as all the links throughout the website are kind of based on those. Shows
text determined by the JoiningTextField table and a static photo that
desperately needs updating.
"""
template = loader.get_template('about/eligibility.html')
eligibility_text = JoiningTextField.objects.filter(section='EL')
ugrad_reqs_text = JoiningTextField.objects.filter(section='UG')
grad_reqs_text = JoiningTextField.objects.filter(section='GR')
why_join_text = JoiningTextField.objects.filter(section='Y')
context_dict = {
'eligibility_text': eligibility_text,
'ugrad_text': ugrad_reqs_text,
'grad_text': grad_reqs_text,
'why_join_text': why_join_text,
'can_edit_page': Permissions.can_manage_electee_progress(request.user),
'subnav': 'joining',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
return HttpResponse(template.render(context))
示例8: edit_electee_process_visibility
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def edit_electee_process_visibility(request):
if not Permissions.can_manage_electee_progress(request.user):
request.session['error_message']='You are not authorized to edit the electee process visibility settings.'
return redirect('electees:view_electee_groups')
current_vis = ElecteeProcessVisibility.objects.get_or_create(term=AcademicTerm.get_current_term())
VisibilityForm = modelform_factory(ElecteeProcessVisibility,exclude=['term'])
prefix='visibility'
form = VisibilityForm(request.POST or None ,prefix=prefix,instance=current_vis[0])
if request.method =='POST':
if form.is_valid():
form.save()
request.session['success_message']='Electee settings updated successfully'
return redirect('electees:manage_survey')
else:
request.session['error_message']='Form is invalid. Please correct the noted errors.'
template = loader.get_template('generic_form.html')
context_dict = {
'form':form,
'prefix':prefix,
'has_files':False,
'submit_name':'Update Visibility Settings',
'form_title':'Update Electee Visibility Settings for %s'%(unicode(AcademicTerm.get_current_term())),
'help_text':'Change whether certain electee items are visible to all actives.',
'base':'electees/base_electees.html',
'back_button':{'link':reverse('electees:manage_survey'),'text':'To Survey Manager'},
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
return HttpResponse(template.render(context))
示例9: update_joining_page
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def update_joining_page(request):
if not Permissions.can_manage_electee_progress(request.user):
request.session['error_message']='You are not authorized to update joining page text.'
return redirect('about:eligibility')
JoiningTextForm = modelformset_factory(JoiningTextField,extra=0)
if request.method=='POST':
formset = JoiningTextForm(request.POST)
if formset.is_valid():
instances = formset.save()
request.session['success_message']='Joining page successfully updated.'
return redirect('about:eligibility')
else:
request.session['error_message']='Your submision contained errors, please correct and resubmit.'
else:
formset=JoiningTextForm()
context_dict = {
'formset':formset,
'subnav':'joining',
'has_files':False,
'submit_name':'Update Joining Page',
'back_button':{'link':reverse('about:eligibility'),'text':'To Joining Page'},
'form_title':'Edit Joining Page Text',
'help_text':'These sections use markdown syntax. You can change the content and how it is displayed here.',
'can_add_row':False,
'base':'about/base_about.html',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
template = loader.get_template('generic_formset.html')
return HttpResponse(template.render(context))
示例10: edit_survey_parts
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def edit_survey_parts(request):
if not Permissions.can_manage_electee_progress(request.user):
request.session['error_message']='You are not authorized to edit the electee survey.'
return redirect('electees:view_electee_groups')
SurveyPartFormSet = modelformset_factory(SurveyPart, exclude=[])
prefix='surveyparts'
if request.method =='POST':
formset = SurveyPartFormSet(request.POST,prefix=prefix,queryset=SurveyPart.objects.all())
if formset.is_valid():
formset.save()
request.session['success_message']='Electee interview survey parts updated successfully'
return redirect('electees:manage_survey')
else:
request.session['error_message']='Form is invalid. Please correct the noted errors.'
else:
formset = SurveyPartFormSet(prefix=prefix,queryset=SurveyPart.objects.all())
template = loader.get_template('generic_formset.html')
context_dict = {
'formset':formset,
'prefix':prefix,
'has_files':False,
'can_add_row':True,
'submit_name':'Update Electee Survey Parts',
'form_title':'Update Electee Interview Survey Parts',
'help_text':'Add or edit the different parts of the survey. Questions will be associated with a particular part. Only those parts that have questions which appear in a given survey will be included in that survey. There should be no need to remove survey parts. If all questions in a part are required, leave that field blank.',
'base':'electees/base_electees.html',
'back_button':{'link':reverse('electees:manage_survey'),'text':'To Survey Manager'},
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
return HttpResponse(template.render(context_dict, request))
示例11: edit_electee_group_membership
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def edit_electee_group_membership(request):
if not Permissions.can_manage_electee_progress(request.user):
request.session['error_message']='You are not authorized to edit electee teams'
return redirect('electees:view_electee_groups')
if request.method =='POST':
electee_groups_json=request.POST['electee_groups']
electee_groups = json.loads(electee_groups_json)
for group_id in electee_groups:
members = electee_groups[group_id]
group = ElecteeGroup.objects.get(id=group_id)
group.members.clear()
for member in members:
group.members.add(MemberProfile.objects.get(uniqname=member))
request.session['success_message']='Your changes have been saved'
e_groups = ElecteeGroup.objects.filter(term=AcademicTerm.get_current_term())
template = loader.get_template('electees/edit_electee_group_membership.html')
context_dict = {
'electee_groups':e_groups,
'unassigned_electees':get_unassigned_electees(),
'subsubnav':'members',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
return HttpResponse(template.render(context))
示例12: edit_electee_resources
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def edit_electee_resources(request):
if not Permissions.can_manage_electee_progress(request.user):
request.session['error_message']='You are not authorized to edit electee resources.'
return redirect('electees:view_electee_groups')
ResourceFormSet = modelformset_factory(ElecteeResource,exclude=('term',),can_delete=True)
term =AcademicTerm.get_current_term()
if request.method =='POST':
formset = ResourceFormSet(request.POST,request.FILES,prefix='resources',queryset=ElecteeResource.objects.filter(term=term))
if formset.is_valid():
instances=formset.save(commit=False)
for obj in formset.deleted_objects:
obj.delete()
for instance in instances:
instance.term=term
instance.save()
request.session['success_message']='Electee resources updated successfully'
return redirect('electees:view_electee_groups')
else:
request.session['error_message']='Form is invalid. Please correct the noted errors.'
else:
formset = ResourceFormSet(prefix='resources',queryset=ElecteeResource.objects.filter(term=term))
template = loader.get_template('generic_formset.html')
context_dict = {
'formset':formset,
'prefix':'resources',
'has_files':True,
'submit_name':'Update Electee Resources',
'form_title':'Update/Add/Remove Electee Resources for %s'%(unicode(term)),
'help_text':'These are the full packets and their constituent parts. If you need a part that isn\'t listed here, contact the web chair.',
'can_add_row':True,
'base':'electees/base_electees.html',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
return HttpResponse(template.render(context_dict, request))
示例13: edit_electee_groups
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def edit_electee_groups(request):
if not Permissions.can_manage_electee_progress(request.user):
request.session["error_message"] = "You are not authorized to edit electee groups"
return redirect("electees:view_electee_groups")
e_groups = ElecteeGroup.objects.filter(term=get_current_term())
ElecteeGroupFormSet = modelformset_factory(
ElecteeGroup,
exclude=("term", "members", "points"),
can_delete=True,
widgets={"leaders": CheckboxSelectMultiple, "officers": CheckboxSelectMultiple},
)
ElecteeGroupFormSet.form.base_fields["leaders"].queryset = get_actives().order_by("last_name", "first_name")
# ElecteeGroupFormSet.form.base_fields['leaders'].widget=CheckboxSelectMultiple
ElecteeGroupFormSet.form.base_fields["officers"].queryset = get_current_officers().order_by(
"last_name", "first_name"
)
if request.method == "POST":
formset = ElecteeGroupFormSet(request.POST, prefix="groups")
if formset.is_valid():
instances = formset.save(commit=False)
for instance in instances:
if not instance.id:
instance.term = get_current_term()
instance.points = 0
instance.save()
formset.save_m2m()
request.session["success_message"] = "Electee groups successfully updated"
return redirect("electees:view_electee_groups")
else:
request.session["error_message"] = "Form is invalid. Please correct the noted errors"
else:
formset = ElecteeGroupFormSet(queryset=e_groups, prefix="groups")
template = loader.get_template("generic_formset.html")
context_dict = {
"formset": formset,
"prefix": "groups",
"subsubnav": "groups",
"has_files": False,
"submit_name": "Update Electee Groups",
"form_title": "Update/Add/Remove Electee Groups",
"help_text": "Create the electee groups for this semester, and specify the leaders nd officers. You can also remove or edit here.",
"can_add_row": True,
"base": "electees/base_electees.html",
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
return HttpResponse(template.render(context))
示例14: eligibility
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def eligibility(request):
template = loader.get_template('about/eligibility.html')
eligibility_text = JoiningTextField.objects.filter(section='EL')
ugrad_reqs_text = JoiningTextField.objects.filter(section='UG')
grad_reqs_text = JoiningTextField.objects.filter(section='GR')
why_join_text = JoiningTextField.objects.filter(section='Y')
context_dict = {
'eligibility_text':eligibility_text,
'ugrad_text':ugrad_reqs_text,
'grad_text':grad_reqs_text,
'why_join_text':why_join_text,
'can_edit_page':Permissions.can_manage_electee_progress(request.user),
'subnav':'joining',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
return HttpResponse(template.render(context))
示例15: update_joining_page
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_electee_progress [as 别名]
def update_joining_page(request):
"""
Standard form view based on the generic_formset. Used to update the text
in the joining page.
"""
denied_message = 'You are not authorized to update joining page text.'
if not Permissions.can_manage_electee_progress(request.user):
request.session['error_message'] = denied_message
return redirect('about:eligibility')
prefix = 'joining'
# messages and static text
success_message = 'Joining page successfully updated.'
help_text = ('These sections use markdown syntax. You can change the '
'content and how it is displayed here.')
JoiningTextForm = modelformset_factory(JoiningTextField, extra=0,
exclude=[])
formset = JoiningTextForm(request.POST or None, prefix=prefix)
if request.method == 'POST':
if formset.is_valid():
instances = formset.save()
request.session['success_message'] = success_message
return redirect('about:eligibility')
else:
request.session['error_message'] = FORM_ERROR
context_dict = {
'formset': formset,
'prefix': prefix,
'subnav': 'joining',
'has_files': False,
'submit_name': 'Update Joining Page',
'back_button': {'link': reverse('about:eligibility'),
'text': 'To Joining Page'},
'form_title': 'Edit Joining Page Text',
'help_text': help_text,
'can_add_row': False,
'base': 'about/base_about.html',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
template = loader.get_template('generic_formset.html')
return HttpResponse(template.render(context))