summaryrefslogtreecommitdiff
path: root/fossee_manim/admin.py
diff options
context:
space:
mode:
Diffstat (limited to 'fossee_manim/admin.py')
-rw-r--r--fossee_manim/admin.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/fossee_manim/admin.py b/fossee_manim/admin.py
index 35bf57b..121c487 100644
--- a/fossee_manim/admin.py
+++ b/fossee_manim/admin.py
@@ -46,5 +46,32 @@ class CategoryAdmin(admin.ModelAdmin):
list_filter = ['name']
+class AnimationAdmin(admin.ModelAdmin):
+ list_display = ['title', 'status', 'contributor']
+ list_filter = ['category']
+ actions = ['download_data']
+
+ def download_data(self, request, queryset):
+ openfile = string_io()
+ response = HttpResponse(content_type='text/csv')
+ response['Content-Disposition'] = 'attachment;\
+ filename=animations_data.csv'
+
+ writer = csv.writer(response)
+ writer.writerow(['title', 'contributor', 'reviewer', 'description',
+ 'status', 'github link', 'category'])
+
+ for q in queryset:
+ writer.writerow([q.title, q.contributor.get_full_name(),
+ q.reviewer.get_full_name(), q.description, q.status, q.github,
+ q.category])
+
+ openfile.seek(0)
+ response.write(openfile.read())
+ return response
+
+ download_data.short_description = "Download data CSV file."
+
admin.site.register(Category, CategoryAdmin)
-admin.site.register(Profile, ProfileAdmin) \ No newline at end of file
+admin.site.register(Profile, ProfileAdmin)
+admin.site.register(Animation, AnimationAdmin) \ No newline at end of file