def attach_profile_and_content_to_context(request, content_path, context):
"""Attaches UserProfile data and yaml content to a request context.
Args:
request: a Request instance passed to the View
content_path: path to our static yaml content
context: a base context to be modified
Returns:
the modified context
"""
if not request.user.is_anonymous():
context['user_profile'] = UserProfile.objects.get(user=request.user)
if content_path:
with open(content_path) as content_file:
content = yaml.safe_load(content_file)
for item in content:
context[item] = content[item]
return context
static.py 文件源码
python
阅读 37
收藏 0
点赞 0
评论 0
评论列表
文章目录