Adding contact options.
This commit is contained in:
parent
6aa37716d6
commit
3229838d0a
13
src/rideshare/templates/rideshare/emails/contact_mail.html
Normal file
13
src/rideshare/templates/rideshare/emails/contact_mail.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
Hello!<br />
|
||||
<br />
|
||||
The following message has been submitted to your rideshare on <a href="{{ rideshare_url }}">{{ rideshare_url }}</a>.<br />
|
||||
<br />
|
||||
<message><br />
|
||||
<br />
|
||||
{{ message }}<br />
|
||||
<br />
|
||||
</message><br />
|
||||
<br />
|
||||
Best regards,<br />
|
||||
<br />
|
||||
The BornHack Teamp
|
13
src/rideshare/templates/rideshare/emails/contact_mail.txt
Normal file
13
src/rideshare/templates/rideshare/emails/contact_mail.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
Hello!
|
||||
|
||||
The following message has been submitted to your rideshare on {{ rideshare_url }}.
|
||||
|
||||
<message>
|
||||
|
||||
{{ message }}
|
||||
|
||||
</message>
|
||||
|
||||
Best regards,
|
||||
|
||||
The BornHack Team
|
|
@ -1,5 +1,6 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load commonmark %}
|
||||
{% load bootstrap3 %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
@ -26,14 +27,32 @@
|
|||
{{ object.description|untrustedcommonmark }}
|
||||
</p>
|
||||
</div>
|
||||
{% if user == object.user %}
|
||||
<div class="panel-footer">
|
||||
<a class="btn btn-success pull-right" href="{% url 'rideshare:contact-confirm' camp_slug=camp.slug pk=object.pk %}">
|
||||
<i class="fas fa-thumbs-up"></i>
|
||||
Contact this rideshare
|
||||
<a class="btn btn-danger pull-right" href="{% url 'rideshare:delete' camp_slug=camp.slug pk=object.pk %}">
|
||||
<i class="fas fa-trash"></i>
|
||||
Delete
|
||||
</a>
|
||||
<a class="btn btn-primary pull-right" href="{% url 'rideshare:update' camp_slug=camp.slug pk=object.pk %}">
|
||||
<i class="fas fa-edit"></i>
|
||||
Edit
|
||||
</a>
|
||||
<span class="clearfix"></span>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="panel-footer">
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form form %}
|
||||
<button type="submit" class="btn btn-success pull-right">
|
||||
<i class="fas fa-envelope"></i>
|
||||
Send
|
||||
</button>
|
||||
<span class="clearfix"></span>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -10,9 +10,13 @@
|
|||
On this page participants of {{ camp.title }} can communicate about ridesharing to and from the festival.
|
||||
</p>
|
||||
|
||||
<a class="btn btn-success" href="{% url 'rideshare:create' camp_slug=camp.slug %}">
|
||||
Create ride
|
||||
<a class="btn btn-success pull-right" href="{% url 'rideshare:create' camp_slug=camp.slug %}">
|
||||
<i class="fas fa-car"></i>
|
||||
Create ride
|
||||
</a>
|
||||
<span class="clearfix"></span>
|
||||
|
||||
<hr />
|
||||
|
||||
<table class="table table-condensed table-striped">
|
||||
<thead>
|
||||
|
|
|
@ -6,7 +6,6 @@ from .views import (
|
|||
RideDetail,
|
||||
RideUpdate,
|
||||
RideDelete,
|
||||
RideContactConfirm,
|
||||
)
|
||||
|
||||
app_name = 'rideshare'
|
||||
|
@ -39,11 +38,6 @@ urlpatterns = [
|
|||
RideDelete.as_view(),
|
||||
name='delete'
|
||||
),
|
||||
path(
|
||||
'confirm/',
|
||||
RideContactConfirm.as_view(),
|
||||
name='contact-confirm'
|
||||
),
|
||||
])
|
||||
)
|
||||
]
|
||||
|
|
|
@ -1,19 +1,31 @@
|
|||
from django.contrib import messages
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.urls import reverse
|
||||
from django.views.generic import (
|
||||
ListView,
|
||||
DetailView,
|
||||
CreateView,
|
||||
UpdateView,
|
||||
DeleteView,
|
||||
TemplateView,
|
||||
FormView
|
||||
)
|
||||
from django.http import HttpResponseRedirect
|
||||
from django import forms
|
||||
|
||||
from camps.mixins import CampViewMixin
|
||||
from utils.email import add_outgoing_email
|
||||
|
||||
from .models import Ride
|
||||
|
||||
|
||||
class ContactRideForm(forms.Form):
|
||||
message = forms.CharField(
|
||||
widget=forms.Textarea(attrs={"placeholder": "Remember to include your contact information!"}),
|
||||
label="Write a message to this rideshare",
|
||||
help_text="ATTENTION!: Pressing send will send an email with the above text. It is up to you to include your contact information so the person receiving the email can contact you.",
|
||||
)
|
||||
|
||||
|
||||
class RideList(LoginRequiredMixin, CampViewMixin, ListView):
|
||||
model = Ride
|
||||
|
||||
|
@ -21,6 +33,32 @@ class RideList(LoginRequiredMixin, CampViewMixin, ListView):
|
|||
class RideDetail(LoginRequiredMixin, CampViewMixin, DetailView):
|
||||
model = Ride
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['form'] = ContactRideForm()
|
||||
return context
|
||||
|
||||
def post(self, request, **kwargs):
|
||||
form = ContactRideForm(request.POST)
|
||||
if form.is_valid():
|
||||
ride = self.get_object()
|
||||
add_outgoing_email(
|
||||
text_template='rideshare/emails/contact_mail.txt',
|
||||
to_recipients=[ride.user.emailaddress_set.get(primary=True).email],
|
||||
formatdict=dict(
|
||||
rideshare_url="https://bornhack.dk{}".format(
|
||||
reverse(
|
||||
'rideshare:detail',
|
||||
kwargs={"camp_slug": self.camp.slug, "pk": ride.pk}
|
||||
)
|
||||
),
|
||||
message=form.cleaned_data['message'],
|
||||
),
|
||||
subject="BornHack rideshare message!",
|
||||
)
|
||||
messages.info(request, "Your message has been sent.")
|
||||
return HttpResponseRedirect(ride.get_absolute_url())
|
||||
|
||||
|
||||
class RideCreate(LoginRequiredMixin, CampViewMixin, CreateView):
|
||||
model = Ride
|
||||
|
@ -42,11 +80,3 @@ class RideUpdate(LoginRequiredMixin, CampViewMixin, UpdateView):
|
|||
|
||||
class RideDelete(LoginRequiredMixin, CampViewMixin, DeleteView):
|
||||
model = Ride
|
||||
|
||||
|
||||
class RideContactConfirm(LoginRequiredMixin, CampViewMixin, DetailView):
|
||||
model = Ride
|
||||
template_name = "rideshare/ride_contact_confirm.html"
|
||||
|
||||
|
||||
# class RideContact(View):
|
||||
|
|
Loading…
Reference in a new issue