[Django] #32462: Django ORM get_readonly_fields, action on a ONE table row

8 views
Skip to first unread message

Django

unread,
Feb 19, 2021, 5:23:48 AM2/19/21
to django-...@googlegroups.com
#32462: Django ORM get_readonly_fields, action on a ONE table row
-------------------------------------+-------------------------------------
Reporter: Naum74 | Owner: nobody
Type: | Status: new
Uncategorized |
Component: | Version: 3.1
contrib.admin |
Severity: Normal | Keywords: get_readonly_fields
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hello dear Django experts!
I ask for help in this matter:
There is a code:
----

{{{
def get_readonly_fields(self, request, obj=None):

all_fields = list(self.get_fields(request, obj))
user_blocked_fields = all_fields[:]
iskom = 'SELFDISPOSAL'
naxodim =
Articles.objects.filter(delivery_type__title__icontains=iskom)

if request.user.has_perm('excels.can_edit_manager_group'):
user_blocked_fields = [f for f in user_blocked_fields if f not
in self.manager_group_fields]

if request.user.has_perm('excels.can_edit_upakovka_group'):
user_blocked_fields = [f for f in user_blocked_fields if f not
in self.upakovka_group_fields]

if request.user.has_perm('excels.can_edit_transport_group'):
user_blocked_fields = [f for f in user_blocked_fields if f not
in self.transport_group_fields]

# if request.user.has_perm('excels.can_edit_manager_group') and
naxodim:
# user_blocked_fields = [f for f in user_blocked_fields if f
not in self.manager_and_transport_group_fields]
#
# if request.user.has_perm('excels.can_edit_transport_group') and
naxodim:
# user_blocked_fields = [f for f in user_blocked_fields if f
not in self.transport_minus_all_group_fields]

return user_blocked_fields"
}}}

It turns out that I have a change of permissions for editing fields
depending on user rights.
further I want to make permission not for the whole table, but only for
ONE ROW of the table.
That is, when you enter one record in the table and put the word
"SELFDISPOSAL" in FK there, then you write down and then some
readonlu_fields change fields to others.
This happens on my filter, but for the whole table (class), and I need
ONLY ONE LINE WHERE I HAVE THE SPECIFIED WORD "SELFDISPOSAL" IN ONE OF THE
FIELDS.!
How should I do it?
Thanks to everyone who responds!

----

--
Ticket URL: <https://code.djangoproject.com/ticket/32462>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 19, 2021, 5:35:16 AM2/19/21
to django-...@googlegroups.com
#32462: Django ORM get_readonly_fields, action on a ONE table row
-------------------------------------+-------------------------------------
Reporter: Naum Klaiderman | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 3.1
Severity: Normal | Resolution: invalid
Keywords: get_readonly_fields | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Please don't use Trac as a support channel. Closing per
TicketClosingReasons/UseSupportChannels.

--
Ticket URL: <https://code.djangoproject.com/ticket/32462#comment:1>

Reply all
Reply to author
Forward
0 new messages