# Path: wbc/core/views.py
# class ProtectedCreateView(CreateView):
# 
#     @method_decorator(login_required)
#     def dispatch(self, *args, **kwargs):
#         return super(ProtectedCreateView, self).dispatch(*args, **kwargs)
# 
# class ProtectedUpdateView(UpdateView):
# 
#     @method_decorator(login_required)
#     def dispatch(self, *args, **kwargs):
#         return super(ProtectedUpdateView, self).dispatch(*args, **kwargs)
# 
# class ProtectedDeleteView(DeleteView):
# 
#     @method_decorator(login_required)
#     def dispatch(self, *args, **kwargs):
#         return super(ProtectedDeleteView, self).dispatch(*args, **kwargs)
# 
# Path: wbc/region/models.py
# class District(Entity):
#     muncipality = models.ForeignKey(Muncipality, related_name='districts')
# 
#     class Meta:
#         verbose_name = 'Bezirk'
#         verbose_name_plural = 'Bezirke'
# 
# Path: wbc/comments/models.py
# class Comment(Model):
#     place = models.ForeignKey(Place, verbose_name="Ort")
#     author_name = models.CharField(
#         max_length=100, verbose_name="Autorin/Author")
#     author_email = models.CharField(max_length=256, verbose_name="Email")
#     author_url = models.CharField(
#         max_length=256, blank=True, verbose_name="Url")
# 
#     enabled = models.BooleanField(verbose_name="Freigeschaltet")
#     content = models.TextField(verbose_name="Inhalt")
# 
#     @property
#     def gravatar(self):
#         gravatar_url = "http://www.gravatar.com/avatar/" + \
#             hashlib.md5(self.author_email.lower()).hexdigest() + "?"
#         gravatar_url += urlencode({'s': str(32)})
# 
#         return gravatar_url
# 
#     def __str__(self):
#         return str(self.place) + ', ' + self.author_name
# 
#     def __unicode__(self):
#         return unicode(self.__str__())
# 
#     class Meta:
#         ordering = ("created",)
#         verbose_name = "Kommentar"
#         verbose_name_plural = "Kommentare"
# 
# Path: wbc/comments/forms.py
# class CommentForm(ModelForm):
# 
#     class Meta:
#         model = Comment
#         fields = ('author_name','author_email','author_url','content')


import datetime
from django.conf import settings
from django.shortcuts import render, get_object_or_404
from django.core.urlresolvers import reverse, reverse_lazy
from django.contrib.auth.decorators import login_required
from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Rss201rev2Feed
from django.http import HttpResponseRedirect, Http404
from django.db.models import Q
from django.utils.timezone import now
from rest_framework import viewsets
from rest_framework.response import Response
from wbc.core.views import ProtectedCreateView, ProtectedUpdateView, ProtectedDeleteView
from wbc.region.models import District
from wbc.comments.models import Comment
from wbc.comments.forms import CommentForm
from .models import *
from .serializers import *
from .forms import *
            if form.is_valid():
                comment = form.save(commit=False)
                comment.enabled = True
                comment.place = p
                comment.save()

    return render(request, 'process/place.html', {
        'place': p,
        'comments': Comment.objects.filter(place_id=int(pk), enabled=True),
        'process_link': reverse('wbc.process.views.process'),
        'new_publication_link': reverse('publication_create'),
    })


class PublicationFeedMimeType(Rss201rev2Feed):
    mime_type = 'application/xml'


class PublicationFeed(Feed):
    title = settings.FEED_TITLE
    description = settings.FEED_DESCRIPTION
    link = settings.SITE_URL
    feed_url = '/feeds/'
    feed_type = PublicationFeedMimeType

    def get_object(self, request):
        if 'bezirk' in request.GET:
            district = request.GET['bezirk']
            try:
                District.objects.get(name=district)

# Path: wbc/core/views.py
# class ProtectedCreateView(CreateView):
# 
#     @method_decorator(login_required)
#     def dispatch(self, *args, **kwargs):
#         return super(ProtectedCreateView, self).dispatch(*args, **kwargs)
# 
# class ProtectedUpdateView(UpdateView):
# 
#     @method_decorator(login_required)
#     def dispatch(self, *args, **kwargs):
#         return super(ProtectedUpdateView, self).dispatch(*args, **kwargs)
# 
# class ProtectedDeleteView(DeleteView):
# 
#     @method_decorator(login_required)
#     def dispatch(self, *args, **kwargs):
#         return super(ProtectedDeleteView, self).dispatch(*args, **kwargs)
# 
# Path: wbc/region/models.py
# class District(Entity):
#     muncipality = models.ForeignKey(Muncipality, related_name='districts')
# 
#     class Meta:
#         verbose_name = 'Bezirk'
#         verbose_name_plural = 'Bezirke'
# 
# Path: wbc/comments/models.py
# class Comment(Model):
#     place = models.ForeignKey(Place, verbose_name="Ort")
#     author_name = models.CharField(
#         max_length=100, verbose_name="Autorin/Author")
#     author_email = models.CharField(max_length=256, verbose_name="Email")
#     author_url = models.CharField(
#         max_length=256, blank=True, verbose_name="Url")
# 
#     enabled = models.BooleanField(verbose_name="Freigeschaltet")
#     content = models.TextField(verbose_name="Inhalt")
# 
#     @property
#     def gravatar(self):
#         gravatar_url = "http://www.gravatar.com/avatar/" + \
#             hashlib.md5(self.author_email.lower()).hexdigest() + "?"
#         gravatar_url += urlencode({'s': str(32)})
# 
#         return gravatar_url
# 
#     def __str__(self):
#         return str(self.place) + ', ' + self.author_name
# 
#     def __unicode__(self):
#         return unicode(self.__str__())
# 
#     class Meta:
#         ordering = ("created",)
#         verbose_name = "Kommentar"
#         verbose_name_plural = "Kommentare"
# 
# Path: wbc/comments/forms.py
# class CommentForm(ModelForm):
# 
#     class Meta:
#         model = Comment
#         fields = ('author_name','author_email','author_url','content')


# Path: wbc/process/views.py
import datetime
from django.conf import settings
from django.shortcuts import render, get_object_or_404
from django.core.urlresolvers import reverse, reverse_lazy
from django.contrib.auth.decorators import login_required
from django.contrib.syndication.views import Feed
from django.utils.feedgenerator import Rss201rev2Feed
from django.http import HttpResponseRedirect, Http404
from django.db.models import Q
from django.utils.timezone import now
from rest_framework import viewsets
from rest_framework.response import Response
from wbc.core.views import ProtectedCreateView, ProtectedUpdateView, ProtectedDeleteView
from wbc.region.models import District
from wbc.comments.models import Comment
from wbc.comments.forms import CommentForm
from .models import *
from .serializers import *
from .forms import *

            if form.is_valid():
                comment = form.save(commit=False)
                comment.enabled = True
                comment.place = p
                comment.save()

    return render(request, 'process/place.html', {
        'place': p,
        'comments': Comment.objects.filter(place_id=int(pk), enabled=True),
        'process_link': reverse('wbc.process.views.process'),
        'new_publication_link': reverse('publication_create'),
    })


class PublicationFeedMimeType(Rss201rev2Feed):
    mime_type = 'application/xml'


class PublicationFeed(Feed):
    title = settings.FEED_TITLE
    description = settings.FEED_DESCRIPTION
    link = settings.SITE_URL
    feed_url = '/feeds/'
    feed_type = PublicationFeedMimeType

    def get_object(self, request):
        if 'bezirk' in request.GET:
            district = request.GET['bezirk']
            try:
                District.objects.get(name=district)

            except District.DoesNotExist: