-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[admin] Change empty org label #171 #209
[admin] Change empty org label #171 #209
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, this should be different when organization field is required. Otherwise it might leave the impression that systemwide is available but then it'd raise validation error while submitting the form.
I totally agree with you @purhan, but the code you have suggested can be modified as below.
if not fields['organization'].required:
fields['organization'].empty_label = _('Shared systemwide (no organization)')
I don't think, we need to add strikethrough to show that a field is required. We can keep the default empty_label
when the organization field is required.
@pandafy Done. Like I said, I removed the test as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pandafy Done. Like I said, I removed the test as well.
@purhan tests are good. Let's add a test.
@pandafy sure. One more thing, as you can see I wrote a test for this, but after implementing these changes, I can't test this feature as there is no model with optional organization field in this project.
I was not able to reply to this before. But better later than never.
You can add an admin site for Template
model below. Since it uses ShareableOrgMixin
, the organization field is optional.
openwisp-users/tests/testapp/models.py
Lines 9 to 13 in 4569b60
class Template(ShareableOrgMixin): | |
name = models.CharField(max_length=16) | |
def clean(self): | |
self._validate_org_reverse_relation('config_set') |
@devkapilbansal the optional organization field is not used directly in this module, but in other modules of OpenWISP. Sometimes, you will need to think about OpenWISP as whole instead of individual module. Then only, some features make sense.
|
813baa8
to
2a807f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @purhan, looks good but while testing it I realized there's a few things to improve which are not related to this PR.
The empty label should be available only to super users (I found out is simple: fields['organization'].empty_label = None
, let me know if you can help with this (we'll need a test for this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @purhan 👍 👍
Closes #171