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

    **Attributes**:

        * ``object_id`` - Selected event object
        * ``form`` - EventForm
        * ``template`` - appointment/event/change.html

    **Logic Description**:

        * Update/delete selected event from the event list
          via EventForm & get redirected to the event list
    """
    event = get_object_or_404(Event, pk=object_id)
    form = EventForm(request.user, request.POST or None, instance=event)
    if form.is_valid():
        # Delete event
        if request.POST.get('delete'):
            event_del(request, object_id)
            return HttpResponseRedirect(redirect_url_to_event_list)
        else:
            # Update event
            form.save()
            request.session["msg"] = _(
                '"%s" is updated.') % request.POST['title']
            return HttpResponseRedirect(redirect_url_to_event_list)

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

    **Attributes**:

        * ``form`` - EventForm
        * ``template`` - appointment/event/change.html

    **Logic Description**:

        * Add new event belonging to the logged in user
          via EventForm & get redirected to the event list
    """
    form = EventForm(request.user, request.POST or None)
    # Add event
    if form.is_valid():
        form.save()
        request.session["msg"] = _('"%s" is added') % request.POST['title']
        return HttpResponseRedirect(redirect_url_to_event_list)
    data = {
        'form': form,
        'action': 'add',
    }
    return render_to_response('appointment/event/change.html',
                              data,
                              context_instance=RequestContext(request))
Esempio n. 3
0
def event_change(request, object_id):
    """Update/Delete event for the logged in user

    **Attributes**:

        * ``object_id`` - Selected event object
        * ``form`` - EventForm
        * ``template`` - appointment/event/change.html

    **Logic Description**:

        * Update/delete selected event from the event list
          via EventForm & get redirected to the event list
    """
    event = get_object_or_404(Event, pk=object_id)
    form = EventForm(request.user, request.POST or None, instance=event)
    if form.is_valid():
        # Delete event
        if request.POST.get("delete"):
            event_del(request, object_id)
            return HttpResponseRedirect(redirect_url_to_event_list)
        else:
            # Update event
            form.save()
            request.session["msg"] = _('"%s" is updated.') % request.POST["title"]
            return HttpResponseRedirect(redirect_url_to_event_list)

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

    **Attributes**:

        * ``form`` - EventForm
        * ``template`` - frontend/appointment/event/change.html

    **Logic Description**:

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

    template = 'frontend/appointment/event/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. 5
0
def event_add(request):
    """Add a new event for the logged in user

    **Attributes**:

        * ``form`` - EventForm
        * ``template`` - appointment/event/change.html

    **Logic Description**:

        * Add new event belonging to the logged in user
          via EventForm & get redirected to the event list
    """
    form = EventForm(request.user, request.POST or None)
    # Add event
    if form.is_valid():
        form.save()
        request.session["msg"] = _('"%s" is added') % request.POST["title"]
        return HttpResponseRedirect(redirect_url_to_event_list)
    data = {"form": form, "action": "add"}
    return render_to_response("appointment/event/change.html", data, context_instance=RequestContext(request))
Esempio n. 6
0
def event_change(request, object_id):
    """Update/Delete event for the logged in user

    **Attributes**:

        * ``object_id`` - Selected event object
        * ``form`` - EventForm
        * ``template`` - frontend/appointment/event/change.html

    **Logic Description**:

        * Update/delete selected event from the event list
          via EventForm & get redirected to the event list
    """
    event = get_object_or_404(Event, pk=object_id)

    form = EventForm(request.user, instance=event)
    if request.method == 'POST':
        # Delete event
        if request.POST.get('delete'):
            event_del(request, object_id)
            return HttpResponseRedirect(redirect_url_to_event_list)
        else:
            # Update event
            form = EventForm(request.user, request.POST, instance=event)
            if form.is_valid():
                form.save()
                request.session["msg"] = _('"%s" is updated.') % request.POST['title']
                return HttpResponseRedirect(redirect_url_to_event_list)

    template = 'frontend/appointment/event/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))