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

Remove views from existing projects on view update #431

Merged
merged 14 commits into from
Nov 17, 2022

Conversation

m6121
Copy link
Member

@m6121 m6121 commented Mar 18, 2022

This PR aims at fixing #345 by automatically updating existing projects on saving of views. I added a separate view and project in the test-data in order to test this case.

@jochenklar
Copy link
Member

Thanks @m6121 , we need to talk about this though. We have a few more cases we should treat the same: views can be restricted to sites and groups as well. Also the same goes for tasks.

On the technical level, maybe a post_save signal for View would be better, since it also triggers when the view is updated through the admin interface.

@jochenklar jochenklar changed the base branch from master to dev March 18, 2022 13:18
@m6121 m6121 marked this pull request as draft March 18, 2022 14:03
@m6121
Copy link
Member Author

m6121 commented Mar 23, 2022

Hi @jochenklar, I refactored the code to cover the three dependencies and implemented a configuration flag in order to enable this feature. However, the tests did not yet cover all possible cases. I employed the m2m_changed signal which is connected in the views/apps.py.

@coveralls
Copy link

coveralls commented Mar 23, 2022

Coverage Status

Coverage increased (+0.08%) to 90.581% when pulling 3c8b920 on ubrostock:view_update into b12720c on rdmorganiser:dev.

@m6121 m6121 marked this pull request as ready for review March 24, 2022 16:01
@m6121
Copy link
Member Author

m6121 commented Mar 24, 2022

I added some tests and fixed the logic and think this is in a status worth a review, especially the implemented logic.

@jochenklar jochenklar added this to the 1.9.0 milestone May 19, 2022
@jochenklar jochenklar changed the base branch from dev to dev2 June 8, 2022 08:26
@jochenklar jochenklar changed the base branch from dev2 to master June 8, 2022 08:26
@jochenklar jochenklar marked this pull request as draft June 8, 2022 08:26
rdmo/views/signals.py Outdated Show resolved Hide resolved
rdmo/views/signals.py Outdated Show resolved Hide resolved
rdmo/views/signals.py Outdated Show resolved Hide resolved
@jochenklar
Copy link
Member

Hey @m6121 , thanks a lot, looks good, I added a few (minor) comments inline.

I wonder if we should move the signals and handlers to the projects app since it changes stuff in projects (Project). Not sure about it. I tried so far to keep kind of a hierarchy between the django apps.

core -> conditions -> projects
        domain
        ...

and not import Project in views. But maybe this is not super important, what do you think?

In another project I put the handlers in a separate file handlers.py to keep the apps.py file small: https://github.com/django-daiquiri/daiquiri/blob/master/daiquiri/auth/apps.py#L10, should we do this in rdmo as well or is this overkill?

@jochenklar
Copy link
Member

Oh and it would be good if you indent the fixtures with 2 spaces and the rest with 4 spaces. I have a trailing white space plugin and a flake8 plugin in my editor which makes me even more pedantic!

@jochenklar jochenklar changed the base branch from master to dev October 21, 2022 11:36
Comment on lines +11 to +12
if settings.PROJECT_REMOVE_VIEWS:
from . import handlers
Copy link
Member Author

Choose a reason for hiding this comment

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

I moved the implementation into the projects app. I think this makes sense as you suggested. Furthermore, I also moved it from signals.py to handlers.py. However, I am not happy with the linking into the projects/apps.py due to the configuration flag.

@m6121
Copy link
Member Author

m6121 commented Oct 22, 2022

I also adjusted the indentation to two spaces. The formatting that I originally committed was created using the djangoadmin-command as we proposed here: https://github.com/rdmorganiser/rdmo/blob/master/docs/dev.md

python manage.py dumpdata --indent 4 -o ../rdmo/testing/fixtures/views.json views

Even when using --indent 2 there are some small differences between the formattings.

@m6121
Copy link
Member Author

m6121 commented Oct 24, 2022

Hi @jochenklar, thanks a lot for your review! Hope I addressed all comments. Not sure if we should change the import of the handlers to be more independent of the feature flag. Despite this, I think it is ready for a review.

@m6121 m6121 marked this pull request as ready for review October 24, 2022 08:58
@jochenklar
Copy link
Member

Thanks! I think we need to fix the dev.md file. I usually use just python manage.py dumpdata views > ../rdmo/testing/fixtures/views.json. I don't know why we stated 4 spaces in the file, maybe @triole knows. Otherwise I think we are done, @triole can you have a look.

@m6121
Copy link
Member Author

m6121 commented Oct 26, 2022

I think the dumping commands in the dev.md file were proposed by me. So, we can safely replace them by your command. Thanks a lot for reviewing, again.

@jochenklar jochenklar merged commit 70c936b into rdmorganiser:dev Nov 17, 2022
@m6121 m6121 deleted the view_update branch November 29, 2022 13:41
CalamityC pushed a commit to CalamityC/rdmo that referenced this pull request Nov 23, 2023
Remove views from existing projects on view update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants