Skip to content

parameterize namespace#1

Merged
KommuSoft merged 15 commits into
masterfrom
feature/parameterize-namespace
Apr 26, 2025
Merged

parameterize namespace#1
KommuSoft merged 15 commits into
masterfrom
feature/parameterize-namespace

Conversation

@KommuSoft
Copy link
Copy Markdown
Member

@KommuSoft KommuSoft commented Apr 8, 2025

Summary by CodeRabbit

  • New Features
    • Introduced configurable admin URL namespaces for more flexible link generation.
    • Added action buttons in the admin list view for executing actions on individual records directly, improving efficiency.
    • Enhanced admin interface with single-item action buttons supported by client-side scripting for streamlined workflows.
    • Expanded documentation with usage examples and installation guidance for new admin features.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2025

Warning

Rate limit exceeded

@KommuSoft has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 23 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2e315e4 and 56f0a32.

📒 Files selected for processing (3)
  • README.md (3 hunks)
  • docs/source/conf.py (1 hunks)
  • pyproject.toml (1 hunks)

Walkthrough

The changes add a new class attribute admin_url_namespace to the LinkFieldAdminMixin class in the Django admin module. This attribute is used within the _link_to_model_field method to determine the URL prefix dynamically. Instead of hardcoding "admin:", the method now checks if admin_url_namespace is set and prefixes the URL root accordingly. Additionally, a new mixin SingleItemActionMixin is introduced to enable action buttons as a column in the Django admin list display, allowing single-item admin actions via a JavaScript helper function. The JavaScript function get_checkboxes is added to facilitate selecting a single item and submitting the corresponding admin action.

Changes

File Change Summary
django_adminlink/admin.py Added admin_url_namespace attribute to LinkFieldAdminMixin and modified _link_to_model_field to use it for URL prefixing. Added new SingleItemActionMixin with action_buttons, action_button_column, get_list_display, and media to support single-item action buttons in admin list. Added SingleItemActionAdmin combining the mixin with ModelAdmin.
django_adminlink/static/js/single_admin_action.js Added get_checkboxes(e) JavaScript function to select a single checkbox by primary key, set the admin action, uncheck others, and submit the form, enabling single-item admin actions via buttons.
README.md Extended documentation to describe the new SingleItemActionMixin feature, explaining usage of action buttons in admin list view, their configuration, and JavaScript behavior. Also rephrased and expanded the LinkFieldAdminMixin section for clarity.
docs/source/getting_started.rst Added usage example and explanation for SingleItemActionMixin showing how to add per-row action buttons in Django admin with code snippet.
docs/source/installation.rst Updated installation instructions clarifying that the package is a Django app but only needs to be added to INSTALLED_APPS if using SingleItemActionMixin or derivatives for static files inclusion.

Sequence Diagram(s)

sequenceDiagram
    participant Admin as Django Admin
    participant SingleMixin as SingleItemActionMixin
    participant JS as single_admin_action.js
    participant Form as Admin Form

    Admin->>SingleMixin: Render list display with action_button_column
    SingleMixin->>Admin: Append action buttons with JS call
    User->>JS: Click action button (action, pk)
    JS->>Form: Set action select value
    JS->>Form: Uncheck all checkboxes
    JS->>Form: Check checkbox for pk
    JS->>Form: Submit form
    Form->>Admin: Process single-item action
Loading
sequenceDiagram
    participant LinkMixin as LinkFieldAdminMixin
    participant _link as _link_to_model_field

    LinkMixin->>_link: Call _link_to_model_field()
    _link->>_link: Check if admin_url_namespace is set
    alt Namespace is set
        _link->>_link: Prefix URL using admin_url_namespace
    else
        _link->>_link: Use default "admin:" prefix
    end
    _link-->>LinkMixin: Return constructed URL
Loading

Poem

🐇✨
Hop, hop, through lines of code I prance,
A namespace is added, oh what a chance!
Buttons appear, just one click away,
Single actions brighten the admin day.
With a twitch of my nose, I celebrate the dance!
🐇💻🎉

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
django_adminlink/admin.py (1)

36-39: Implementation looks good, but consider one edge case.

The logic to conditionally prefix the URL with the namespace is well-implemented. The code now dynamically builds URLs using the configured namespace instead of hardcoding "admin:".

However, there's a small edge case to consider: what if self.admin_url_namespace is an empty string? The current check if self.admin_url_namespace: would skip adding a colon separator entirely. This might be intentional, but if it's not, you might want to handle this explicitly.

If it's intentional to support no namespace at all (including no colon), then this implementation is correct. Otherwise, consider:

-            if self.admin_url_namespace:
+            if self.admin_url_namespace is not None:
               # prefix with namespace
               url_root = f"{self.admin_url_namespace}:{url_root}"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e38105 and 661aa6c.

📒 Files selected for processing (1)
  • django_adminlink/admin.py (2 hunks)
🔇 Additional comments (1)
django_adminlink/admin.py (1)

10-10: Good addition of configurable namespace parameter.

The admin_url_namespace class attribute with a default value of "admin" provides a clean way to customize the namespace used in URL generation while maintaining backward compatibility.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
django_adminlink/admin.py (1)

86-89: 🛠️ Refactor suggestion

Static path should be relative to enable Django’s static-files finders

Using an absolute path (/static/...) bypasses collectstatic, custom storage back-ends, and any CDN prefixing logic.

-        return super().media + Media(js=["/static/js/single_admin_action.js"])
+        return super().media + Media(js=["django_adminlink/js/single_admin_action.js"])

Place the file under django_adminlink/static/django_adminlink/js/… so that STATIC_URL and STATICFILES_STORAGE are respected.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 661aa6c and 5e3d7b5.

📒 Files selected for processing (2)
  • django_adminlink/admin.py (3 hunks)
  • django_adminlink/static/js/single_admin_action.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
django_adminlink/admin.py (1)
django_adminlink/static/js/single_admin_action.js (1)
  • item (6-6)
🔇 Additional comments (2)
django_adminlink/admin.py (2)

78-80: Avoid serialising primary keys that are already safe JavaScript literals

json.dumps(str(obj.pk)) produces "123" (a quoted string) and therefore the second parameter passed to get_checkboxes is "\"123\"" (string with quotes).
Since primary keys are typically integers or simple strings, you can pass them directly:

-                (json.dumps(item), json.dumps(str(obj.pk)), label)
+                (json.dumps(item), obj.pk, label)

This keeps the JavaScript signature clean: get_checkboxes("publish", 123)

[ suggest_essential_refactor ]


40-43: Namespace attribute should tolerate None without emitting a colon

When admin_url_namespace is None or an empty string, the conditional still prepends ":", resulting in ":app_model_change" which breaks reverse().
Consider adjusting the logic:

-            if self.admin_url_namespace:
-                # prefix with namespace
-                url_root = f"{self.admin_url_namespace}:{url_root}"
+            if self.admin_url_namespace:           # truthy & non-empty
+                url_root = f"{self.admin_url_namespace}:{url_root}"

or normalise the attribute during __init__.

Comment thread django_adminlink/static/js/single_admin_action.js Outdated
Comment thread django_adminlink/admin.py
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
django_adminlink/static/js/single_admin_action.js (1)

1-18: Properly implemented JavaScript function with defensive checks

The function correctly implements single-item action functionality for Django admin with good defensive programming practices by checking for null elements. This helps prevent runtime errors if elements aren't found.

A few minor improvements could enhance maintainability:

-function get_checkboxes(e) {
+function get_checkboxes(e) {
     const pk = e.getAttribute('data-pk');
     const action = e.getAttribute('data-action');
-    const actionSelector = document.querySelector(`select[name=action]`);
+    const actionSelector = document.querySelector('select[name="action"]');
     if(actionSelector == null) {
         return;
     }
     actionSelector.value = action;
-    for(const item of document.querySelectorAll('input.action-select[type=checkbox]')) {
+    for(const item of document.querySelectorAll('input.action-select[type="checkbox"]')) {
       item.checked = false;
     }
-    const item = document.querySelector(`input.action-select[type=checkbox][value="${pk}"]`);
+    const item = document.querySelector(`input.action-select[type="checkbox"][value="${pk}"]`);
     if(item == null) {
         return;
     }
     item.checked = true;
     item.form.submit();
 }
django_adminlink/admin.py (1)

63-77: Well-structured SingleItemActionMixin with proper HTML generation

The mixin is well implemented with:

  • Flexible action button configuration (supports both list and dict formats)
  • Proper HTML generation with format_html_join to prevent XSS
  • Correct attribute handling for the JavaScript interaction

One enhancement to consider is adding CSS styling classes to the buttons for better UI integration:

-            '<button type="button" data-action="{}" data-pk="{}" onclick="get_checkboxes(this)">{}</button>',
+            '<button type="button" class="button" data-action="{}" data-pk="{}" onclick="get_checkboxes(this)">{}</button>',
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e3d7b5 and e40211f.

📒 Files selected for processing (2)
  • django_adminlink/admin.py (3 hunks)
  • django_adminlink/static/js/single_admin_action.js (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
django_adminlink/admin.py (1)
django_adminlink/static/js/single_admin_action.js (2)
  • item (12-12)
  • pk (2-2)
🔇 Additional comments (3)
django_adminlink/admin.py (3)

11-11: Good parameterization of admin URL namespace

Adding the admin_url_namespace attribute allows for more flexible configuration when using this mixin in different admin contexts or customized Django installations.


37-40: Correctly implemented dynamic URL namespace

The implementation correctly builds the URL with the configurable namespace instead of hardcoding "admin:". The conditional check ensures backward compatibility if the namespace isn't set.


78-80: Properly extends list_display without overwriting parent implementation

The method correctly preserves the existing list_display items by using the unpacking operator to combine the parent's list_display with the new action column.

Comment thread django_adminlink/admin.py Outdated
KommuSoft and others added 4 commits April 26, 2025 15:04
Docstrings generation was requested by @KommuSoft.

* #1 (comment)

The following files were modified:

* `django_adminlink/admin.py`
* `django_adminlink/static/js/single_admin_action.js`
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 26, 2025

Note

Generated docstrings for this pull request at #2

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (10)
README.md (10)

10-10: Relocate single-action description under Usage section.
The paragraph introducing single-row actions is placed before the main Usage section. For clearer structure, move it under the “## Usage” heading or directly beneath the “### Single row actions” subheading.


24-24: Streamline introductory sentence in Usage section.
Consider tightening the phrasing for brevity and clarity. For example:

-Once the package is installed, we can work with the mixins provided by the package.
+After installation, import and apply the provided mixins in your `ModelAdmin` classes.

26-26: Clarify field‐linking heading.
The heading only calls out ForeignKey, but the mixin also handles OneToOneField. For consistency, you might rename:

-### Adding links to `ForeignKey` fields
+### Linking `ForeignKey` and `OneToOneField` fields

28-28: Capitalize sentence start.
Documentation sentences should begin with a capital letter. For example:

-you can use the `LinkFieldAdminMixin` mixin in the admins...
+You can use the `LinkFieldAdminMixin` mixin in the admins...

41-41: Refine example explanation for clarity.
The current sentence is long and repeats “Genre.” Consider simplifying:

-If `genre` is a `ForeignKey` to a `Genre` model for example, and `Genre` has its own `ModelAdmin`, it will automatically convert `genre` into a column that adds a link to the admin detail view of the corresponding genre.
+If `genre` is a `ForeignKey` to a `Genre` model (with its own `ModelAdmin`), this mixin renders the `genre` column as a link to the related genre’s detail view.

44-44: Split comma splice into two sentences.
Replace the comma splice with two clear sentences. For example:

-The package also provides a `SingleItemActionMixin`, this enables to add a column at the right end of the admin that contains (one or more) buttons.
+The package also provides a `SingleItemActionMixin`. It adds a column at the right end of the admin containing one or more buttons.

46-46: Improve wording for listing actions.
Make the instruction more direct. For example:

-One can specify which actions to run by listing these, for example:
+Specify actions by listing their names (or mapping labels to action names), for example:

48-48: Use consistent code fence language tag.
The rest of the README uses python for code fences—consider changing for consistency:

-```python3
+```python

59-59: Clarify checkbox enabling description.
The phrase “enables the one of the selected row” is unclear. Consider:

-The package does not perform the action itself: it works with a small amount of *JavaScript* that just disables all checkboxes, enables the one of the selected row, and finally submits the action form, and lets Django handle the logic further.
+The package does not perform the action itself: it uses a small JavaScript helper that disables all checkboxes, enables only the checkbox for the selected row, submits the action form, and lets Django handle the rest.
🧰 Tools
🪛 LanguageTool

[misspelling] ~59-~59: Make sure that ‘the one of’ is correct and that ‘one’ is a pronoun. Possibly, the ‘the’ is unnecessary or ‘of’ is better expressed with a preposition such as ‘about’ or ‘in’.
Context: ...t just disables all checkboxes, enables the one of the selected row, and finally submits t...

(THE_ONE_OF_DT)


61-61: Use direct pronoun and simplify instruction.
For a more conversational tone and brevity:

-If the label(s) and action(s) are the same, one can also work with a list of the names of the actions, like:
+If labels and action names match, you can simply provide a list of action names, for example:
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a4577a and 9860fe6.

📒 Files selected for processing (2)
  • README.md (3 hunks)
  • django_adminlink/admin.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • django_adminlink/admin.py
🧰 Additional context used
🪛 LanguageTool
README.md

[misspelling] ~59-~59: Make sure that ‘the one of’ is correct and that ‘one’ is a pronoun. Possibly, the ‘the’ is unnecessary or ‘of’ is better expressed with a preposition such as ‘about’ or ‘in’.
Context: ...t just disables all checkboxes, enables the one of the selected row, and finally submits t...

(THE_ONE_OF_DT)

⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: build (3.12)
  • GitHub Check: no-makemessages (3.11, nl)
  • GitHub Check: no-makemessages (3.8, nl)
  • GitHub Check: no-makemessages (3.12, nl)
  • GitHub Check: no-makemigrations (3.12)
  • GitHub Check: no-makemigrations (3.11)
  • GitHub Check: no-makemessages (3.9, nl)
  • GitHub Check: no-makemigrations (3.10)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.8)
  • GitHub Check: test (3.12)
  • GitHub Check: no-makemigrations (3.8)
  • GitHub Check: no-makemessages (3.10, nl)
  • GitHub Check: test (3.8)

KommuSoft and others added 4 commits April 26, 2025 15:43
…pwYdpGdEGDvIWyYqFoRM5wCCQyqq1V3

📝 Add docstrings to `feature/parameterize-namespace`
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
README.md (2)

22-34: Installation instructions could use minor grammatical improvements.

The installation instructions are clear but contain some minor grammatical issues.

-You do *not* need to add `'django_adminlink'` to the `INSTALLED_APPS` settings *unless*, you use the `SingleItemActionMixin` or a derived product from it, since then
-you need to make use of the `static/js/single_admin_action.js` file that ships with it. So then the `INSTALLED_APPS` looks like:
+You do *not* need to add `'django_adminlink'` to the `INSTALLED_APPS` settings *unless* you use the `SingleItemActionMixin` or a derived product from it. In that case,
+you need to make use of the `static/js/single_admin_action.js` file that ships with it. Then the `INSTALLED_APPS` looks like:
🧰 Tools
🪛 LanguageTool

[typographical] ~22-~22: It seems that a comma is missing after this introductory phrase.
Context: ...ionMixinor a derived product from it, since then you need to make use of thestatic/js/...

(SINCE_THEN_COMMA)


71-71: Minor grammatical issues in documentation.

There are a few minor grammatical issues that affect readability.

-The package does not perform the action itself: it works with a small amount of *JavaScript* that just disables all checkboxes, enables the one of the selected row, and finally submits the action form, and lets Django handle the logic further.
+The package does not perform the action itself: it works with a small amount of *JavaScript* that just disables all checkboxes, enables only the checkbox of the selected row, and finally submits the action form, letting Django handle the rest of the logic.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~71-~71: Possible missing article found.
Context: ...add a button with the label "delete" as last column. When clicked, that row, and onl...

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~71-~71: Possible missing comma found.
Context: .... When clicked, that row, and only that row is then removed. The package does not ...

(AI_HYDRA_LEO_MISSING_COMMA)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9860fe6 and 2e315e4.

📒 Files selected for processing (5)
  • README.md (3 hunks)
  • django_adminlink/admin.py (3 hunks)
  • django_adminlink/static/js/single_admin_action.js (1 hunks)
  • docs/source/getting_started.rst (1 hunks)
  • docs/source/installation.rst (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/source/getting_started.rst
🚧 Files skipped from review as they are similar to previous changes (1)
  • django_adminlink/static/js/single_admin_action.js
🧰 Additional context used
🧬 Code Graph Analysis (1)
django_adminlink/admin.py (1)
django_adminlink/static/js/single_admin_action.js (2)
  • item (22-22)
  • pk (9-9)
🪛 LanguageTool
README.md

[typographical] ~22-~22: It seems that a comma is missing after this introductory phrase.
Context: ...ionMixinor a derived product from it, since then you need to make use of thestatic/js/...

(SINCE_THEN_COMMA)


[uncategorized] ~71-~71: Possible missing article found.
Context: ...add a button with the label "delete" as last column. When clicked, that row, and onl...

(AI_HYDRA_LEO_MISSING_THE)


[uncategorized] ~71-~71: Possible missing comma found.
Context: .... When clicked, that row, and only that row is then removed. The package does not ...

(AI_HYDRA_LEO_MISSING_COMMA)


[misspelling] ~73-~73: Make sure that ‘the one of’ is correct and that ‘one’ is a pronoun. Possibly, the ‘the’ is unnecessary or ‘of’ is better expressed with a preposition such as ‘about’ or ‘in’.
Context: ...t just disables all checkboxes, enables the one of the selected row, and finally submits t...

(THE_ONE_OF_DT)

🔇 Additional comments (14)
docs/source/installation.rst (1)

11-12: Clear installation requirement documentation.

The documentation clarifies when to add the package to INSTALLED_APPS, which is helpful for users who will use the new SingleItemActionMixin feature.

README.md (4)

10-11: Good introduction to the new single-row actions feature.

This contextual introduction helps users understand the problem that the SingleItemActionMixin solves.


56-59: Clear introduction to the SingleItemActionMixin feature.

This section clearly explains the purpose of the SingleItemActionMixin and how it enhances the Django admin interface.


61-70: Good example usage for dictionary-based button configuration.

The example clearly demonstrates how to configure action buttons using a dictionary mapping labels to action names.


75-84: Good alternative example for list-based button configuration.

The example demonstrates the simplified list approach when action names and button labels are identical.

django_adminlink/admin.py (9)

11-11: Good addition of configurable admin URL namespace.

The admin_url_namespace attribute allows users to customize the URL namespace, making the LinkFieldAdminMixin more flexible when used in projects with custom admin site configurations.


14-18: Excellent docstring addition.

Adding comprehensive docstrings greatly improves code readability and maintainability.


38-42: Informative docstring for the link generation method.

Clear explanation of what happens when the related model is not registered with the admin site.


47-50: Good implementation of dynamic URL namespace.

The implementation correctly uses the new admin_url_namespace attribute to dynamically generate the URL root, rather than hardcoding "admin:".


54-62: Thorough method docstring with clear parameter and return descriptions.

The detailed docstring for the column_render function provides excellent context for future maintainers.


82-101: Well-implemented SingleItemActionMixin with good button rendering logic.

The implementation handles both dictionary and list configurations for action buttons. The button rendering includes all necessary data attributes for the JavaScript to identify the action and object.


103-116: Good implementation of conditional list display extension.

The get_list_display method intelligently adds the action column only when action buttons are defined, avoiding an empty column when not needed.


117-125: Correctly implemented media property for JavaScript inclusion.

The media property correctly includes the JavaScript file using a relative path, which works well with Django's static file handling.


128-129: Convenient admin class combining the mixin with ModelAdmin.

Providing SingleItemActionAdmin as a convenience class is helpful for users who don't need to combine it with other mixins.

@KommuSoft KommuSoft merged commit 6932353 into master Apr 26, 2025
22 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 13, 2025
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.

1 participant