def create(request): if request.method == 'POST': form = ReminderForm(request.POST) if form.is_valid(): new_reminder = form.save(commit=False) new_reminder.user = request.user new_reminder.save() return HttpResponseRedirect("/dashboard") else: form = ReminderForm() return render_to_response("create.html", locals(), context_instance=RequestContext(request))
def remind(request, bug): if request.method == 'POST': reminderForm = ReminderForm(request.POST, user=request.user) if reminderForm.is_valid(): reminder_text = reminderForm.cleaned_data['text'] reminder_recipients = reminderForm.cleaned_data['recipients'] """ save note """ bugnote = Bugnote(bug=bug, reporter=request.user, text='Reminder to %s: %s' % (', '.join(map(str, reminder_recipients)), reminder_text), scope=reminderForm.cleaned_data['scope']) bugnote.save() """ send reminder """ send_alerts(bug, reminder_recipients, reminder_text) request.user.message_set.create(message=_('Reminder(s) sent')) return HttpResponseRedirect(bug.get_absolute_url()) else: reminderForm = ReminderForm(user=request.user) return direct_to_template(request, 'picket/reminder.html', {'bug': bug, 'reminder_form': reminderForm,})