Re: has_delete_permission not called in an admin template?

2009-11-23 Thread rd-london
OK, so my conclusion having examined the code listed at  http://bit.ly/7ZrKHl
is that my solution is thread-safe. There's no if...else... type logic
happening in my solution so should be fine.

R


On Nov 20, 5:22 pm, rd-london  wrote:
> And ... yes there does seem to be a better way.
>
> Define own version of "changelist_view" e.g.:
>
>     def changelist_view(self, request, extra_context=None):
>         extra_context={ 'has_delete_permission': self.has_delete_permission
> (request) }
>         return super(MyCommentsAdmin, self).changelist_view(request,
> extra_context)
>
> However - as this post suggests -http://bit.ly/7ZrKHl- is this
> thread safe?
> Thanks for any thoughts anyone.
>
> R
>
> On Nov 20, 5:02 pm, rd-london  wrote:
>
>
>
> > Right, I've worked out why this is:
>
> > django/contrib/admin/options.py - def changelist_view(self, request,
> > extra_context=None): contains the line:
>
> >         context = {
> >             'title': cl.title,
> >             'is_popup': cl.is_popup,
> >             'cl': cl,
> >             'media': media,
> >             'has_add_permission': self.has_add_permission(request),
> >             'root_path': self.admin_site.root_path,
> >             'app_label': app_label,
> >             'action_form': action_form,
> >             'actions_on_top': self.actions_on_top,
> >             'actions_on_bottom': self.actions_on_bottom,
> >         }
>
> > So, it doesn't add "has_delete_permission" to the context (nor
> > "has_change_permission") for that matter. Simple fix:
>
> >         context = {
> >             'title': cl.title,
> >             'is_popup': cl.is_popup,
> >             'cl': cl,
> >             'media': media,
> >             'has_add_permission': self.has_add_permission(request),
> > addedhere     --->       'has_delete_permission':
> > self.has_delete_permission(request),         <- added here
> >             'root_path': self.admin_site.root_path,
> >             'app_label': app_label,
> >             'action_form': action_form,
> >             'actions_on_top': self.actions_on_top,
> >             'actions_on_bottom': self.actions_on_bottom,
> >         }
>
> > ... but ... but ... surely that comes from the land of Harry the
> > Hacker?
> > Isn't there a better way to do this, or is this a genuine bug?
>
> > Any help or thoughts very welcome,
>
> > Cheers
> > R
>
> > On Nov 20, 3:18 pm, rd-london  wrote:
>
> > > Hi,
> > > Wonder if anyone can help.
>
> > > Have following chunk in my own change_list.html template:
>
> > >     {% block object-tools %}
> > >         
> > >           {% if has_add_permission %}
> > >           
> > >              > > title="Add Comment" class="addlink">
> > >               {% blocktrans with cl.opts.verbose_name as name %}Add
> > > {{ name }}{% endblocktrans %}
> > >             
> > >           
> > >           {% endif %}
> > >           {% if has_delete_permission %}
> > >           
> > > My thing goes here
> > >           
> > >           {% endif %}
> > >         
>
> > >     {% endblock %}
>
> > > Created a user that has delete permissions. Got my own ModelAdmin and
> > > have checked using the debugger that the user does indeed have delete
> > > permissions.
>
> > > The "def has_add_permission" fn in contrib/admin/options.py *is* being
> > > called (I've put "import pdb;pdb.set_trace()" there to check), whereas
> > > def has_delete_permission is not - and I can't work out for the life
> > > of me why not.
>
> > > Anyone help at all?
>
> > > Thanks,
> > > R

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: has_delete_permission not called in an admin template?

2009-11-20 Thread rd-london
And ... yes there does seem to be a better way.

Define own version of "changelist_view" e.g.:

def changelist_view(self, request, extra_context=None):
extra_context={ 'has_delete_permission': self.has_delete_permission
(request) }
return super(MyCommentsAdmin, self).changelist_view(request,
extra_context)

However - as this post suggests - http://bit.ly/7ZrKHl - is this
thread safe?
Thanks for any thoughts anyone.

R






On Nov 20, 5:02 pm, rd-london  wrote:
> Right, I've worked out why this is:
>
> django/contrib/admin/options.py - def changelist_view(self, request,
> extra_context=None): contains the line:
>
>         context = {
>             'title': cl.title,
>             'is_popup': cl.is_popup,
>             'cl': cl,
>             'media': media,
>             'has_add_permission': self.has_add_permission(request),
>             'root_path': self.admin_site.root_path,
>             'app_label': app_label,
>             'action_form': action_form,
>             'actions_on_top': self.actions_on_top,
>             'actions_on_bottom': self.actions_on_bottom,
>         }
>
> So, it doesn't add "has_delete_permission" to the context (nor
> "has_change_permission") for that matter. Simple fix:
>
>         context = {
>             'title': cl.title,
>             'is_popup': cl.is_popup,
>             'cl': cl,
>             'media': media,
>             'has_add_permission': self.has_add_permission(request),
> addedhere     --->       'has_delete_permission':
> self.has_delete_permission(request),         <- added here
>             'root_path': self.admin_site.root_path,
>             'app_label': app_label,
>             'action_form': action_form,
>             'actions_on_top': self.actions_on_top,
>             'actions_on_bottom': self.actions_on_bottom,
>         }
>
> ... but ... but ... surely that comes from the land of Harry the
> Hacker?
> Isn't there a better way to do this, or is this a genuine bug?
>
> Any help or thoughts very welcome,
>
> Cheers
> R
>
> On Nov 20, 3:18 pm, rd-london  wrote:
>
> > Hi,
> > Wonder if anyone can help.
>
> > Have following chunk in my own change_list.html template:
>
> >     {% block object-tools %}
> >         
> >           {% if has_add_permission %}
> >           
> >              > title="Add Comment" class="addlink">
> >               {% blocktrans with cl.opts.verbose_name as name %}Add
> > {{ name }}{% endblocktrans %}
> >             
> >           
> >           {% endif %}
> >           {% if has_delete_permission %}
> >           
> > My thing goes here
> >           
> >           {% endif %}
> >         
>
> >     {% endblock %}
>
> > Created a user that has delete permissions. Got my own ModelAdmin and
> > have checked using the debugger that the user does indeed have delete
> > permissions.
>
> > The "def has_add_permission" fn in contrib/admin/options.py *is* being
> > called (I've put "import pdb;pdb.set_trace()" there to check), whereas
> > def has_delete_permission is not - and I can't work out for the life
> > of me why not.
>
> > Anyone help at all?
>
> > Thanks,
> > R

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: has_delete_permission not called in an admin template?

2009-11-20 Thread rd-london
Right, I've worked out why this is:

django/contrib/admin/options.py - def changelist_view(self, request,
extra_context=None): contains the line:

context = {
'title': cl.title,
'is_popup': cl.is_popup,
'cl': cl,
'media': media,
'has_add_permission': self.has_add_permission(request),
'root_path': self.admin_site.root_path,
'app_label': app_label,
'action_form': action_form,
'actions_on_top': self.actions_on_top,
'actions_on_bottom': self.actions_on_bottom,
}

So, it doesn't add "has_delete_permission" to the context (nor
"has_change_permission") for that matter. Simple fix:

context = {
'title': cl.title,
'is_popup': cl.is_popup,
'cl': cl,
'media': media,
'has_add_permission': self.has_add_permission(request),
addedhere --->   'has_delete_permission':
self.has_delete_permission(request), <- added here
'root_path': self.admin_site.root_path,
'app_label': app_label,
'action_form': action_form,
'actions_on_top': self.actions_on_top,
'actions_on_bottom': self.actions_on_bottom,
}

... but ... but ... surely that comes from the land of Harry the
Hacker?
Isn't there a better way to do this, or is this a genuine bug?

Any help or thoughts very welcome,

Cheers
R






On Nov 20, 3:18 pm, rd-london  wrote:
> Hi,
> Wonder if anyone can help.
>
> Have following chunk in my own change_list.html template:
>
>     {% block object-tools %}
>         
>           {% if has_add_permission %}
>           
>              title="Add Comment" class="addlink">
>               {% blocktrans with cl.opts.verbose_name as name %}Add
> {{ name }}{% endblocktrans %}
>             
>           
>           {% endif %}
>           {% if has_delete_permission %}
>           
> My thing goes here
>           
>           {% endif %}
>         
>
>     {% endblock %}
>
> Created a user that has delete permissions. Got my own ModelAdmin and
> have checked using the debugger that the user does indeed have delete
> permissions.
>
> The "def has_add_permission" fn in contrib/admin/options.py *is* being
> called (I've put "import pdb;pdb.set_trace()" there to check), whereas
> def has_delete_permission is not - and I can't work out for the life
> of me why not.
>
> Anyone help at all?
>
> Thanks,
> R

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




has_delete_permission not called in an admin template?

2009-11-20 Thread rd-london
Hi,
Wonder if anyone can help.

Have following chunk in my own change_list.html template:

{% block object-tools %}

  {% if has_add_permission %}
  

  {% blocktrans with cl.opts.verbose_name as name %}Add
{{ name }}{% endblocktrans %}

  
  {% endif %}
  {% if has_delete_permission %}
  
My thing goes here
  
  {% endif %}


{% endblock %}

Created a user that has delete permissions. Got my own ModelAdmin and
have checked using the debugger that the user does indeed have delete
permissions.

The "def has_add_permission" fn in contrib/admin/options.py *is* being
called (I've put "import pdb;pdb.set_trace()" there to check), whereas
def has_delete_permission is not - and I can't work out for the life
of me why not.

Anyone help at all?

Thanks,
R






--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.