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

Manage excluded_products in ranges dashboard #4073

Merged
merged 33 commits into from Jun 23, 2023

Conversation

gwaidacher
Copy link
Contributor

@gwaidacher gwaidacher commented Mar 14, 2023

Added tabs to range - products in dashboard, first tab contains now existing form for managing included products, in the second tab the excluded products can be managed, with a separate textfield for upc input and a second fileupload form.

see #4055

@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #4073 (a5ac234) into master (1a8aaef) will decrease coverage by 0.04%.
The diff coverage is 97.89%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4073      +/-   ##
==========================================
- Coverage   87.42%   87.39%   -0.04%     
==========================================
  Files         291      291              
  Lines       15858    15932      +74     
==========================================
+ Hits        13864    13923      +59     
- Misses       1994     2009      +15     
Impacted Files Coverage Δ
src/oscar/apps/offer/models.py 100.00% <ø> (ø)
src/oscar/apps/offer/abstract_models.py 89.00% <92.85%> (+0.01%) ⬆️
src/oscar/apps/dashboard/ranges/forms.py 74.02% <97.05%> (-25.98%) ⬇️
src/oscar/apps/dashboard/ranges/views.py 87.23% <100.00%> (+7.76%) ⬆️

... and 1 file with indirect coverage changes

@gwaidacher
Copy link
Contributor Author

Added missing tests. where does the "1 file has unexpected coverage changes not visible in diff " error come from?

Copy link
Contributor

@joeyjurjens joeyjurjens left a comment

Choose a reason for hiding this comment

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

Hi @gwaidacher , thank you very much for your PR. It's quite a big one and we really appreciate it that you're taking the time for it!

I do have some review comments though, if you have any questions or comments to mine, just let me know! :)

src/oscar/apps/dashboard/ranges/views.py Outdated Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/views.py Outdated Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/views.py Outdated Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/views.py Outdated Show resolved Hide resolved
src/oscar/apps/offer/abstract_models.py Outdated Show resolved Hide resolved
src/oscar/apps/offer/abstract_models.py Outdated Show resolved Hide resolved
src/oscar/locale/de/LC_MESSAGES/django.po Outdated Show resolved Hide resolved
src/oscar/views/generic.py Outdated Show resolved Hide resolved
@gwaidacher
Copy link
Contributor Author

gwaidacher commented Mar 21, 2023

  • changed field "included to "upload_type" in RangeProductFileUpload
  • changed the "excluded" kwarg in redirect url to "active_tab"
  • passed the "excluded" argument in RangeProductForm via init() method
  • updated translation strings

@gwaidacher
Copy link
Contributor Author

Hi @gwaidacher , thank you very much for your PR. It's quite a big one and we really appreciate it that you're taking the time for it!

I do have some review comments though, if you have any questions or comments to mine, just let me know! :)

PR updated, please have a look

Copy link
Contributor

@joeyjurjens joeyjurjens left a comment

Choose a reason for hiding this comment

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

Hi @gwaidacher , I still have some feedback to keep it a bit more clean. Thanks again for your time and effort.

src/oscar/apps/dashboard/ranges/apps.py Outdated Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/forms.py Outdated Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/views.py Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/views.py Outdated Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/views.py Outdated Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/views.py Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/views.py Outdated Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/views.py Outdated Show resolved Hide resolved
src/oscar/views/generic.py Outdated Show resolved Hide resolved
tests/functional/dashboard/test_range.py Outdated Show resolved Hide resolved
Copy link
Contributor

@joeyjurjens joeyjurjens left a comment

Choose a reason for hiding this comment

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

Few small things left, the rest looks great!

src/oscar/apps/dashboard/ranges/views.py Outdated Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/views.py Outdated Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/forms.py Show resolved Hide resolved
src/oscar/apps/dashboard/ranges/forms.py Outdated Show resolved Hide resolved
self.handle_file_products(request, range, form)
return redirect(
reverse('dashboard:range-products', kwargs={'pk': range.pk})
+ '?upload_type=excluded'
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is really necessary. Once the upload was successful, we can just redirect them as is, maybe with a success message stating it was successful. The GET parameter is not really needed in my opinion.

Copy link
Contributor Author

@gwaidacher gwaidacher Jun 5, 2023

Choose a reason for hiding this comment

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

It's used to redirect to the page having the second tab with excluded products active.

)
return redirect(
reverse('dashboard:range-products', kwargs={'pk': range.pk})
+ '?upload_type=excluded'
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.


if form.cleaned_data["upload_type"] == \
RangeProductFileUpload.EXCLUDED_PRODUCTS_TYPE:
action = _('excluded from this range')
Copy link
Contributor

Choose a reason for hiding this comment

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

You forgot to actually add the product to the excluded products here

product_range.excluded_products.add(product)

Copy link
Contributor

Choose a reason for hiding this comment

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

please add a test for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is already a test for this in test_range: "test_dupe_excluded_skus_warning"
"'The products with SKUs or UPCs matching 456 have already been excluded from this range'"

<div class="float-right">
<input type="hidden" name="action" value="remove_excluded_products" />
<button type="submit" class="btn btn-secondary" data-loading-text="{% trans 'Removing...' %}">
{% trans "Remove excluded products" %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change this to:

Remove selected excluded products

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@viggo-devries
Copy link
Contributor

In general this is missing some tests, great that the existing tests still pass but please add some specific tests for excluding the products.

@viggo-devries viggo-devries added Needs more work Needs tests This pull request does not have sufficient tests labels Jun 16, 2023
@gwaidacher
Copy link
Contributor Author

In general this is missing some tests, great that the existing tests still pass but please add some specific tests for excluding the products.

Hi! There are already 2 tests in test_range.RangeProductViewTest: test_upload_excluded_file_with_skus for the upload-file form and test_dupe_excluded_skus_warning - if this is insufficient, please specify which function should be tested.

@viggo-devries
Copy link
Contributor

In general this is missing some tests, great that the existing tests still pass but please add some specific tests for excluding the products.

Hi! There are already 2 tests in test_range.RangeProductViewTest: test_upload_excluded_file_with_skus for the upload-file form and test_dupe_excluded_skus_warning - if this is insufficient, please specify which function should be tested.

Yes I saw but the fact that your tests missed this entire functionality: f97053a is not good.

I would like to see tests for every action that can be performed and also the result of that action.
You should be able to come up with way more than the 2 actions you have tested now. like:
test_add_single_product_to_excluded_range
test_add_multipe_products_to_excluded_range
remove_single_product_from_excluded_range
remove_multiple_products_from_excluded_range
etc.etc.

File Upload for excluded_products
added url to show tab with excluded_products
process excluded_products form
Form for excluded_products
Added nav-tabs for excluded_products
fix missing komma
fix parenthesis
gwaidacher and others added 21 commits June 23, 2023 14:02
fix continuation line
fix import redirect
fix import form
fix continuation line
added migration file
query first form in view
test first form for included_products
alter field id
test RangeProductExcludedFileUpload
import corrected
continuation line
fix import order
added RangeProductExcludedFileUpload registry
author gwaidacher <gw@acat.cc> 1678894171 +0100
committer Joey Jurjens <joey@highbiza.nl> 1687521813 +0200

added Meta on AbstractRangeProductExcludedFileUpload

test 2nd form

restructured forms

fixed contination line

changed offer migrations

fix removed obsolete code

fix test_upload_excluded_file_with_skus

fix newline

set form.included = True

fix return form

add included to handle_file_products

updated error message

fix error msg in test

fix error msg

fix success msg

changed forms key

modified test

modified test url

test 3rd form

test form 2

added test for dupe skus

query form 3

better form 3?

should be form 2

add products

check form 2

context['form_excluded']

added action to msg

fixed message

fixed success msg

added test for removing excluded product

add test for removing included product

fixed url

fix submit form

improved clean_query

fixed german translation

test unexpected coverage changes

Restructured forms

fixed form test

updated translation strings

fixed format mapping

format mapping

format mapping

format mapping

updated test

fixed msg

++ "this"

no mapping

fix ngettext msg

undo changes

undo changes

pass excluded=True as kwarg

removed excluded from init args

update test_range.py

refactored forms

Update test_range.py

default for upload_type

added comment

fix continuation line

set required false

recommit

changed url for excluded products

uncommented get_success_url()

fix url

fix url

removed url2

fix success message

fixed error message

fix added msg

merged cleaned_query into clean

use add_error('query') in clean()

only check new products if there are

added RangeProductFileUpload.EXCLUDED_PRODUCTS_TYPE

moved validation to separate method

removed trailing whitespace

more trailing whitespace...

added comment

fix add product to excluded products

Establish better test base line
@joeyjurjens
Copy link
Contributor

@gwaidacher Hey man. I have written the missing tests, so you don't have to do that anymore.

@gwaidacher
Copy link
Contributor Author

@gwaidacher Hey man. I have written the missing tests, so you don't have to do that anymore.

Thank you very much :D

@joeyjurjens
Copy link
Contributor

@gwaidacher Hey man. I have written the missing tests, so you don't have to do that anymore.

Thank you very much :D

We should thank you! You've spend quite some time into this. It'll likely be merged to master today! :)

@specialunderwear specialunderwear merged commit 1d55f8d into django-oscar:master Jun 23, 2023
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs more work Needs tests This pull request does not have sufficient tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants