本文整理汇总了Python中packages.bin.bin.Page.id方法的典型用法代码示例。如果您正苦于以下问题:Python Page.id方法的具体用法?Python Page.id怎么用?Python Page.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类packages.bin.bin.Page
的用法示例。
在下文中一共展示了Page.id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UserManage
# 需要导入模块: from packages.bin.bin import Page [as 别名]
# 或者: from packages.bin.bin.Page import id [as 别名]
def UserManage(request, pk=None):
s = Auth().isAuth(request)
if s is False:
return Auth.routeLogin
second_base_url = ''
obj = Users() if pk is None else Users.objects.get(pk=pk)
page = Page(request)
page.title = 'User Management'
page.icon = 'fa fa-group'
page.form_name = 'user_management'
page.form_action = base_url_admin+second_base_url+'new/'
page.breadcrumbs = ['System', 'User Management']
page.errors = []
# create record
if request.method != "POST" and pk is None:
page.breadcrumbs.append('New')
form = FormRegisterNew(instance=obj)
return Auth.routeLogin if s is False else \
render_to_response(
base_template_admin+'manage.html',
{'s': s, 'form': form, 'page': page},
context_instance=RequestContext(request)
)
elif request.method != "POST" and pk is not None:
page.form_action = base_url_admin + second_base_url + 'update/' + str(pk) + '/'
page.title = 'Update User: %s' % obj.username
page.breadcrumbs.append('Update')
page.request = request
page.id = pk
from django.forms.models import model_to_dict
form = FormRegister(instance=obj, data=model_to_dict(obj))
return render_to_response(
base_template_admin+'manage.html',
{'s': s, 'form': form, 'page': page},
context_instance=RequestContext(request)
)
# process record
elif request.method == "POST":
page.breadcrumbs.append('Update')
page.form_action = base_url_admin+second_base_url + 'new/' if pk is None else \
base_url_admin+second_base_url + 'update/'+str(pk)+'/'
try:
raw_password = request.POST["password"]
except KeyError:
raw_password = None
# do some non field specific validations
if pk is None:
form = FormRegisterNew(request.POST, request.FILES, instance=obj)
if raw_password == "":
page.non_field_errors = ['Please enter a valid password']
else:
form = FormRegister(request.POST, request.FILES, instance=obj)
# validate and process
if form.is_valid() and not page.non_field_errors:
# do method to process
posts = request.POST
for post in posts:
if hasattr(obj, post):
setattr(obj, post, form.cleaned_data[post])
try:
if request.FILES['picture']:
# delete any previous image
try:
# get actual file name
ext = '.' + obj.picture.url.split('.')[-1]
filename = "".join(obj.picture.url.split('.')[:-1])
fn = list()
fn.append(settings.MEDIA_ROOT + '/' + filename + ext)
fn.append(settings.MEDIA_ROOT + '/' + filename + '.64x64' + ext)
fn.append(settings.MEDIA_ROOT + '/' + filename + '.128x128' + ext)
fn.append(settings.MEDIA_ROOT + '/' + filename + '.256x256' + ext)
fn.append(settings.MEDIA_ROOT + '/' + filename + '.512x512' + ext)
fn.append(settings.MEDIA_ROOT + '/' + filename + '.1024x1024' + ext)
for f in fn:
os.path.exists(f) and os.remove(f)
except (KeyError, AttributeError, ValueError):
pass
except KeyError:
pass
# encrypt password
if raw_password:
obj.password = sha1(raw_password).hexdigest()
#.........这里部分代码省略.........