from django.contrib import admin
from .models import Match
from .models import Tip

def delete_tips(modeladmin, request, queryset):
    for match in queryset:
        tips = Tip.object.filter(match = match)
        for tip in tips:
            tip.score = 0
            tip.scoring_field = ""
            tip.is_score_calculated = False
delete_tips.delete_tips = "Delete calculated scores for tips for these matches"
            
class MatchAdmin(admin.ModelAdmin):
    actions = [make_published]

admin.site.register(Match, MatchAdmin)
admin.site.register(Tip)

from django.contrib import admin
from .models import Match
from .models import Tip

def delete_tips(modeladmin, request, queryset):
    for match in queryset:
        tips = Tip.object.filter(match = match)
        for tip in tips:
            tip.score = 0
            tip.scoring_field = ""
            tip.is_score_calculated = False
delete_tips.delete_tips = "Delete calculated scores for tips for these matches"
            
class MatchAdmin(admin.ModelAdmin):
    actions = [delete_tips]

admin.site.register(Match, MatchAdmin)
admin.site.register(Tip)

Add action to zero out tips for given match
Add action to zero out tips for given match

  from django.contrib import admin
  from .models import Match
  from .models import Tip
  
  def delete_tips(modeladmin, request, queryset):
      for match in queryset:
          tips = Tip.object.filter(match = match)
          for tip in tips:
              tip.score = 0
              tip.scoring_field = ""
              tip.is_score_calculated = False
  delete_tips.delete_tips = "Delete calculated scores for tips for these matches"
              
  class MatchAdmin(admin.ModelAdmin):
-     actions = [make_published]
+     actions = [delete_tips]
  
  admin.site.register(Match, MatchAdmin)
  admin.site.register(Tip)
  
Add action to zero out tips for given match
## Code Before:
from django.contrib import admin
from .models import Match
from .models import Tip

def delete_tips(modeladmin, request, queryset):
    for match in queryset:
        tips = Tip.object.filter(match = match)
        for tip in tips:
            tip.score = 0
            tip.scoring_field = ""
            tip.is_score_calculated = False
delete_tips.delete_tips = "Delete calculated scores for tips for these matches"
            
class MatchAdmin(admin.ModelAdmin):
    actions = [make_published]

admin.site.register(Match, MatchAdmin)
admin.site.register(Tip)

## Instruction:
Add action to zero out tips for given match
## Code After:
from django.contrib import admin
from .models import Match
from .models import Tip

def delete_tips(modeladmin, request, queryset):
    for match in queryset:
        tips = Tip.object.filter(match = match)
        for tip in tips:
            tip.score = 0
            tip.scoring_field = ""
            tip.is_score_calculated = False
delete_tips.delete_tips = "Delete calculated scores for tips for these matches"
            
class MatchAdmin(admin.ModelAdmin):
    actions = [delete_tips]

admin.site.register(Match, MatchAdmin)
admin.site.register(Tip)
