def send_message(request, group_id): ''' Display the form and send a message to all patients who subscribed to the information group. ''' group = get_object_or_404(InfoService, pk = group_id) member_count = str(group.members.count()) if(request.method == "POST"): form = InfoMessageValidationForm(request.POST) if form.is_valid(): create_messages_for_infoservice(group, form.cleaned_data['text']) backurl = reverse('groups_send_message', kwargs= {'group_id': group_id}) nexturl = reverse('web_index') title = _("Message created") message = _("All members of the \"%s\" service" " will get your message.") % group.name new_button_label = _("Send another message") success = True return render_to_response('web/status_message.html', locals(), context_instance = RequestContext(request)) return render_to_response("groups/message_create.html", locals(), context_instance = RequestContext(request))
def send_message(request): ''' Display the form and send a message to all patients waiting for the medicine. Afterwards, the medicine information group is deleted. ''' if request.method == 'POST': form = MedicineMessageValidationForm(request.POST) if form.is_valid(): med_id = form.cleaned_data['medicine'].pk medicine = get_object_or_404(InfoService, pk = med_id) create_messages_for_infoservice(medicine, form.cleaned_data['text']) medicine.delete() backurl = reverse('medicines_send_message') nexturl = reverse('web_index') title = _("Message created") message = _("All patients who were waiting for the medicine " "\"%s\" will be informed. The waiting list" " will also be removed.") % medicine.name new_button_label = _("Send another message") success = True return render_to_response('web/status_message.html', locals(), context_instance = RequestContext(request)) medicines = [] for medicine in InfoService.objects.all().filter(type='medicine'): if medicine.members.count() > 0: medicines.append(medicine) current_hospital = Hospital.get_current_hospital() template_text = MEDICINE_MESSAGE_TEMPLATE template_text = template_text.replace("$hospital", current_hospital.name) return render_to_response('medicine/message_create.html', locals(), context_instance = RequestContext(request))