-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from Hafnernuss/release/0.5.0
Release 0.5.0
- Loading branch information
Showing
25 changed files
with
362 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,5 +131,6 @@ dmypy.json | |
# user configured: | ||
_build/ | ||
test_files | ||
|
||
cov.xml | ||
static/ | ||
|
||
cov.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.. _api: | ||
|
||
###################### | ||
API | ||
###################### | ||
|
||
.. currentmodule:: dynamic_file.models | ||
|
||
================ | ||
DynamicFile | ||
================ | ||
.. autoclass:: DynamicFile | ||
:members: | ||
:inherited-members: Model | ||
:noindex: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.. _changelog: | ||
|
||
###################### | ||
Changelog | ||
###################### | ||
This document provides an overview about breaking changes and new features. | ||
|
||
|
||
*************************************************** | ||
0.5.0 | ||
*************************************************** | ||
|
||
Changes | ||
**************************************************** | ||
The setting ``DYNAMIC_FILE_UPLOADED_BY_RELATED_NAME`` has been removed. | ||
If you want to know the uploaded files from your ``uploader entity``, use the following: | ||
|
||
.. code-block:: python3 | ||
DynamicFile.objects.filter(uploaded_by=your_entity_id) | ||
Features | ||
**************************************************** | ||
|
||
* If the file is an image, a preview will be shown in the admin (relies on ``mimetypes``) | ||
* Added a field ``display_name`` to provide a human-readable name for dynamic files | ||
* Added some ``base64`` utilities for commonly used tasks | ||
|
||
*************************************************** | ||
0.4.0 | ||
*************************************************** | ||
First useable version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
from django.contrib import admin | ||
|
||
from .models import DynamicFile | ||
from django.utils.safestring import mark_safe | ||
from django.utils.translation import gettext as _ | ||
|
||
|
||
def preview(dynamic_file): | ||
try: | ||
mimetype = dynamic_file.mimetype | ||
if mimetype and 'image' in mimetype: | ||
src = dynamic_file.to_base64_src() | ||
return mark_safe(f'<img src="{src}" width="150" />') | ||
else: | ||
return _('No preview available') | ||
except Exception as e: | ||
return _(f'No preview available: {str(e)}') | ||
|
||
|
||
@admin.register(DynamicFile) | ||
class CourseGroupAdmin(admin.ModelAdmin): | ||
class DynamicFileAdmin(admin.ModelAdmin): | ||
list_display = ['id', 'name'] | ||
readonly_fields = ['preview'] | ||
|
||
def preview(self, instance): | ||
return preview(instance) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
dynamic_file/migrations/0003_alter_dynamicfile_uploaded_by.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 4.1.3 on 2023-07-07 07:34 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
from django.conf import settings | ||
DYNAMIC_FILE_UPLOADED_BY_MODEL = settings.DYNAMIC_FILE_UPLOADED_BY_MODEL | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dynamic_file', '0002_alter_dynamicfile_file'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='dynamicfile', | ||
name='uploaded_by', | ||
field=models.ForeignKey(blank=True, help_text='The owner/uploader of this file', null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=DYNAMIC_FILE_UPLOADED_BY_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='dynamicfile', | ||
name='display_name', | ||
field=models.CharField(blank=True, default='', | ||
help_text='An optional displayable name for this file.', max_length=128), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
from .fields import * # noqa: F401,F403 | ||
from .dynamic_file import * # noqa: F401,F403 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.