Skip to content
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

UI Changes; Support for lt, lte, gt, gte; and Advanced Filter Admin queryset filtering by User #25

Merged
merged 10 commits into from
Jun 7, 2016

Conversation

pjpassa
Copy link
Contributor

@pjpassa pjpassa commented Jun 3, 2016

No description provided.

@@ -230,7 +230,7 @@ def forms(self):

AFQFormSet = formset_factory(
AdvancedFilterQueryForm, formset=AdvancedFilterFormSet,
extra=1, can_delete=True)
extra=0, can_delete=True)

AFQFormSetNoExtra = formset_factory(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFQFormSetNoExtra, defined just below (line 235), already has 0 extra forms. And I believe the current default is used when creating a new filter, which would make sense wince a filter with 0 rules is not really interesting.

Perhaps it would be better to add an require an extra form only when adding, but not when editing rules? We can toggle between the forms by passing extra_form=True/False in admin.py.

@asfaltboy
Copy link
Member

Hello @pjpassa, thank you for contributing!

I like most of the changes, but please take note of my comments. Also, the tests now need correction; looks like it has to do with the queryset/change/delete permission checks.

@pjpassa
Copy link
Contributor Author

pjpassa commented Jun 6, 2016

@asfaltboy I've added/updated tests as requested and made the changes you requested, too. There is one more bug that I'm trying to track down, and I'll need to figure out what failed in the latest build.

1

When you change the field you get a dropdown for value that is unusable.

2

But when you add another filter everything fixes itself.

3

I haven't been able to track down the issue, but if you can help me track down what is wrong, I'd be glad to fix it for this pull request.

@@ -361,7 +361,7 @@ def initialize_form(self, instance, model, data=None, extra=None):
AdvancedFilterQueryForm._parse_query_dict(
field_data, model))

formset = AFQFormSetNoExtra if extra is None else AFQFormSet
formset = AFQFormSetNoExtra if not extra or not instance else AFQFormSet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right about not extra, good catch!

However, I'm not sure if I like or not instance here. If we're editing a new form and get an error on submit, the instance is still None, but I think the user expects to see an extra form row (if it was there before the error).

@asfaltboy
Copy link
Member

asfaltboy commented Jun 6, 2016

Hi @pjpassa, thank you again for your work.

The fancy select box is an easy-select2 widget. It is indeed initialised on field selection, in a method called OperatorHandlers.initialize_select2.

That code issues a request to query for available value choices for a given field and displays a smart select box which should also accept custom values.

Honestly I don’t know of an issue with this, but you can disable it for given fields by updating settings.ADVANCED_FILTERS_DISABLE_FOR_FIELDS = (‘email’, ). Please refer to the GetFieldChoices view for more info.

If you do find an issue that you can easily reproduce, kindly open an issue.

On a side note, we're definitely lacking on usability, documentation and tests for the frontend features, including this widget, other javascript and styles.

Correction: I am aware of a number of easy-select2 issues as well as other frontend bugs.

@asfaltboy
Copy link
Member

Regarding the failing test, I have a feeling this has to do with "extra forms fix". You can try reverting only that change and re-run the tests. I think it would be easier to pinpoint if each feature was a separate pull request, for next time 😄

@pjpassa
Copy link
Contributor Author

pjpassa commented Jun 6, 2016

I believe those last 2 commits cover everything. The QuantifiedCode issue is related to the new test I created, and I don't see anything wrong with the problems it lists, to be honest. Especially seeing that the same "problems" exist in other places in the code base and I would break consistency if I fixed them.

I'll continue to do testing on the front-end problem and create an issue as necessary. Or if I can fix it, I'll create a new pull request. 😉

@coveralls
Copy link

coveralls commented Jun 6, 2016

Coverage Status

Coverage increased (+0.1%) to 96.198% when pulling 5cdcbe9 on worthwhile:develop into 5fc8c65 on modlinltd:develop.

@coveralls
Copy link

coveralls commented Jun 6, 2016

Coverage Status

Coverage increased (+0.1%) to 96.198% when pulling 4f928da on worthwhile:develop into 5fc8c65 on modlinltd:develop.

@asfaltboy asfaltboy merged commit d3ee9f4 into modlinltd:develop Jun 7, 2016
@asfaltboy
Copy link
Member

Looks great! Thanks again @pjpassa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants