def trigger_on_off(request, trigger_id):
    """
        enable/disable the status of the trigger then go back home
        :param request: request object
        :param trigger_id: the trigger ID to switch the status to True or False
        :type request: HttpRequest object
        :type trigger_id: int
        :return render
        :rtype HttpResponse
    """
    now = arrow.utcnow().to(settings.TIME_ZONE).format('YYYY-MM-DD HH:mm:ssZZ')
    trigger = get_object_or_404(TriggerService, pk=trigger_id)
    if trigger.status:
        title = 'disabled'
        title_trigger = _('Set this trigger on')
        btn = 'success'
        trigger.status = False
    else:
        title = _('Edit your service')
        title_trigger = _('Set this trigger off')
        btn = 'primary'
        trigger.status = True
        # set the trigger to the current date when the
        # the trigger is back online
        trigger.date_triggered = now
    trigger.save()

    return render(request, 'triggers/trigger_line.html',
                           {'trigger': trigger,
                            'title': title,
                            'title_trigger': title_trigger,
                            'btn': btn,
                            'fire': settings.DJANGO_TH.get('fire', False)
                            }
                  )
def trigger_on_off ( request , trigger_id ) : now = arrow . utcnow ( ) . to ( settings . TIME_ZONE ) . format ( 'YYYY-MM-DD HH:mm:ssZZ' ) trigger = get_object_or_404 ( TriggerService , pk = trigger_id ) if trigger . status : title = 'disabled' title_trigger = _ ( 'Set this trigger on' ) btn = 'success' trigger . status = False else : title = _ ( 'Edit your service' ) title_trigger = _ ( 'Set this trigger off' ) btn = 'primary' trigger . status = True trigger . date_triggered = now trigger . save ( ) return render ( request , 'triggers/trigger_line.html' , { 'trigger' : trigger , 'title' : title , 'title_trigger' : title_trigger , 'btn' : btn , 'fire' : settings . DJANGO_TH . get ( 'fire' , False ) } )
enable/disable the status of the trigger then go back home
        :param request: request object
        :param trigger_id: the trigger ID to switch the status to True or False
        :type request: HttpRequest object
        :type trigger_id: int
        :return render
        :rtype HttpResponse