def new_message(request, mlist_fqdn): """ Sends a new thread-starting message to the list. TODO: unit tests """ store = get_store(request) mlist = store.get_list(mlist_fqdn) failure = None if request.method == 'POST': form = PostForm(request.POST) if form.is_valid(): today = datetime.date.today() redirect_url = reverse('archives_with_month', kwargs={ "mlist_fqdn": mlist_fqdn, 'year': today.year, 'month': today.month }) redirect_url += "?msg=sent-ok" try: post_to_list(request, mlist, form.cleaned_data['subject'], form.cleaned_data["message"]) except PostingFailed, e: failure = str(e) else: return redirect(redirect_url)
def reply(request, mlist_fqdn, message_id_hash): """ Sends a reply to the list. TODO: unit tests """ if request.method != 'POST': raise SuspiciousOperation form = ReplyForm(request.POST) if not form.is_valid(): return HttpResponse(form.errors.as_text(), content_type="text/plain", status=400) store = get_store(request) mlist = store.get_list(mlist_fqdn) if form.cleaned_data["newthread"]: subject = form.cleaned_data["subject"] headers = {} else: message = store.get_message_by_hash_from_list(mlist.name, message_id_hash) subject = message.subject if not message.subject.lower().startswith("re:"): subject = "Re: %s" % subject headers = {"In-Reply-To": "<%s>" % message.message_id, "References": "<%s>" % message.message_id, } try: post_to_list(request, mlist, subject, form.cleaned_data["message"], headers) except PostingFailed, e: return HttpResponse(str(e), content_type="text/plain", status=500)
def reply(request, mlist_fqdn, message_id_hash): """ Sends a reply to the list. TODO: unit tests """ if request.method != 'POST': raise SuspiciousOperation form = ReplyForm(request.POST) if not form.is_valid(): return HttpResponse(form.errors.as_text(), content_type="text/plain", status=400) store = get_store(request) mlist = store.get_list(mlist_fqdn) if form.cleaned_data["newthread"]: subject = form.cleaned_data["subject"] headers = {} else: message = store.get_message_by_hash_from_list(mlist.name, message_id_hash) subject = message.subject if not message.subject.lower().startswith("re:"): subject = "Re: %s" % subject headers = { "In-Reply-To": "<%s>" % message.message_id, "References": "<%s>" % message.message_id, } try: post_to_list(request, mlist, subject, form.cleaned_data["message"], headers) except PostingFailed, e: return HttpResponse(str(e), content_type="text/plain", status=500)
def new_message(request, mlist_fqdn): """ Sends a new thread-starting message to the list. TODO: unit tests """ store = get_store(request) mlist = store.get_list(mlist_fqdn) failure = None if request.method == 'POST': form = PostForm(request.POST) if form.is_valid(): today = datetime.date.today() redirect_url = reverse( 'archives_with_month', kwargs={ "mlist_fqdn": mlist_fqdn, 'year': today.year, 'month': today.month}) redirect_url += "?msg=sent-ok" try: post_to_list(request, mlist, form.cleaned_data['subject'], form.cleaned_data["message"]) except PostingFailed, e: failure = str(e) else: return redirect(redirect_url)