本文整理汇总了Python中usermanagement.check_perms函数的典型用法代码示例。如果您正苦于以下问题:Python check_perms函数的具体用法?Python check_perms怎么用?Python check_perms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_perms函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: indicators
def indicators(indicatorgroup=None):
its = {}
indicators = dqindicators.indicatorsTests(indicatorgroup)
indicatorgroup = dqindicators.indicatorGroups(indicatorgroup)
for indicator in indicators:
ind_id = indicator.Indicator.id
if ind_id not in its:
its[ind_id] = {}
its[ind_id].update(indicator.Indicator.as_dict())
its[ind_id]["indicator_type"] = its[ind_id]["indicator_type"].title()
if its[ind_id]["indicator_category_name"]:
its[ind_id]["indicator_type"] += " - " + its[ind_id]["indicator_category_name"]
if True:
if ('test' not in its[ind_id]):
its[ind_id]['test'] = []
if indicator.Test:
test_data = indicator.Test.as_dict()
test_data['test_id'] = test_data['id']
del(test_data['id'])
its[ind_id]['test'].append(test_data)
its[ind_id]["links"] = {
"edit": url_for('indicators_edit',
indicatorgroup=indicatorgroup.name,
indicator=indicator.Indicator.name),
"delete": url_for('indicators_delete',
indicatorgroup=indicatorgroup.name,
indicator=indicator.Indicator.name)
}
its = util.resort_indicator_tests(its)
links = {
"edit_group": url_for('indicatorgroups_edit',
indicatorgroup=indicatorgroup.name),
"delete_group": url_for('indicatorgroups_delete',
indicatorgroup=indicatorgroup.name),
"new_indicator": url_for('indicators_new',
indicatorgroup=indicatorgroup.name),
"csv_assoc_tests": url_for('indicatorgroup_tests_csv',
indicatorgroup=indicatorgroup.name),
"csv_unassoc_tests": url_for('indicatorgroup_tests_csv',
indicatorgroup=indicatorgroup.name,
option="no")
}
indicator_data = [ v for k,v in its.items() ]
json_data = json.dumps({
"indicator": indicator_data,
"indicatorgroup": indicatorgroup.as_dict(),
"admin": usermanagement.check_perms('admin'),
"links": links
}, indent=2)
return render_template("indicators.html",
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user,
json_data=json_data)
示例2: indicatorgroups
def indicatorgroups():
if not usermanagement.check_perms('admin'):
return redirect(url_for('indicators', indicatorgroup=app.config["INDICATOR_GROUP"]))
indicatorgroups = dqindicators.indicatorGroups()
return render_template("indicatorgroups.html", indicatorgroups=indicatorgroups,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
示例3: organisation_conditions
def organisation_conditions(id=None):
if id is not None:
pc = get_pc(id)
return render_template("organisation_condition.html", pc=pc,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
else:
pcs = get_pcs()
return render_template("organisation_conditions.html", pcs=pcs,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
示例4: organisations_index
def organisations_index(organisation_code=None):
aggregation_type=integerise(request.args.get('aggregation_type', 2))
template_args = {}
org_packages = dqorganisations.organisationPackages(organisation_code)
organisation = dqorganisations.organisations(organisation_code)
packagegroups = dqorganisations.organisationPackageGroups(organisation_code)
irs = [ir for ir in get_info_results(org_packages, organisation)]
coverage = get_coverage(organisation, irs)
organisation_survey = dqsurveys.getSurvey(organisation_code)
surveydata = dqsurveys.getSurveyDataAllWorkflows(organisation_code)
surveydata, _ = dqsurveys.get_survey_data_and_workflow(
organisation_survey, surveydata)
summary_data = get_summary_data(organisation, aggregation_type)
allowed_to_view_survey = usermanagement.check_perms(
"survey",
"view")
allowed_to_edit_survey_researcher = usermanagement.check_perms(
"survey_researcher",
"edit",
{"organisation_code": organisation_code})
show_researcher_button = (
allowed_to_edit_survey_researcher and
(
(organisation_survey and
organisation_survey.Workflow.name == 'researcher')
or
(not organisation_survey)
)
)
template_args = dict(organisation=organisation,
summary_data=summary_data,
packagegroups=packagegroups,
coverage=coverage,
surveydata=surveydata,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user,
allowed_to_view_survey=allowed_to_view_survey,
show_researcher_button=show_researcher_button)
return render_template("organisation_index.html", **template_args)
示例5: organisations
def organisations(organisation_code=None):
check_perms = usermanagement.check_perms('organisation', 'view', {'organisation_code':organisation_code})
if organisation_code is not None:
if check_perms:
return redirect(url_for('organisations_index', organisation_code=organisation_code))
else:
return redirect(url_for('organisation_publication', organisation_code=organisation_code))
else:
organisations = dqorganisations.organisations()
template_args = dict(organisations=organisations,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
return render_template("organisations.html", **template_args)
示例6: ipc_step2
def ipc_step2():
step = "2"
if request.method != "POST":
return
from iatidq import dqimportpublisherconditions
def get_results():
if request.form.get("local"):
return dqimportpublisherconditions.importPCsFromFile()
else:
url = request.form["url"]
return dqimportpublisherconditions.importPCsFromUrl(url)
results = get_results()
if results:
flash("Parsed conditions", "success")
return render_template(
"import_organisation_conditions_step2.html",
results=results,
step=step,
admin=usermanagement.check_perms("admin"),
loggedinuser=current_user,
)
else:
flash("There was an error importing your conditions", "error")
return redirect(url_for("import_organisation_conditions"))
示例7: ipc_step2
def ipc_step2():
step = '2'
if request.method != 'POST':
return
from iatidq import dqimportpublisherconditions
def get_results():
if request.form.get('local'):
return dqimportpublisherconditions.importPCsFromFile()
else:
url = request.form['url']
return dqimportpublisherconditions.importPCsFromUrl(url)
results = get_results()
## FIXME: duplicate code?
if results:
flash('Parsed conditions', "success")
return render_template(
"import_organisation_conditions_step2.html",
results=results,
step=step,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
else:
flash('There was an error importing your conditions', "error")
return redirect(url_for('import_organisation_conditions'))
示例8: users_edit
def users_edit(username=None):
if username:
user = dqusers.user_by_username(username)
permissions = dqusers.userPermissions(user.id)
if request.method == 'POST':
if user:
flash('Successfully updated user.', 'success')
else:
user = {}
flash('Could not update user.', 'error')
else:
if request.method == 'POST':
user = dqusers.addUser({
'username': request.form['username'],
'password': request.form['password'],
'name': request.form['name'],
'email_address': request.form['email_address'],
'organisation': request.form['organisation']
})
if user:
flash('Successfully added new user', 'success')
else:
flash('Could not add user user', 'error')
else:
user = {}
permissions = {}
return render_template("users_edit.html",
user=user,
permissions=permissions,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
示例9: indicators_new
def indicators_new(indicatorgroup=None):
indicatorgroups = dqindicators.indicatorGroups()
if (request.method == 'POST'):
data = {
'name': request.form['name'],
'description': request.form['description'],
'indicatorgroup_id': request.form['indicatorgroup_id'],
'longdescription': request.form.get("longdescription"),
'indicator_type': request.form.get("indicator_type"),
'indicator_category_name': request.form.get("indicator_category_name"),
'indicator_subcategory_name': request.form.get("indicator_subcategory_name"),
'indicator_ordinal': request.form.get("indicator_ordinal", None),
'indicator_noformat': request.form.get("indicator_noformat", None),
'indicator_order': request.form.get("indicator_order", None),
'indicator_weight': request.form.get("indicator_weight", None)
}
indicator = dqindicators.addIndicator(data)
if indicator:
flash('Successfully added Indicator.', 'success')
else:
flash("Couldn't add Indicator. Maybe one already exists with the same name?", 'error')
else:
indicator = None
return render_template("indicator_edit.html",
indicatorgroups=indicatorgroups,
indicator=indicator,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
示例10: indicators_edit
def indicators_edit(indicatorgroup=None, indicator=None):
indicatorgroups = dqindicators.indicatorGroups()
if (request.method == 'POST'):
data = {
'name': request.form['name'],
'description': request.form['description'],
'indicatorgroup_id': request.form['indicatorgroup_id'],
'longdescription': request.form['longdescription'],
'indicator_type': request.form.get("indicator_type"),
'indicator_category_name': request.form.get("indicator_category_name"),
'indicator_subcategory_name': request.form.get("indicator_subcategory_name"),
'indicator_ordinal': request.form.get("indicator_ordinal", None),
'indicator_noformat': request.form.get("indicator_noformat", None),
'indicator_order': request.form.get("indicator_order", None),
'indicator_weight': request.form.get("indicator_weight", None)
}
indicator = dqindicators.updateIndicator(indicatorgroup, indicator, data)
flash('Successfully updated Indicator', 'success')
else:
indicator = dqindicators.indicators(indicatorgroup, indicator)
return render_template("indicator_edit.html",
indicatorgroups=indicatorgroups,
indicator=indicator,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
示例11: organisation_survey_view
def organisation_survey_view(organisation_code, workflow, workflow_name, organisationsurvey, allowed_to_edit):
organisation = Organisation.query.filter_by(
organisation_code=organisation_code).first_or_404()
surveydata = dqsurveys.getSurveyData(organisation_code, workflow_name)
surveydata_allworkflows = dqsurveys.getSurveyDataAllWorkflows(organisation_code)
indicators = dqindicators.indicators("pwyf2013")
org_indicators = dqorganisations._organisation_indicators_split(
organisation, 2)
twentytwelvedata=get_organisation_results(organisation_code, indicators)
publishedstatuses = dqsurveys.publishedStatus()
publishedstatuses = dict(map(lambda ps: (ps.id, ps), publishedstatuses))
publishedformats = dqsurveys.publishedFormat()
publishedformats = dict(map(lambda pf: (pf.id, pf), publishedformats))
template_path = "surveys/_survey_"+workflow.WorkflowType.name+".html"
return render_template(
template_path,
organisation=organisation,
indicators=indicators,
org_indicators = org_indicators,
twentytwelvedata=twentytwelvedata,
old_publication_status=old_publication_status,
publishedstatuses=publishedstatuses,
workflow=workflow,
surveydata=surveydata_allworkflows,
organisationsurvey=organisationsurvey,
allowed_to_edit=allowed_to_edit,
publishedformats=publishedformats,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
示例12: organisation_edit
def organisation_edit(organisation_code=None):
packages = dqpackages.packages()
packagegroups = dqpackages.packageGroups()
organisation = dqorganisations.organisations(organisation_code)
if request.method == 'POST':
if 'addpackages' in request.form:
add_packages(organisation)
elif 'addpackagegroup' in request.form:
add_packagegroup(organisation)
elif 'updateorganisation' in request.form:
update_organisation(organisation_code)
organisationpackages = dqorganisations.organisationPackages(
organisation.organisation_code)
return render_template(
"organisation_edit.html",
organisation=organisation,
packages=packages,
packagegroups=packagegroups,
donorresponses=donorresponse.RESPONSE_TYPES,
organisationpackages=organisationpackages,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
示例13: indicators
def indicators(indicatorgroup=None):
indicators = dqindicators.indicators(indicatorgroup)
indicatorgroup = dqindicators.indicatorGroups(indicatorgroup)
return render_template("indicators.html",
indicatorgroup=indicatorgroup,
indicators=indicators,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
示例14: users
def users(username=None):
if username:
return redirect(url_for('users_edit', username=username))
else:
users=dqusers.user()
return render_template("users.html", users=users,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)
示例15: publishers
def publishers():
p_groups = PackageGroup.query.order_by(
PackageGroup.name).all()
pkgs = Package.query.order_by(Package.package_name).all()
return render_template("packagegroups.html", p_groups=p_groups,
pkgs=pkgs,
admin=usermanagement.check_perms('admin'),
loggedinuser=current_user)