#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.dd4606cea8b07f075d808f6ee7601480%40djangoproject.com.

Reply via email to