2015-05-02 18:41:11 +00:00
|
|
|
import datetime
|
2015-05-02 15:00:15 +00:00
|
|
|
|
2015-05-02 17:00:38 +00:00
|
|
|
from django.shortcuts import get_object_or_404, render
|
2015-05-02 18:41:11 +00:00
|
|
|
from django.forms import ModelForm
|
|
|
|
from django.http import HttpResponseRedirect
|
|
|
|
from django.core.urlresolvers import reverse
|
2015-09-08 04:23:32 +00:00
|
|
|
from django.utils.translation import get_language
|
|
|
|
from djangocms_blog.models import Post
|
2016-03-22 00:21:50 +00:00
|
|
|
from django.core.urlresolvers import resolve
|
2016-04-07 05:26:50 +00:00
|
|
|
from django.contrib import messages
|
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
|
2015-05-02 15:42:04 +00:00
|
|
|
|
2016-04-04 01:39:57 +00:00
|
|
|
from .models import Message, Supporter
|
2016-04-07 05:26:50 +00:00
|
|
|
from .forms import ContactUsForm
|
|
|
|
from django.views.generic.edit import FormView
|
|
|
|
|
2015-05-02 15:42:04 +00:00
|
|
|
|
2016-04-07 05:26:50 +00:00
|
|
|
class ContactView(FormView):
|
|
|
|
template_name = 'contact.html'
|
|
|
|
form_class = ContactUsForm
|
|
|
|
success_url = '/digitalglarus/contact/'
|
|
|
|
success_message = _('Message Successfully Sent')
|
|
|
|
|
|
|
|
def form_valid(self, form):
|
|
|
|
form.save()
|
|
|
|
form.send_email()
|
|
|
|
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
|
|
|
return super(ContactView, self).form_valid(form)
|
2015-05-02 20:42:08 +00:00
|
|
|
|
2015-05-02 15:42:04 +00:00
|
|
|
|
2015-05-02 17:00:38 +00:00
|
|
|
def detail(request, message_id):
|
|
|
|
p = get_object_or_404(Message, pk=message_id)
|
|
|
|
|
|
|
|
context = { 'message': p, }
|
2015-06-10 21:34:33 +00:00
|
|
|
return render(request, 'digitalglarus/detail.html', context)
|
2015-05-02 17:00:38 +00:00
|
|
|
|
2015-05-02 20:02:19 +00:00
|
|
|
def about(request):
|
2015-06-10 21:34:33 +00:00
|
|
|
return render(request, 'digitalglarus/about.html')
|
2015-05-02 18:41:11 +00:00
|
|
|
|
2015-09-20 14:37:54 +00:00
|
|
|
#def index(request):
|
|
|
|
# return render(request, 'digitalglarus/index.html')
|
|
|
|
#
|
|
|
|
#def letscowork(request):
|
|
|
|
# return render(request, 'digitalglarus/letscowork.html')
|
|
|
|
|
2015-05-02 15:15:20 +00:00
|
|
|
def index(request):
|
2015-10-01 18:49:56 +00:00
|
|
|
return home(request)
|
2015-09-20 14:37:54 +00:00
|
|
|
|
|
|
|
def home(request):
|
2016-04-04 01:39:57 +00:00
|
|
|
return render(request, 'index.html')
|
2015-05-02 20:42:08 +00:00
|
|
|
|
2015-09-20 14:37:54 +00:00
|
|
|
def letscowork(request):
|
|
|
|
return render(request, 'digitalglarus/letscowork.html')
|
2015-09-16 07:11:39 +00:00
|
|
|
|
2016-04-07 05:26:50 +00:00
|
|
|
# def contact(request):
|
|
|
|
# message = Message(received_date=datetime.datetime.now())
|
|
|
|
# form = MessageForm(request.POST, instance=message)
|
2015-05-13 23:24:40 +00:00
|
|
|
|
2016-04-07 05:26:50 +00:00
|
|
|
# if request.method == 'POST':
|
2015-05-02 18:41:11 +00:00
|
|
|
|
2016-04-07 05:26:50 +00:00
|
|
|
# if form.is_valid():
|
|
|
|
# form.save()
|
|
|
|
# return HttpResponseRedirect(reverse("digitalglarus:contact"))
|
2015-05-02 18:41:11 +00:00
|
|
|
|
2016-04-07 05:26:50 +00:00
|
|
|
# # form = MessageForm()
|
2015-05-02 18:41:11 +00:00
|
|
|
|
2016-04-07 05:26:50 +00:00
|
|
|
# context = {
|
|
|
|
# 'form': form,
|
|
|
|
# }
|
2015-05-02 18:41:11 +00:00
|
|
|
|
2016-04-07 05:26:50 +00:00
|
|
|
# return render(request, 'digitalglarus/contact.html', context)
|
2015-09-08 04:23:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
def blog(request):
|
2015-09-26 19:42:46 +00:00
|
|
|
tags = ["digitalglarus"]
|
2016-04-04 01:39:57 +00:00
|
|
|
posts = Post.objects.filter_by_language(get_language()).filter(tags__name__in=tags)
|
2015-09-08 04:23:32 +00:00
|
|
|
context = {
|
|
|
|
'post_list': posts,
|
|
|
|
}
|
|
|
|
return render(request, 'glarus_blog/post_list.html', context)
|
|
|
|
|
|
|
|
|
|
|
|
def blog_detail(request, slug):
|
2016-04-04 01:39:57 +00:00
|
|
|
post = Post.objects.filter_by_language(get_language()).filter(slug=slug).first()
|
2015-09-08 04:23:32 +00:00
|
|
|
context = {
|
|
|
|
'post': post,
|
|
|
|
}
|
2016-04-04 01:39:57 +00:00
|
|
|
return render(request, 'post_detail.html', context)
|
2016-02-03 13:27:29 +00:00
|
|
|
|
2016-04-07 05:26:50 +00:00
|
|
|
|
2016-04-04 01:39:57 +00:00
|
|
|
def support(request):
|
2016-04-04 02:28:04 +00:00
|
|
|
return render(request, 'support.html')
|
2016-02-03 13:27:29 +00:00
|
|
|
|
2016-04-07 05:26:50 +00:00
|
|
|
|
2016-02-03 13:27:29 +00:00
|
|
|
def supporters(request):
|
|
|
|
context = {
|
|
|
|
'supporters': Supporter.objects.order_by('name')
|
|
|
|
}
|
2016-04-01 10:37:01 +00:00
|
|
|
return render(request, 'supporters.html', context)
|