本文整理汇总了Python中models.Group.view方法的典型用法代码示例。如果您正苦于以下问题:Python Group.view方法的具体用法?Python Group.view怎么用?Python Group.view使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Group
的用法示例。
在下文中一共展示了Group.view方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_or_create_user
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import view [as 别名]
def edit_or_create_user(request, user_id=None, form=None, user=None):
if (((user_id and user_id != request.user.username) or not user_id)
and not request.user.is_superuser):
context = {'error': 'No autorizado'}
return render_to_response('error.html',
context, context_instance=RequestContext(request))
if user is None:
if user_id:
user = User.view("couchauth/username", key=user_id).one()
if not user:
return HttpResponseRedirect('/webconf/couchauth/show_users/')
else:
user = User()
user.password = ''
if form is None:
form = UserForm(instance=user)
if not request.user.is_superuser:
del form.fields['is_staff']
del form.fields['is_active']
del form.fields['is_superuser']
# Moved out of the main form layout on the template
del form.fields['photo']
tematres_conf = Config.get_or_create("tematres")
hosts = tematres_conf["values"].get("hosts", [])
form.fields['tematres_host'].widget.choices = map(None, hosts, hosts)
form_url = "/webconf/couchauth/save_user/%s" % (user_id or '')
if user_id:
delete_url = "/webconf/couchauth/delete_user/%s" % (user._id)
form_title = "Editando usuario: " + user.username
else:
delete_url = None
form_title = "Creando usuario"
groups = Group.view("couchauth/all_groups")
if user._attachments and 'photo' in user._attachments:
photo = "/couchflow/get_attach/couchauth/%s/photo" % (user._id)
else:
photo = None
context = {
'form': form,
'userdoc': user,
'form_title': form_title,
'form_url': form_url,
'delete_url': delete_url,
'groups': groups,
'photo': photo,
}
return render_to_response('webconf/couchauth/form_user.html',
context, context_instance=RequestContext(request))
示例2: show_groups
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import view [as 别名]
def show_groups(request):
groups = Group.view("couchauth/all_groups")
context = { 'groups': groups,
}
return render_to_response('webconf/couchauth/show_groups.html',
context,
context_instance=RequestContext(request)
)
示例3: show_users
# 需要导入模块: from models import Group [as 别名]
# 或者: from models.Group import view [as 别名]
def show_users(request):
groups = Group.view("couchauth/all_groups")
users = User.view("couchauth/all_users")
context = {'users': users, 'groups': groups,
'form_title': 'Usuarios'
}
return render_to_response('webconf/couchauth/show_users.html',
context,
context_instance=RequestContext(request)
)