Esempio n. 1
0
def alarm_change(request, object_id):
    """Update/Delete alarm for the logged in user

    **Attributes**:

        * ``object_id`` - Selected alarm object
        * ``form`` - AlarmForm
        * ``template`` - appointment/alarm/change.html

    **Logic Description**:

        * Update/delete selected alarm from the alarm list
          via AlarmForm & get redirected to the alarm list
    """
    alarm = get_object_or_404(Alarm, pk=object_id)

    form = AlarmForm(request.user, request.POST or None, instance=alarm)
    if form.is_valid():
        # Delete alarm
        if request.POST.get('delete'):
            alarm_del(request, object_id)
            return HttpResponseRedirect(redirect_url_to_alarm_list)
        else:
            # Update alarm
            form.save()
            request.session["msg"] = _('"%s" is updated.') % alarm
            return HttpResponseRedirect(redirect_url_to_alarm_list)

    data = {
        'form': form,
        'action': 'update',
    }
    return render_to_response('appointment/alarm/change.html',
                              data,
                              context_instance=RequestContext(request))
Esempio n. 2
0
def alarm_add(request):
    """Add a new alarm for the logged in user

    **Attributes**:

        * ``form`` - AlarmForm
        * ``template`` - appointment/alarm/change.html

    **Logic Description**:

        * Add new alarm belonging to the logged in user
          via AlarmForm & get redirected to the alarm list
    """
    form = AlarmForm(request.user, request.POST or None)
    # Add alarm
    if form.is_valid():
        obj = form.save()
        request.session["msg"] = _('"%s" is added') % obj
        return HttpResponseRedirect(redirect_url_to_alarm_list)

    data = {
        'form': form,
        'action': 'add',
    }
    return render_to_response('appointment/alarm/change.html',
                              data,
                              context_instance=RequestContext(request))
Esempio n. 3
0
def alarm_change(request, object_id):
    """Update/Delete alarm for the logged in user

    **Attributes**:

        * ``object_id`` - Selected alarm object
        * ``form`` - AlarmForm
        * ``template`` - appointment/alarm/change.html

    **Logic Description**:

        * Update/delete selected alarm from the alarm list
          via AlarmForm & get redirected to the alarm list
    """
    alarm = get_object_or_404(Alarm, pk=object_id)

    form = AlarmForm(request.user, request.POST or None, instance=alarm)
    if form.is_valid():
        # Delete alarm
        if request.POST.get("delete"):
            alarm_del(request, object_id)
            return HttpResponseRedirect(redirect_url_to_alarm_list)
        else:
            # Update alarm
            form.save()
            request.session["msg"] = _('"%s" is updated.') % alarm
            return HttpResponseRedirect(redirect_url_to_alarm_list)

    data = {"form": form, "action": "update"}
    return render_to_response("appointment/alarm/change.html", data, context_instance=RequestContext(request))
Esempio n. 4
0
def alarm_add(request):
    """Add a new alarm for the logged in user

    **Attributes**:

        * ``form`` - AlarmForm
        * ``template`` - appointment/alarm/change.html

    **Logic Description**:

        * Add new alarm belonging to the logged in user
          via AlarmForm & get redirected to the alarm list
    """
    form = AlarmForm(request.user, request.POST or None)
    # Add alarm
    if form.is_valid():
        obj = form.save()
        request.session["msg"] = _('"%s" is added') % obj
        return HttpResponseRedirect(redirect_url_to_alarm_list)

    data = {
        'form': form,
        'action': 'add',
    }
    return render_to_response('appointment/alarm/change.html', data, context_instance=RequestContext(request))
Esempio n. 5
0
def alarm_add(request):
    """Add a new alarm for the logged in user

    **Attributes**:

        * ``form`` - AlarmForm
        * ``template`` - frontend/appointment/alarm/change.html

    **Logic Description**:

        * Add new alarm belonging to the logged in user
          via AlarmForm & get redirected to the alarm list
    """
    form = AlarmForm(request.user)
    error_msg = False
    # Add alarm
    if request.method == 'POST':
        form = AlarmForm(request.user, request.POST)
        if form.is_valid():
            obj = form.save()
            request.session["msg"] = _('"%s" is added.') % obj
            return HttpResponseRedirect(redirect_url_to_alarm_list)

    template = 'frontend/appointment/alarm/change.html'
    data = {
        'form': form,
        'action': 'add',
        'error_msg': error_msg,
        'dialer_setting_msg': user_dialer_setting_msg(request.user),
    }
    return render_to_response(template, data,
                              context_instance=RequestContext(request))
Esempio n. 6
0
def alarm_change(request, object_id):
    """Update/Delete alarm for the logged in user

    **Attributes**:

        * ``object_id`` - Selected alarm object
        * ``form`` - AlarmForm
        * ``template`` - frontend/appointment/alarm/change.html

    **Logic Description**:

        * Update/delete selected alarm from the alarm list
          via AlarmForm & get redirected to the alarm list
    """
    alarm = get_object_or_404(Alarm, pk=object_id)

    form = AlarmForm(request.user, instance=alarm)
    if request.method == 'POST':
        # Delete alarm
        if request.POST.get('delete'):
            alarm_del(request, object_id)
            return HttpResponseRedirect(redirect_url_to_alarm_list)
        else:
            # Update alarm
            form = AlarmForm(request.user, request.POST, instance=alarm)
            if form.is_valid():
                form.save()
                request.session["msg"] = _('"%s" is updated.') % alarm
                return HttpResponseRedirect(redirect_url_to_alarm_list)

    template = 'frontend/appointment/alarm/change.html'
    data = {
        'form': form,
        'action': 'update',
        'dialer_setting_msg': user_dialer_setting_msg(request.user),
    }
    return render_to_response(template, data,
                              context_instance=RequestContext(request))