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

Allow the page title customization from the ModelView #311

Merged
merged 7 commits into from
Oct 12, 2023

Conversation

mrharpo
Copy link
Contributor

@mrharpo mrharpo commented Sep 26, 2023

Page title

Adds title customization.

Usage

Overwrite the title function in your view:

class MyView(BaseView):
    def title(self, request: Request):
        return 'Custom Title'

You can also set a title per request type:

    def title(self, request: Request) -> str:
        if request.state.action == RequestAction.LIST:
            return self.label
        if request.state.action == RequestAction.DETAIL:
            return f'{self.label} - {request.path_params["pk"]}'
        if request.state.action == RequestAction.EDIT:
            return f'{self.label} - Edit {request.path_params["pk"]}'
        if request.state.action == RequestAction.CREATE:
            return f'{self.label} - Create'
        return None

Closes #310

@codecov
Copy link

codecov bot commented Sep 29, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (9a5a604) 100.00% compared to head (72b8124) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #311   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           68        68           
  Lines         5003      5009    +6     
=========================================
+ Hits          5003      5009    +6     
Files Coverage Δ
starlette_admin/base.py 100.00% <100.00%> (ø)
starlette_admin/views.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jowilf jowilf added this to the 0.12.0 milestone Oct 10, 2023
* main:
  Update sqlalchemy-file requirement from <0.6.0,>=0.5.0 to >=0.5.0,<0.7.0 (jowilf#326)
  🎬 Detail actions (jowilf#302)
  [pre-commit.ci] pre-commit autoupdate (jowilf#293)
  Bump fasteners from 0.18 to 0.19 (jowilf#322)
  Update httpx requirement from <0.25.0,>=0.23.3 to >=0.23.3,<0.26.0 (jowilf#314)
  Skip odmantic Test Suite on Python 3.8 Due to Segment Fault and Lack of Maintenance (jowilf#325)
  Bump ruff from 0.0.286 to 0.0.292 (jowilf#323)
  Update mkdocstrings[python] requirement (jowilf#315)
  Update arrow requirement from <1.3.0,>=1.2.3 to >=1.2.3,<1.4.0 (jowilf#316)
  Bump black from 23.7.0 to 23.9.1 (jowilf#317)
  Bump actions/checkout from 3 to 4 (jowilf#318)
  🏓 Datatables options (jowilf#308)
@jowilf jowilf merged commit 855a71c into jowilf:main Oct 12, 2023
9 checks passed
@jowilf
Copy link
Owner

jowilf commented Oct 12, 2023

Thank you for your contribution🎉.

@jowilf jowilf changed the title 📰 Page title Allow the page title customization from the ModelView Nov 1, 2023
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.

Enhancement: Page titles
2 participants