Skip to content

Commit

Permalink
Merge pull request #47 from Hrishabh598/main
Browse files Browse the repository at this point in the history
added get_form in TagAdmin #8
  • Loading branch information
DjangoCRM authored Sep 24, 2024
2 parents 62bc196 + aaad7b6 commit ea1840f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crm/site/tagadmin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib.auth import get_permission_codename
from django.utils.translation import gettext_lazy as _

from django import forms
from crm.forms.admin_forms import TagForm
from crm.site.crmmodeladmin import CrmModelAdmin

Expand Down Expand Up @@ -54,3 +54,11 @@ def has_delete_permission(self, request, obj=None):
if request.user.is_superuser:
return True
return False

def get_form(self,request, obj=None):
form = TagForm
if not request.user.department_id:
form.base_fields['department'].widget = forms.Select()
else:
form.base_fields['department'].widget = forms.HiddenInput()
return form

0 comments on commit ea1840f

Please sign in to comment.