parameters: (self, keg)
docstring: Permanently deletes a keg and ALL drinks.
docstring_summary: Permanently deletes a keg and ALL drinks.
docstring_tokens: Permanently deletes a keg and ALL drinks .
function: def cancel_keg(self, keg):
          """Permanently deletes a keg and ALL drinks."""
          keg_drinks = keg.drinks.all().order_by("id")
  
          if keg_drinks:
              first_drink_id = keg_drinks[0].id
              sessions = set()
              for drink in keg_drinks:
                  sessions.add(drink.session)
                  drink.delete()
              for session in sessions:
                  session.Rebuild()
              self.rebuild_stats(first_drink_id)
          keg.delete()
function_tokens: def cancel_keg ( self , keg ) : keg_drinks = keg . drinks . all ( ) . order_by ( "id" ) if keg_drinks : first_drink_id = keg_drinks [ 0 ] . id sessions = set ( ) for drink in keg_drinks : sessions . add ( drink . session ) drink . delete ( ) for session in sessions : session . Rebuild ( ) self . rebuild_stats ( first_drink_id ) keg . delete ( )