def profile(request): username = request.user the_user = User.objects.get(username=username) user_perm_list = list(the_user.get_all_permissions()) for i in range(len(user_perm_list)): user_perm_list[i] = en2cn(user_perm_list[i].split('.')[1]) # group_perm_list = list(the_user.get_group_permissions()) # for i in range(len(group_perm_list)): # group_perm_list[i] = en2cn(group_perm_list[i].split('.')[1]) if request.method == 'POST': form = ProfileFrom(request.POST, request.FILES, instance=the_user) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('index')) else: form = ProfileFrom(instance=the_user) return render_to_response('users/profile.html', locals(), RequestContext(request))
def __init__(self, *args, **kwargs): super(GroupPermForm, self).__init__(*args, **kwargs) self.fields['perm_list'].choices = ((x.id, en2cn(x.codename)) for x in perm_filter())
def __init__(self, *args, **kwargs): super(UserPermForm, self).__init__(*args, **kwargs) self.fields['perm_list'].choices = ((x.id, en2cn(x.codename)) for x in perm_filter()) self.fields['group_list'].choices = ((x.id, x.name) for x in Group.objects.all())