~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to wlmaps/admin.py

  • Committer: kaputtnik
  • Date: 2019-07-21 08:18:21 UTC
  • mfrom: (542.2.8 move_maps_minimap)
  • Revision ID: kaputtnik-20190721081821-mjqitcya1qdozbqg
Cleanups for wlmaps: minimaps are stored in wlmaps/minimaps; deleting a maps deletes the corresponding files; Implemented the new value 'needs_version_after'

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
from .models import Map
6
6
from django.contrib import admin
7
7
 
 
8
def delete_selected(modeladmin, request, queryset):
 
9
    """Overwritten Django's default action to delete a map.
 
10
 
 
11
    This action uses the delete() method of the map model. This ensures
 
12
    also deleting the corresponding files (.wmf and .png) of a map.
 
13
 
 
14
    """
 
15
    for obj in queryset:
 
16
        obj.delete()
 
17
delete_selected.short_description = 'Delete selected maps'
 
18
 
8
19
 
9
20
class MapAdmin(admin.ModelAdmin):
 
21
    actions = [delete_selected,]
10
22
    list_display = ['name', 'author', 'pub_date']
11
23
    prepopulated_fields = {'slug': ('name',)}
12
24
    search_fields = ['name', 'author']
14
26
    readonly_fields = ('uploader', 'nr_players', 'w', 'h', 'minimap', 'file', 'world_name')
15
27
    fieldsets = (
16
28
        (None, {
17
 
            'fields': (('name', 'author'), 'uploader', 'uploader_comment')
 
29
            'fields': (('name', 'author'), 'uploader', 'uploader_comment', 'wl_version_after')
18
30
        }),
19
31
        ('Map properties', {
20
32
            'classes': ('collapse',),