# 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 *


class PlaceCreate(ProtectedCreateView):
    model = Place
    fields = '__all__'


class PlaceUpdate(ProtectedUpdateView):
    model = Place
    fields = '__all__'


class PlaceDelete(ProtectedDeleteView):
    model = Place
    success_url = reverse_lazy('places')


class PublicationCreate(ProtectedCreateView):
    model = Publication
    fields = '__all__'

    def get_initial(self):
        try:
            self.initial['place'] = Place.objects.get(
                pk=self.request.GET.get('place_id', None))
        except Place.DoesNotExist:
            self.initial['place'] = {}
        return self.initial



# 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 *



class PlaceCreate(ProtectedCreateView):
    model = Place
    fields = '__all__'


class PlaceUpdate(ProtectedUpdateView):
    model = Place
    fields = '__all__'


class PlaceDelete(ProtectedDeleteView):
    model = Place
    success_url = reverse_lazy('places')


class PublicationCreate(ProtectedCreateView):
    model = Publication
    fields = '__all__'

    def get_initial(self):
        try:
            self.initial['place'] = Place.objects.get(
                pk=self.request.GET.get('place_id', None))
        except Place.DoesNotExist:
            self.initial['place'] = {}
        return self.initial



class PublicationUpdate(ProtectedUpdateView):