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
|
2016-04-10 21:12:43 +00:00
|
|
|
from django.core.urlresolvers import reverse_lazy
|
2016-04-12 05:50:15 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2016-04-13 05:31:19 +00:00
|
|
|
from django.views.generic import TemplateView
|
2015-09-08 04:23:32 +00:00
|
|
|
from django.utils.translation import get_language
|
|
|
|
from djangocms_blog.models import Post
|
2016-04-07 05:26:50 +00:00
|
|
|
from django.contrib import messages
|
2016-04-23 17:00:20 +00:00
|
|
|
from django.http import JsonResponse
|
|
|
|
from django.views.generic import View
|
2015-05-02 15:42:04 +00:00
|
|
|
|
2016-04-10 21:12:43 +00:00
|
|
|
from .models import Supporter
|
|
|
|
from utils.forms import ContactUsForm
|
2016-04-07 05:26:50 +00:00
|
|
|
from django.views.generic.edit import FormView
|
2016-04-23 17:00:20 +00:00
|
|
|
from membership.calendar.calendar import BookCalendar
|
|
|
|
from membership.models import Calendar as CalendarModel
|
|
|
|
import json
|
|
|
|
from django.contrib.auth import logout
|
|
|
|
|
|
|
|
class CalendarApi(View):
|
|
|
|
def get(self,request,month,year):
|
|
|
|
calendar = BookCalendar(request.user,requested_month=month).formatmonth(int(year),int(month))
|
|
|
|
ret = {'calendar':calendar,'month':month,'year':year}
|
|
|
|
return JsonResponse(ret)
|
|
|
|
|
|
|
|
def post(self,request):
|
|
|
|
pd = json.loads(request.POST.get('data',''))
|
|
|
|
ret = {'status':'success'}
|
|
|
|
CalendarModel.add_dates(pd,request.user)
|
|
|
|
return JsonResponse(ret)
|
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
|
2016-04-10 21:12:43 +00:00
|
|
|
success_url = reverse_lazy('digitalglarus:contact')
|
2016-04-07 05:26:50 +00:00
|
|
|
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
|
|
|
|
2016-04-13 05:31:19 +00:00
|
|
|
class IndexView(TemplateView):
|
2016-04-16 01:18:29 +00:00
|
|
|
template_name = "digitalglarus/index.html"
|
2016-04-13 05:31:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
class AboutView(TemplateView):
|
2016-04-16 01:18:29 +00:00
|
|
|
template_name = "digitalglarus/about.html"
|
2016-04-13 05:31:19 +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 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
|
|
|
|
2015-09-08 04:23:32 +00:00
|
|
|
|
|
|
|
def blog(request):
|
2015-09-26 19:42:46 +00:00
|
|
|
tags = ["digitalglarus"]
|
2016-06-24 02:32:51 +00:00
|
|
|
posts = Post.objects.filter(tags__name__in=tags, publish=True).translated(get_language())
|
|
|
|
# posts = Post.objects.filter_by_language(get_language()).filter(tags__name__in=tags, publish=True)
|
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-09 06:51:20 +00:00
|
|
|
# post = Post.objects.filter_by_language(get_language()).filter(slug=slug).first()
|
|
|
|
language = 'en-us' # currently nothing is translated to german so we give then en
|
|
|
|
|
|
|
|
post = Post.objects.translated(language, slug=slug).first()
|
2015-09-08 04:23:32 +00:00
|
|
|
context = {
|
|
|
|
'post': post,
|
|
|
|
}
|
2016-04-09 06:51:20 +00:00
|
|
|
return render(request, 'glarus_blog/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)
|
2016-04-23 17:00:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
|