<commit_before>from machiavelli.models import *
from django.contrib import admin

class ScenarioAdmin(admin.ModelAdmin):
	list_display = ('title', 'start_year')

class CountryAdmin(admin.ModelAdmin):
	list_display = ('name', 'css_class')

class PlayerAdmin(admin.ModelAdmin):
	list_display = ('user', 'game', 'country', 'done')
	list_filter = ('user', 'game', 'done')
	ordering = ['game']

class UnitAdmin(admin.ModelAdmin):
	list_display = ('__unicode__', 'player')
	ordering = ['player']
	list_filter = ('player',)

class GameAreaAdmin(admin.ModelAdmin):
	list_display = ('game', 'board_area', 'player')
	list_per_page = 73
	ordering = ['board_area']
	list_filter = ('game', 'player')

class SetupAdmin(admin.ModelAdmin):
	list_display = ('scenario', 'country', 'area', 'unit_type')

class OrderAdmin(admin.ModelAdmin):
	list_display = ('player_info', '__unicode__')

	def player_info(self, obj):
		return "%(country)s (%(game)s)" % { 'country': obj.unit.player.country,
											'game': obj.unit.player.game }
	player_info.short_description = 'Player'

class ControlTokenInline(admin.TabularInline):
	model = ControlToken
	extra = 1

class GTokenInline(admin.TabularInline):
	model = GToken
	extra = 1

class AFTokenInline(admin.TabularInline):
	model = AFToken
	extra = 1

class AreaAdmin(admin.ModelAdmin):
	list_display = ('name', 'code', 'is_sea', 'is_coast', 'has_city', 'is_fortified', 'has_port')
	inlines = [ ControlTokenInline,
		GTokenInline,
		AFTokenInline ]

class BaseEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season', 'phase')
	list_filter = ('game', 'year', 'season', 'phase')

class NewUnitEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year')
	list_filter = ('game', 'year')

class DisbandEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season', 'phase')
	list_filter = ('game', 'year', 'season', 'phase')

class OrderEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', 'country', '__unicode__', 'year', 'season')
	list_filter = ('game', 'country', 'year', 'season')

class StandoffEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season')
	list_filter = ('game', 'year', 'season')

class ConversionEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season', 'phase')
	list_filter = ('game', 'year', 'season', 'phase')

class ControlEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year')
	list_filter = ('game', 'year')

class MovementEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season', 'phase')
	list_filter = ('game', 'year', 'season', 'phase')

class UnitEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season', 'phase')
	list_filter = ('game', 'year', 'season', 'phase', 'message')

class GameAdmin(admin.ModelAdmin):
	list_display = ('pk', 'year', 'season', 'phase', 'slots', 'scenario', 'created_by')

class RetreatOrderAdmin(admin.ModelAdmin):
	pass

class LetterAdmin(admin.ModelAdmin):
	ordering = ['-id']
	list_display = ('sender', 'receiver', '__unicode__')

admin.site.register(Scenario, ScenarioAdmin)
admin.site.register(Country, CountryAdmin)
admin.site.register(Game, GameAdmin)<commit_msg>added redraw_map action to admin<commit_after>from machiavelli.models import *
from django.contrib import admin

class ScenarioAdmin(admin.ModelAdmin):
	list_display = ('title', 'start_year')

class CountryAdmin(admin.ModelAdmin):
	list_display = ('name', 'css_class')

class PlayerAdmin(admin.ModelAdmin):
	list_display = ('user', 'game', 'country', 'done')
	list_filter = ('user', 'game', 'done')
	ordering = ['game']

class UnitAdmin(admin.ModelAdmin):
	list_display = ('__unicode__', 'player')
	ordering = ['player']
	list_filter = ('player',)

class GameAreaAdmin(admin.ModelAdmin):
	list_display = ('game', 'board_area', 'player')
	list_per_page = 73
	ordering = ['board_area']
	list_filter = ('game', 'player')

class SetupAdmin(admin.ModelAdmin):
	list_display = ('scenario', 'country', 'area', 'unit_type')

class OrderAdmin(admin.ModelAdmin):
	list_display = ('player_info', '__unicode__')

	def player_info(self, obj):
		return "%(country)s (%(game)s)" % { 'country': obj.unit.player.country,
											'game': obj.unit.player.game }
	player_info.short_description = 'Player'

class ControlTokenInline(admin.TabularInline):
	model = ControlToken
	extra = 1

class GTokenInline(admin.TabularInline):
	model = GToken
	extra = 1

class AFTokenInline(admin.TabularInline):
	model = AFToken
	extra = 1

class AreaAdmin(admin.ModelAdmin):
	list_display = ('name', 'code', 'is_sea', 'is_coast', 'has_city', 'is_fortified', 'has_port')
	inlines = [ ControlTokenInline,
		GTokenInline,
		AFTokenInline ]

class BaseEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season', 'phase')
	list_filter = ('game', 'year', 'season', 'phase')

class NewUnitEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year')
	list_filter = ('game', 'year')

class DisbandEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season', 'phase')
	list_filter = ('game', 'year', 'season', 'phase')

class OrderEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', 'country', '__unicode__', 'year', 'season')
	list_filter = ('game', 'country', 'year', 'season')

class StandoffEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season')
	list_filter = ('game', 'year', 'season')

class ConversionEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season', 'phase')
	list_filter = ('game', 'year', 'season', 'phase')

class ControlEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year')
	list_filter = ('game', 'year')

class MovementEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season', 'phase')
	list_filter = ('game', 'year', 'season', 'phase')

class UnitEventAdmin(admin.ModelAdmin):
	ordering = ['-year']
	list_per_page = 20
	list_display = ('game', '__unicode__', 'year', 'season', 'phase')
	list_filter = ('game', 'year', 'season', 'phase', 'message')

class GameAdmin(admin.ModelAdmin):
	list_display = ('pk', 'year', 'season', 'phase', 'slots', 'scenario', 'created_by')
	actions = ['redraw_map']

	def redraw_map(self, request, queryset):
		for obj in queryset:
			obj.make_map()
	redraw_map.short_description = "Redraw map"

class RetreatOrderAdmin(admin.ModelAdmin):
	pass

class LetterAdmin(admin.ModelAdmin):
	ordering = ['-id']
	list_display = ('sender', 'receiver', '__unicode__')

admin.site.register(Scenario, ScenarioAdmin)
admin.site.register(Country, CountryAdmin)
admin.site.register(Game, GameAdmin)
{'fraction_non_alphanumeric': 0.1758094728391758, 'fraction_numerical': 0.006154669521006155, 'mean_word_length': 6.243217054263566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '470761', 'n_tokens_mistral': 2663, 'n_tokens_neox': 2559, 'n_words': 575}