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

Enable possibility to use a static file as logo #355

Open
BMourguesFieldbox opened this issue Jan 24, 2024 · 18 comments · May be fixed by #378
Open

Enable possibility to use a static file as logo #355

BMourguesFieldbox opened this issue Jan 24, 2024 · 18 comments · May be fixed by #378
Assignees
Labels
enhancement New feature or request

Comments

@BMourguesFieldbox
Copy link

BMourguesFieldbox commented Jan 24, 2024

In the current version, the logo can be user uploaded.
However, this means that the app has to handle user uploaded documents and serve them.

When building the admin for business client, the logo will most likely be in static files, and I think it could save some complexity to have the possibility to use a CharField that would point to a static file app/logo.png for example.

Then the template would be with a condition

{% if theme.use_static_logo %}}
    ...
    {% static theme.static_logo_path %}}
 {% else %}
     # The current behaviour
 {% endif %}

Wdyt ?

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@fabiocaccamo
Copy link
Owner

@BMourguesFieldbox thank you for this suggestion, it's indeed interesting, I will think more about it.

@FraCata00
Copy link
Contributor

great solution, instead of CharField, i'll be use a FilePathField

from django docs FilePathField
image

@BMourguesFieldbox
Copy link
Author

great solution, instead of CharField, i'll be use a FilePathField

from django docs FilePathField image

Good catch ! Didn't think of it, but sure thanks for the suggestion!

@FraCata00
Copy link
Contributor

FraCata00 commented Mar 18, 2024

great solution, instead of CharField, i'll be use a FilePathField
from django docs FilePathField image

Good catch ! Didn't think of it, but sure thanks for the suggestion!

It's better, because you have more control instead of classic CharField

@fabiocaccamo
Copy link
Owner

@FraCata00 @BMourguesFieldbox to allow users to decide which directory to choose the file from, a conf setting must be added for setting the field path, but this would impact migrations.

@FraCata00
Copy link
Contributor

FraCata00 commented Mar 18, 2024

@fabiocaccamo the users would do a migration command, cause new field features..

@fabiocaccamo
Copy link
Owner

@FraCata00 indeed, but that migration will be added to admin_interface app, and when in the future this app will have new migrations there will be some conflicts.

@FraCata00
Copy link
Contributor

FraCata00 commented Mar 18, 2024

@fabiocaccamo why should there be conflicts?

@fabiocaccamo
Copy link
Owner

@FraCata00 I try to explain you step by step:

  • now this package has 30 migrations
  • if we add this new field it will have 31 migrations
  • you install the package with 31 migrations, you customize the path setting, then you will have to run makemigrations, and as result you will have 32 migrations inside admin_interface package, but the "real" application that you install from pip has only 31 migrations
  • a new feature that relies on migrations gets developed, the app migrations increase to 32, you upgrade the package and migration conflict error! because you already have migration 32.

@FraCata00
Copy link
Contributor

FraCata00 commented Mar 18, 2024

@fabiocaccamo but if you customize the path setting, should not run makemigrations, is a features of FilePathField. We can add a callable to dynamically return the path for the new field, any opinions?

@fabiocaccamo
Copy link
Owner

@FraCata00 should test it very well:

  • add the field
  • set path to a callable that return a value taken from conf settings
  • run make migrations and migrate
  • change the setting value
  • run make migrations and ensure that no new migrations have been created

@FraCata00
Copy link
Contributor

FraCata00 commented Mar 18, 2024

@fabiocaccamo yessir, after work i'll try it okay?
Like the ImageField with a callable upload_to, cannot create every time a new migrations
The FilePathField instead a ImageField, accept an existent file in file system, like a poiinter of file system path

@FraCata00
Copy link
Contributor

@fabiocaccamo I confirm that no new migrations are crreated if the value in settings changed 👍🏻

@fabiocaccamo
Copy link
Owner

fabiocaccamo commented Mar 19, 2024

@FraCata00 good news! (should write a couple of test case anyway)

@FraCata00
Copy link
Contributor

FraCata00 commented Mar 19, 2024

@fabiocaccamo @BMourguesFieldbox I tested personally yesterday evening in my branch to introduce this functionality
Just a little bit of testing it better, and i'll do a PR 👍🏻

N.B.:
The FilePathField allow (in my case with a custom settings conf), to add a path with some file (just use the match key field to match the most use-case image file (like svg, png, jpg, jpeg) and the django admin provide a html widget select to select the static logo (catched by path)

just add a custom def clean() in Theme model and 2 new fields:

  • use_static_logo
  • static_logo_path

@fabiocaccamo
Copy link
Owner

@FraCata00 I would add only a new logo_static field, then if both are defined in the backend, the media will have the priority.

@FraCata00
Copy link
Contributor

@fabiocaccamo oh, maybe is a better solution

FraCata00 added a commit to FraCata00/django-admin-interface that referenced this issue Mar 19, 2024
FraCata00 added a commit to FraCata00/django-admin-interface that referenced this issue Mar 19, 2024
…o render first the static logo (server-uploaded), after the other logo (client-uploaded)

ref to fabiocaccamo#355
@FraCata00 FraCata00 linked a pull request Mar 19, 2024 that will close this issue
3 tasks
@FraCata00
Copy link
Contributor

@fabiocaccamo sorry for the time *I'm in the office tomorrow morning 😆 ), check PR to solve this issue #378

FraCata00 added a commit to FraCata00/django-admin-interface that referenced this issue Apr 15, 2024
FraCata00 added a commit to FraCata00/django-admin-interface that referenced this issue Apr 15, 2024
…o render first the static logo (server-uploaded), after the other logo (client-uploaded)

ref to fabiocaccamo#355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants