# Path: breezeminder/models/alerts.py
# class Alert(BaseDocument):
#     message = app.db.StringField(required=True)
#     is_active = app.db.BooleanField(required=True, default=True)
#     start = app.db.DateTimeField(required=True)
#     end = app.db.DateTimeField(required=True)
#     level = app.db.StringField(default='info')
# 
#     meta = {
#         'collection': 'alerts',
#         'queryset_class': AlertQuerySet,
#         'indexes': [
#             ('start', 'end')
#         ]
#     }
# 
#     def disable(self):
#         self.is_active = False
#         self.save()
# 
#     def enable(self):
#         self.is_active = True
#         self.save()


from flask.ext.script import Command, Option
from breezeminder.models.alerts import Alert



class DisableAlert(Command):
    """ Disables a BreezeMinder site alert """

    def get_options(self):
        return [
            Option('--id', dest='id', required=True,
                   help='ID/Primary Key of the alert to disable'),
            Option('--delete', dest='delete', default=False, action='store_true',
                   help='Instead of disabling the alert, permanently delete it')
        ]

    def run(self, **kwargs):
        id = kwargs['id']

        try:

# Path: breezeminder/models/alerts.py
# class Alert(BaseDocument):
#     message = app.db.StringField(required=True)
#     is_active = app.db.BooleanField(required=True, default=True)
#     start = app.db.DateTimeField(required=True)
#     end = app.db.DateTimeField(required=True)
#     level = app.db.StringField(default='info')
# 
#     meta = {
#         'collection': 'alerts',
#         'queryset_class': AlertQuerySet,
#         'indexes': [
#             ('start', 'end')
#         ]
#     }
# 
#     def disable(self):
#         self.is_active = False
#         self.save()
# 
#     def enable(self):
#         self.is_active = True
#         self.save()


# Path: breezeminder/management/commands/disable_alert.py
from flask.ext.script import Command, Option
from breezeminder.models.alerts import Alert




class DisableAlert(Command):
    """ Disables a BreezeMinder site alert """

    def get_options(self):
        return [
            Option('--id', dest='id', required=True,
                   help='ID/Primary Key of the alert to disable'),
            Option('--delete', dest='delete', default=False, action='store_true',
                   help='Instead of disabling the alert, permanently delete it')
        ]

    def run(self, **kwargs):
        id = kwargs['id']

        try:

            alert = Alert.objects.get(id=id)