Skip to content

Commit bfaa3a7

Browse files
committed
Update mqueue to 0.20.0, add import-export support, and dependencies
- Bump version to 0.20.0 in mqueue/__init__.py - Add ImportExportModelAdmin to MEventAdmin in admin.py for export functionality - Create MEventResource in resources.py to define export fields - Add django-import-export and django-mcpx to install dependencies in setup.py - Delete root __init__.py file
1 parent 621d150 commit bfaa3a7

5 files changed

Lines changed: 30 additions & 6 deletions

File tree

__init__.py

Whitespace-only changes.

mqueue/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.19.0"
1+
__version__ = "0.20.0"
22
default_app_config = "mqueue.apps.MqueueConfig"

mqueue/admin.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,24 @@
77
from django.utils.html import format_html
88
from .models import MEvent
99
from .utils import format_event_class
10-
10+
from import_export.admin import ImportExportModelAdmin
11+
from .resources import MEventResource
1112

1213
def link_to_object(obj: MEvent) -> SafeText:
1314
return format_html( # type: ignore
1415
f'<a href="{obj.url}" target="_blank">{obj.url}</a>'
1516
)
1617

17-
1818
def link_to_object_admin(obj: MEvent) -> SafeText:
1919
return format_html( # type: ignore
2020
f'<a href="{obj.admin_url}" target="_blank">{obj.admin_url}</a>'
2121
)
2222

23-
2423
def event(obj: MEvent) -> SafeText:
2524
return format_html(format_event_class(obj)) # type: ignore
2625

27-
2826
@admin.register(MEvent)
29-
class MEventAdmin(admin.ModelAdmin):
27+
class MEventAdmin(ImportExportModelAdmin):
3028
date_hierarchy = "date_posted"
3129
readonly_fields = ["date_posted", "request"]
3230
list_display: List[Any] = [
@@ -57,6 +55,7 @@ class MEventAdmin(admin.ModelAdmin):
5755
"user",
5856
"content_type",
5957
)
58+
resource_classes = [MEventResource]
6059

6160
class Media:
6261
css = {

mqueue/resources.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from import_export import resources, fields
2+
from .models import MEvent
3+
4+
class MEventResource(resources.ModelResource):
5+
username = fields.Field(attribute='user__username', column_name='username')
6+
7+
class Meta:
8+
model = MEvent
9+
fields = (
10+
'content_type',
11+
'name',
12+
'url',
13+
'admin_url',
14+
'notes',
15+
'date_posted',
16+
'event_class',
17+
'user',
18+
'groups',
19+
'request',
20+
'bucket',
21+
'data',
22+
'scope',
23+
'username'
24+
)

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@
2929
"Programming Language :: Python :: 3.8",
3030
],
3131
zip_safe=False,
32+
install_requires=["django-mcpx", "django-import-export"],
3233
)

0 commit comments

Comments
 (0)