python - Restrict the deleted news with that group -


the challenge to:

there group named groupeditor user of group( groupeditor) can add , change , remove news- news

but user of group(groupeditor) when deleted news delete news added

and that's question how implement ? maybe in admin panel have something?

it admin.py

class publishadmin(admin.modeladmin):     fields = ['author', 'category', 'img', 'title', 'content', 'keywords', 'publish', 'active']  class categoryadmin(admin.modeladmin):     fields = ['title']  admin.site.register(publication, publishadmin) admin.site.register(category, categoryadmin) 

it method in views.py registered user groupeditor

def register(request):     if request.user.is_authenticated(): return redirect('/')     c={}     c.update(csrf(request))     c.setdefault('form', auth.forms.usercreationform)     if request.post:         newform = auth.forms.usercreationform(request.post)         if newform.is_valid():             nf=newform.save(commit = false)             nf.is_staff = true             nf.save()              user=auth.authenticate(                 username = newform.cleaned_data['username'],                  password = newform.cleaned_data['password1']                 )             group = auth.models.group.objects.get(name = 'redactor')             user.groups.add(group)             auth.login(request, user)             return redirect('/')         else:             c['form'] = newform     return render(request, 'register.html',c) 


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -