carltongibson / neapolitan

Quick CRUD views for Django
https://noumenal.es/neapolitan/
MIT License
413 stars 30 forks source link

fix_46_allow_for_missing_actions_while_rendering #47

Closed nanuxbe closed 1 week ago

nanuxbe commented 3 weeks ago

Hey @carltongibson ,

here's the (initial?) PR for #46 with the changes discussed in the issue.

While creating this PR though, I noticed it was rather straightforward to remove actions but that adding an action (ie: duplicate, archive, open, ...) would be rather complicated due to the nature of Role that cannot be extended.

I am thinking about refactoring Role to be more flexible (either not an Enum anymore or implementing something like a role_factory). It would probably be best left in its own PR but it could very well be included here too.

carltongibson commented 3 weeks ago

While creating this PR though, I noticed it was rather straightforward to remove actions but that adding an action (ie: duplicate, archive, open, ...) would be rather complicated due to the nature of Role that cannot be extended.

I am thinking about refactoring Role to be more flexible (either not an Enum anymore or implementing something like a role_factory). It would probably be best left in its own PR but it could very well be included here too.

Ah, yes. Separate issue. 😅 I have thoughts in this direction, that I need to upstream. Roughly: The core CRUD roles should be an enum — there just are the options there are. BUT we need a role protocol, which can be implemented by a custom role-like composing the core CRUD roles plus additional extra actions.

At that point it's feasible that we can automatically add links to the templates for custom actions.

dacodekid commented 3 weeks ago

@nanuxbe, I just tried your branch, but still getting the same -create' is not a valid view function or pattern name. error.

# pyproject.toml
neapolitan = {git = "https://github.com/nanuxbe/neapolitan.git"}
carltongibson commented 3 weeks ago

@dacodekid You probably need to specify the PR branch.

dacodekid commented 3 weeks ago

@carltongibson

I tried that as well but still getting the same error. I'll wait until this gets merged.

neapolitan = { git = "https://github.com/nanuxbe/neapolitan.git", branch = "fix_#46_NoReverseMatch" }
carltongibson commented 2 weeks ago

Great. Thanks for the follow up @nanuxbe. I'll pull this in later on. Have a great Sunday.