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' %}
|
{% extends 'base.html' %}
|
||||||
{% load commonmark %}
|
{% load commonmark %}
|
||||||
|
{% load bootstrap3 %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
@ -26,14 +27,32 @@
|
||||||
{{ object.description|untrustedcommonmark }}
|
{{ object.description|untrustedcommonmark }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
{% if user == object.user %}
|
||||||
<div class="panel-footer">
|
<div class="panel-footer">
|
||||||
<a class="btn btn-success pull-right" href="{% url 'rideshare:contact-confirm' camp_slug=camp.slug pk=object.pk %}">
|
<a class="btn btn-danger pull-right" href="{% url 'rideshare:delete' camp_slug=camp.slug pk=object.pk %}">
|
||||||
<i class="fas fa-thumbs-up"></i>
|
<i class="fas fa-trash"></i>
|
||||||
Contact this rideshare
|
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>
|
</a>
|
||||||
<span class="clearfix"></span>
|
<span class="clearfix"></span>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,13 @@
|
||||||
On this page participants of {{ camp.title }} can communicate about ridesharing to and from the festival.
|
On this page participants of {{ camp.title }} can communicate about ridesharing to and from the festival.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<a class="btn btn-success" href="{% url 'rideshare:create' camp_slug=camp.slug %}">
|
<a class="btn btn-success pull-right" href="{% url 'rideshare:create' camp_slug=camp.slug %}">
|
||||||
|
<i class="fas fa-car"></i>
|
||||||
Create ride
|
Create ride
|
||||||
</a>
|
</a>
|
||||||
|
<span class="clearfix"></span>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
<table class="table table-condensed table-striped">
|
<table class="table table-condensed table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
|
|
|
@ -6,7 +6,6 @@ from .views import (
|
||||||
RideDetail,
|
RideDetail,
|
||||||
RideUpdate,
|
RideUpdate,
|
||||||
RideDelete,
|
RideDelete,
|
||||||
RideContactConfirm,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
app_name = 'rideshare'
|
app_name = 'rideshare'
|
||||||
|
@ -39,11 +38,6 @@ urlpatterns = [
|
||||||
RideDelete.as_view(),
|
RideDelete.as_view(),
|
||||||
name='delete'
|
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.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.urls import reverse
|
||||||
from django.views.generic import (
|
from django.views.generic import (
|
||||||
ListView,
|
ListView,
|
||||||
DetailView,
|
DetailView,
|
||||||
CreateView,
|
CreateView,
|
||||||
UpdateView,
|
UpdateView,
|
||||||
DeleteView,
|
DeleteView,
|
||||||
TemplateView,
|
FormView
|
||||||
)
|
)
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
|
from django import forms
|
||||||
|
|
||||||
from camps.mixins import CampViewMixin
|
from camps.mixins import CampViewMixin
|
||||||
|
from utils.email import add_outgoing_email
|
||||||
|
|
||||||
from .models import Ride
|
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):
|
class RideList(LoginRequiredMixin, CampViewMixin, ListView):
|
||||||
model = Ride
|
model = Ride
|
||||||
|
|
||||||
|
@ -21,6 +33,32 @@ class RideList(LoginRequiredMixin, CampViewMixin, ListView):
|
||||||
class RideDetail(LoginRequiredMixin, CampViewMixin, DetailView):
|
class RideDetail(LoginRequiredMixin, CampViewMixin, DetailView):
|
||||||
model = Ride
|
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):
|
class RideCreate(LoginRequiredMixin, CampViewMixin, CreateView):
|
||||||
model = Ride
|
model = Ride
|
||||||
|
@ -42,11 +80,3 @@ class RideUpdate(LoginRequiredMixin, CampViewMixin, UpdateView):
|
||||||
|
|
||||||
class RideDelete(LoginRequiredMixin, CampViewMixin, DeleteView):
|
class RideDelete(LoginRequiredMixin, CampViewMixin, DeleteView):
|
||||||
model = Ride
|
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