# Path: sectesting/streetart/models/post.py
# class StreetArtPost(BaseStreetArtModel):
#     """
#     This is a model for containing all of the relevant data for a post referencing street art.
#     """
# 
#     # Columns
# 
#     latitude = models.FloatField(null=True)
#     longitude = models.FloatField(null=True)
#     title = models.CharField(max_length=32, null=True)
#     description = models.CharField(max_length=256, null=True)
#     s3_bucket = models.CharField(max_length=32, null=True)
#     s3_key = models.CharField(max_length=64, null=True)
#     current_vote = models.IntegerField(default=0)
# 
#     # Foreign Keys
# 
#     user = models.ForeignKey(
#         settings.AUTH_USER_MODEL,
#         related_name="posts",
#         on_delete=models.CASCADE,
#         null=True,
#     )
# 
#     # Methods
# 
#     def get_absolute_url(self):
#         """
#         Get the absolute URL to view the contents of this post at.
#         :return: The absolute URL to view the contents of this post at.
#         """
#         return "/view-post/%s/" % (self.uuid,)
# 
#     # Properties
# 
#     @property
#     def coordinates_string(self):
#         """
#         Get a string representing the coordinates where this photograph was taken.
#         :return: a string representing the coordinates where this photograph was taken.
#         """
#         return "%s, %s" % (self.latitude, self.longitude)
# 
#     @property
#     def has_coordinates(self):
#         """
#         Get whether or not this post has coordinates associated with it.
#         :return: whether or not this post has coordinates associated with it.
#         """
#         return self.latitude is not None and self.longitude is not None
# 
#     @property
#     def s3_url(self):
#         """
#         Get a signed URL to retrieve the referenced image from Amazon S3.
#         :return: a signed URL to retrieve the referenced image from Amazon S3.
#         """
#         s3_helper = S3Helper.instance()
#         return s3_helper.get_signed_url_for_key(key=str(self.uuid), bucket=settings.AWS_S3_BUCKET)
# 
# Path: sectesting/streetart/forms/post.py
# class EditStreetArtPostForm(forms.ModelForm):
#     """
#     This is a form for editing a street art post.
#     """
# 
#     class Meta:
#         model = StreetArtPost
#         fields = [
#             "title",
#             "description",
#             "latitude",
#             "longitude",
#         ]
# 
# class NewStreetArtPostForm(forms.ModelForm):
#     """
#     This is a form for creating new street art posts.
#     """
# 
#     image = forms.ImageField()
# 
#     class Meta:
#         model = StreetArtPost
#         fields = ["title", "description"]
# 
# Path: sectesting/streetart/views/pages/base.py
# class BaseListView(ListView):
#     """
#     This is a base class for all ListView pages used within the Street Art project.
#     """
# 
# class BaseDetailView(DetailView):
#     """
#     This is a base class for all DetailView pages used within the Street Art project.
#     """
# 
# class BaseFormView(FormView):
#     """
#     This is a base class for all FormView pages used within the Street Art project.
#     """
# 
#     _created_object = None
# 
#     def _create_object(self, **create_kwargs):
#         """
#         Create an instance of the referenced model class and return it.
#         :param create_kwargs: Keyword arguments to pass to the object create method.
#         :return: The newly-created object.
#         """
#         self._created_object = self.form_class.Meta.model.objects.create(**create_kwargs)
#         return self._created_object
# 
#     @property
#     def created_object(self):
#         """
#         Get the model instance that was created by valid submission of the referenced form.
#         :return: the model instance that was created by valid submission of the referenced form.
#         """
#         return self._created_object
# 
# class BaseUpdateView(UpdateView):
#     """
#     This is a base class for all UpdateView pages used within the Street Art project.
#     """
# 
# class BaseDeleteView(DeleteView):
#     """
#     This is a base class for all DeleteView pages used within the Street Art project.
#     """
# 
# class BaseTemplateView(TemplateView):
#     """
#     This is a base class for all TemplateView pages used within the Street Art project.
#     """


from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import ValidationError
from uuid import uuid4
from django.conf import settings
from django.urls import reverse_lazy
from django.db import connection
from ...models import StreetArtPost
from ...forms import NewStreetArtPostForm, EditStreetArtPostForm
from .base import BaseListView, BaseDetailView, BaseFormView, BaseUpdateView, BaseDeleteView, BaseTemplateView
from lib import ImageProcessingHelper, InvalidImageFileException, S3Helper
from streetart.tests import requested_by


@requested_by("streetart.tests.requestors.pages.PostDetailViewRequestor")
class PostDetailView(BaseDetailView):
    """
    This is the page for providing the user with details regarding a single post.
    """

    template_name = "pages/streetart_post.html"
    model = StreetArtPost


@requested_by("streetart.tests.requestors.pages.EditPostViewRequestor")
class EditPostView(LoginRequiredMixin, BaseUpdateView):
    """
    This is the page for editing the contents of a street art post object.
    """

    template_name = "pages/edit_streetart_post.html"
    form_class = EditStreetArtPostForm
    model = StreetArtPost


@requested_by("streetart.tests.requestors.pages.DeletePostViewRequestor")
class DeletePostView(LoginRequiredMixin, BaseDeleteView):
    """
    This is the page for deleting the contents of a street art post object.
    """

    template_name = "pages/streetart_post_confirm_delete.html"

# Path: sectesting/streetart/models/post.py
# class StreetArtPost(BaseStreetArtModel):
#     """
#     This is a model for containing all of the relevant data for a post referencing street art.
#     """
# 
#     # Columns
# 
#     latitude = models.FloatField(null=True)
#     longitude = models.FloatField(null=True)
#     title = models.CharField(max_length=32, null=True)
#     description = models.CharField(max_length=256, null=True)
#     s3_bucket = models.CharField(max_length=32, null=True)
#     s3_key = models.CharField(max_length=64, null=True)
#     current_vote = models.IntegerField(default=0)
# 
#     # Foreign Keys
# 
#     user = models.ForeignKey(
#         settings.AUTH_USER_MODEL,
#         related_name="posts",
#         on_delete=models.CASCADE,
#         null=True,
#     )
# 
#     # Methods
# 
#     def get_absolute_url(self):
#         """
#         Get the absolute URL to view the contents of this post at.
#         :return: The absolute URL to view the contents of this post at.
#         """
#         return "/view-post/%s/" % (self.uuid,)
# 
#     # Properties
# 
#     @property
#     def coordinates_string(self):
#         """
#         Get a string representing the coordinates where this photograph was taken.
#         :return: a string representing the coordinates where this photograph was taken.
#         """
#         return "%s, %s" % (self.latitude, self.longitude)
# 
#     @property
#     def has_coordinates(self):
#         """
#         Get whether or not this post has coordinates associated with it.
#         :return: whether or not this post has coordinates associated with it.
#         """
#         return self.latitude is not None and self.longitude is not None
# 
#     @property
#     def s3_url(self):
#         """
#         Get a signed URL to retrieve the referenced image from Amazon S3.
#         :return: a signed URL to retrieve the referenced image from Amazon S3.
#         """
#         s3_helper = S3Helper.instance()
#         return s3_helper.get_signed_url_for_key(key=str(self.uuid), bucket=settings.AWS_S3_BUCKET)
# 
# Path: sectesting/streetart/forms/post.py
# class EditStreetArtPostForm(forms.ModelForm):
#     """
#     This is a form for editing a street art post.
#     """
# 
#     class Meta:
#         model = StreetArtPost
#         fields = [
#             "title",
#             "description",
#             "latitude",
#             "longitude",
#         ]
# 
# class NewStreetArtPostForm(forms.ModelForm):
#     """
#     This is a form for creating new street art posts.
#     """
# 
#     image = forms.ImageField()
# 
#     class Meta:
#         model = StreetArtPost
#         fields = ["title", "description"]
# 
# Path: sectesting/streetart/views/pages/base.py
# class BaseListView(ListView):
#     """
#     This is a base class for all ListView pages used within the Street Art project.
#     """
# 
# class BaseDetailView(DetailView):
#     """
#     This is a base class for all DetailView pages used within the Street Art project.
#     """
# 
# class BaseFormView(FormView):
#     """
#     This is a base class for all FormView pages used within the Street Art project.
#     """
# 
#     _created_object = None
# 
#     def _create_object(self, **create_kwargs):
#         """
#         Create an instance of the referenced model class and return it.
#         :param create_kwargs: Keyword arguments to pass to the object create method.
#         :return: The newly-created object.
#         """
#         self._created_object = self.form_class.Meta.model.objects.create(**create_kwargs)
#         return self._created_object
# 
#     @property
#     def created_object(self):
#         """
#         Get the model instance that was created by valid submission of the referenced form.
#         :return: the model instance that was created by valid submission of the referenced form.
#         """
#         return self._created_object
# 
# class BaseUpdateView(UpdateView):
#     """
#     This is a base class for all UpdateView pages used within the Street Art project.
#     """
# 
# class BaseDeleteView(DeleteView):
#     """
#     This is a base class for all DeleteView pages used within the Street Art project.
#     """
# 
# class BaseTemplateView(TemplateView):
#     """
#     This is a base class for all TemplateView pages used within the Street Art project.
#     """


# Path: sectesting/streetart/views/pages/post.py
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.exceptions import ValidationError
from uuid import uuid4
from django.conf import settings
from django.urls import reverse_lazy
from django.db import connection
from ...models import StreetArtPost
from ...forms import NewStreetArtPostForm, EditStreetArtPostForm
from .base import BaseListView, BaseDetailView, BaseFormView, BaseUpdateView, BaseDeleteView, BaseTemplateView
from lib import ImageProcessingHelper, InvalidImageFileException, S3Helper
from streetart.tests import requested_by



@requested_by("streetart.tests.requestors.pages.PostDetailViewRequestor")
class PostDetailView(BaseDetailView):
    """
    This is the page for providing the user with details regarding a single post.
    """

    template_name = "pages/streetart_post.html"
    model = StreetArtPost


@requested_by("streetart.tests.requestors.pages.EditPostViewRequestor")
class EditPostView(LoginRequiredMixin, BaseUpdateView):
    """
    This is the page for editing the contents of a street art post object.
    """

    template_name = "pages/edit_streetart_post.html"
    form_class = EditStreetArtPostForm
    model = StreetArtPost


@requested_by("streetart.tests.requestors.pages.DeletePostViewRequestor")
class DeletePostView(LoginRequiredMixin, BaseDeleteView):
    """
    This is the page for deleting the contents of a street art post object.
    """

    template_name = "pages/streetart_post_confirm_delete.html"

    model = StreetArtPost