Esempio n. 1
0
def edit_schedule(request, id):
    schedule = get_object_or_404(Schedules, id=id)
    # So the temporary plan is to populate this form manually as we come up with a django plan
    initial_data = {
        "setup": schedule.message_type,
        "locations": schedule.extras.recipient_location.split(","),
        "group": schedule.extras.group_ref.split(","),
        "reporter": schedule.extras.expected_reporter.split(","),
        "xforms": schedule.extras.missing_reports.split(","),
        "start_date": schedule.start_date,
        "end_date": schedule.end_date,
        "interval": schedule.recur_interval,
        "week_number": schedule.recur_weeknumber,
        "repeat_day": schedule.recur_day.split(","),
        "hour": schedule.start_time.hour,
        "minutes": schedule.start_time.minute,
        "message": schedule.message,
        "user_type": "live",
    }
    form = ScheduleForm(initial_data)
    if request.method == "POST":
        form = ScheduleForm(request.POST)
        if form.is_valid():
            form.update(id)
            return HttpResponseRedirect(reverse("reminder-schedules"))
    return render_to_response("mtrack/schedule.html", {"form": form}, context_instance=RequestContext(request))
Esempio n. 2
0
def broadcasts(request):
    form = ScheduleForm()

    if request.method == "POST":
        form = ScheduleForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse("reminder-schedules"))
    return render_to_response("mtrack/schedule.html", {"form": form}, context_instance=RequestContext(request))