本文整理汇总了Python中models.User.User.remove_project方法的典型用法代码示例。如果您正苦于以下问题:Python User.remove_project方法的具体用法?Python User.remove_project怎么用?Python User.remove_project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.User.User
的用法示例。
在下文中一共展示了User.remove_project方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import remove_project [as 别名]
#.........这里部分代码省略.........
blob_info = upload_files[0]
if 'image' in blob_info.content_type:
screenshot = blob_info.key()
screenshot_url = images.get_serving_url(screenshot)
else:
# uploaded file wasn't an images, hence remove from the blobstore
blobstore.delete(blob_info.key())
fileerror = 'Invalid image type'
project_id = self.request.get('projects_dropdown')
title = self.request.get('title').strip()
titleerror = validate_project_title(title)
url = self.request.get('url').strip()
urlerror = validate_project_url(url)
short_description = self.request.get('short_description').strip()
sderror = validate_project_short_description(short_description)
if titleerror or urlerror or sderror or fileerror:
if blob_info and not fileerror:
# same as above
Project.remove_screenshot_blob(blob_info.key())
user = User.get_user(username)
projects = Project.get_projects_by_ids(user.projects)
upload_url = blobstore.create_upload_url('/' + username, max_bytes_per_blob=self.MAX_IMG_SIZE)
template = 'profile/edit_project.html'
context = { 'user': user,
'username': username,
'title': title,
'url': url,
'short_description': short_description,
'projects': projects,
'upload_url': upload_url,
'titleerror': titleerror,
'urlerror': urlerror,
'sderror': sderror,
'fileerror': fileerror }
self.render(template, context)
return
else:
Project.update_project(project_id, title=title, screenshot=screenshot,
screenshot_url=screenshot_url, url=url, short_description=short_description)
elif mode == 'remove_project':
project_id = self.request.get('project_id')
Project.remove_project(project_id)
User.remove_project(username, project_id)
elif mode == 'edit':
fields = self.get_params_dict((
'real_name',
'email',
'short_about',
'dob',
'tools',
'password',
'password_confirm',
'notify_on_msg'
))
logging.error(fields)
iclasses = self.request.get_all('classes_inprog')
cclasses = self.request.get_all('classes_completed')
fields['iclasses'] = iclasses
fields['cclasses'] = cclasses
fields['username'] = username
user = Key(User, username).get()
errors = self.clean_user_data(user, **fields)
context = {
'errors': errors,
'user': user
}
if not errors:
user.update(**fields)
self.redirect('/{}'.format(username))
else:
if user.dob:
dob = user.dob.strftime('%m/%d/%Y')
else:
dob = None
all, ic, cc = self.organize_courses_for(user)
context['courses_all'] = Course.courses_to_dict()
context['courses_completed'] = cc
context['courses_incomplete'] = ic
context['dob'] = dob
context['username'] = username
context['gravatar'] = user.avatar_url
context['friends'] = []
context['friend_btn'] = False
context['errors'] = errors
self.render('profile/edit.html'.format(username), context)
return
self.redirect('/'+username)