Compare commits

..

2 Commits

Author SHA1 Message Date
j
b24f42689b only show avaiable content 2018-02-21 20:52:47 +05:30
j
57481d4dbe contact form 2018-02-21 20:52:47 +05:30
9 changed files with 87 additions and 7 deletions

View File

@ -145,6 +145,9 @@ MEDIA_ROOT = os.path.join(BASE_DIR, 'data/images')
IMAGE_PREFIX = 'http://studio.camp/images/'
CONTACT_FROM_EMAIL = 'contact@studio.camp'
CONTACT_TO_EMAIL = ['contact@studio.camp']
try:
from local_settings import *
except:

View File

@ -187,3 +187,9 @@ table thead, table tbody, table tfoot {
label, button {
color: #ffffff !important;
}
button {
background: #99999 !important;
}

View File

@ -36,6 +36,8 @@ urlpatterns = [
url(r'directions.html', RedirectView.as_view(url='/directions/')),
url(r'campstudio.html', RedirectView.as_view(url='/directions/')),
url(r'^contact/$', views.contact),
url(r'^texts/index/$', views.section_list, {'section': 'Texts'}, name='texts_list'),
url(r'^events/index/$', views.section_list, {'section': 'Events'}, name='events_list'),
url(r'^projects/index/$', views.section_list, {'section': 'Projects'}, name='projects_list'),
@ -44,8 +46,8 @@ urlpatterns = [
url(r'^texts/(?P<shortname>.+)/$', views.texts, name='texts'),
url(r'^events/(?P<shortname>.+)/$', views.events, name='events'),
url(r'^projects/(?P<shortname>.+)/$', views.projects, name='projects'),
url(r'^works/(?P<shortname>.+)/$', views.works, name='works'),
url(r'^works/$', views.works),
url(r'^works/(?P<shortname>.+)/$', views.works, name='work'),
url(r'^works/$', views.works, name='works'),
url(r'^projects/$', views.projects),
url(r'^events/$', views.events),
url(r'^texts/$', views.texts),

7
content/forms.py Normal file
View File

@ -0,0 +1,7 @@
from django import forms
from django.conf import settings
class ContactForm(forms.Form):
name = forms.CharField(label='Name', required=True)
email = forms.EmailField(label='E-Mail', required=True)
message = forms.CharField(label='Message', widget=forms.Textarea, required=True)

View File

@ -1,3 +1,4 @@
{% load available_content%}
<!doctype html>
<html class="no-js" lang="en">
<head>
@ -21,10 +22,10 @@
<ul class="vertical-menu">
<li><a href="/">HOME</a></li>
<li><a href="/about">ABOUT</a></li>
<li><a href="/projects">PROJECTS</a></li>
<li><a href="/events">EVENTS</a></li>
<li><a href="/works">WORKS</a></li>
<li><a href="/texts">TEXTS</a></li>
{% available_content as sections %}
{% for url, title in sections %}
<li><a href="{Purl}}">{{title}}</a></li>
{% endfor %}
<li><a href="/contact">CONTACT</a></li>
</ul>
</div>

View File

@ -0,0 +1,18 @@
{% extends 'base.html' %}
{% block content %}
<div class="large-8 medium-8 columns special-column">
<div class="index-text">
{% if sent %}
<p>Thanks for getting in touch!</p>
{% else %}
<form method="post">
{% csrf_token %}
{{form}}
<br>
<input type="submit" value="Send Message">
</form>
{% endif %}
</div>
</div>
{% endblock %}

View File

View File

@ -0,0 +1,20 @@
from django import template
from django.urls import reverse
from ..models import Content
register = template.Library()
@register.assignment_tag
def available_content():
sections = []
for type in ['projects', 'events', 'works', 'texts']:
if Content.objects.filter(type__name=type, published=True).exists():
sections.append([
reverse('works'),
type.capitalize()
])
return sections

View File

@ -3,18 +3,21 @@ from __future__ import unicode_literals
from datetime import datetime
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.core.mail import EmailMessage
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db.models import Q
from django.http import HttpResponse, Http404
from django.shortcuts import get_object_or_404, render, redirect
from django.urls import reverse
from django.views.generic.list import ListView
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from photologue.views import GalleryListView
from photologue.models import Photo, Gallery
from .models import Content, ContentContent
from . import forms
ITEMS_PER_PAGE = 30
@ -165,6 +168,26 @@ def page(request, shortname):
raise Http404
return render(request, 'page.html', {'content': content})
def contact(request):
context = {}
if request.method == 'POST':
form = forms.ContactForm(request.POST)
if form.is_valid():
name = form.cleaned_data['name']
email = form.cleaned_data['email']
message = form.cleaned_data['message']
subject = '{} has left a message on studio.camp'.format(name)
from_ = settings.CONTACT_FROM_EMAIL
to = settings.CONTACT_TO_EMAIL
msg = EmailMessage(subject, message, from_, to, reply_to=[email])
msg.send(fail_silently=True)
#msg.send()
context['sent'] = True
else:
form = forms.ContactForm()
context['form'] = form
return render(request, 'contact.html', context)
def limit_content(content, q):
if q: