diff --git a/frontend/admin.py b/frontend/admin.py index 8c38f3f..1b43f8a 100644 --- a/frontend/admin.py +++ b/frontend/admin.py @@ -1,3 +1,8 @@ -from django.contrib import admin +from urlaubsauktion.admin import joker_admin as admin -# Register your models here. +from .models import Inspiration, InspirationRegion, InspirationSponsor, Testimonial + +admin.register(Testimonial) +admin.register(Inspiration) +admin.register(InspirationRegion) +admin.register(InspirationSponsor) \ No newline at end of file diff --git a/frontend/models.py b/frontend/models.py index b306cfe..80aede9 100644 --- a/frontend/models.py +++ b/frontend/models.py @@ -1,8 +1,15 @@ -from django.db import models +from django.contrib.gis.db import models from django.conf import settings from django.core.validators import MaxValueValidator, MinValueValidator +from django.contrib.auth import get_user_model -# Create your models here. +from localauth.models import ImageMixin + +from django_countries.fields import CountryField + +class ClassProperty(property): + def __get__(self, cls, owner): + return self.fget.__get__(None, owner)() class Testimonial(models.Model): name = models.CharField(max_length=128) @@ -14,3 +21,38 @@ class Testimonial(models.Model): ]) language = models.CharField(max_length=12, choices=settings.LANGUAGES) public = models.BooleanField(default=False) + +class InspirationRegion(models.Model): + name = models.CharField(max_length=128) + is_state = models.BooleanField(default=False) + country = CountryField() + + @ClassProperty + @classmethod + def country_set(cls): + return cls.objects.all().values_list("country").distinct() + + def __str__(self): + return self.name + +class InspirationSponsor(ImageMixin): + user = models.ForeignKey(get_user_model(), models.SET_NULL, null=True, blank=True) + name = models.CharField(max_length=128) + + def __str__(self): + return self.name + +class Inspiration(ImageMixin): + title = models.CharField(max_length=256) + region = models.ForeignKey(InspirationRegion, models.PROTECT) + sponsor = models.ForeignKey(InspirationSponsor, models.PROTECT) + content = models.TextField() + destination_name = models.CharField(max_length=128) + destination_coords = models.PointField() + + @property + def user(self): + return self.sponsor.user + + def __str__(self): + return self.title \ No newline at end of file diff --git a/frontend/urls.py b/frontend/urls.py index 14c07c5..07b9e94 100644 --- a/frontend/urls.py +++ b/frontend/urls.py @@ -1,6 +1,6 @@ from django.urls import path, include -from .views import HomeView, DemoTemplateView, ImpressumView, PrivacyNoticeView, TOSView +from .views import HomeView, DemoTemplateView, ImpressumView, PrivacyNoticeView, TOSView, InspirationsView app_name = "frontend" @@ -11,4 +11,5 @@ urlpatterns = [ path('impressum/', ImpressumView.as_view(), name="impressum"), path('privacy/', PrivacyNoticeView.as_view(), name="privacy"), path('tos/', TOSView.as_view(), name="tos"), + path('inspirations/', InspirationsView.as_view(), name="inspirations"), ] \ No newline at end of file diff --git a/frontend/views.py b/frontend/views.py index bfc1b0c..3e164b6 100644 --- a/frontend/views.py +++ b/frontend/views.py @@ -16,4 +16,7 @@ class PrivacyNoticeView(TemplateView): template_name = "frontend/privacy.html" class TOSView(TemplateView): - template_name = "frontend/terms.html" \ No newline at end of file + template_name = "frontend/terms.html" + +class InspirationsView(TemplateView): + template_name = "frontend/inspirations.html" \ No newline at end of file diff --git a/static/frontend/css/inspirations.css b/static/frontend/css/inspirations.css new file mode 100644 index 0000000..0c36be2 --- /dev/null +++ b/static/frontend/css/inspirations.css @@ -0,0 +1,91 @@ +.widget.widget-image { + overflow: hidden; +} + +.widget { + border: none; + box-shadow: 0 2px 0 rgba(0,0,0,.07); + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + margin-bottom: 20px; + position: relative; + background: #fff; + padding: 20px; + display: block; +} + +.widget-image-cover { + margin: -20px; + padding: 100% 20px 20px; + border-radius: 5px; + overflow: hidden; + background: #3C454D; + position: relative; +} + +.widget-image:hover .widget-image-cover img { + max-width: 110%; + min-height: 110%; + margin-left: -5%; + margin-top: -5%; +} + +.widget-image .widget-image-cover img { + transition: all .1s ease-in-out; +} + +.widget-image-cover img { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + min-height: 100%; + max-width: 100%; +} + +.widget-image-info { + position: absolute; + bottom: 0; + left: 0; + right: 0; + background: linear-gradient(to bottom,rgba(0,0,0,0) 0,rgba(0,0,0,.8) 75%); + padding: 20px; + color: #fff; +} + +.widget-image-info h5 { + color: #fff; + margin-top: 0; + margin-bottom: 5px; + font-size: 16px; +} + +.widget-image-info p { + color: rgba(255,255,255,.9); +} + +.row { + margin: 0 -10px; +} + +.row>[class*=col-] { + padding: 0 10px; +} + +.widget-image-user .widget-image-user-image { + border-radius: 36px; + float: left; + width: 36px; + background: #fff; +} + +.widget-image-user .widget-image-user-info { + margin-left: 46px; +} + +.widget-image-user .widget-image-user-image img { + max-width: 100%; + border-radius: 36px; +} \ No newline at end of file diff --git a/static/frontend/images/inspiration.png b/static/frontend/images/inspiration.png new file mode 100644 index 0000000..1c95d82 Binary files /dev/null and b/static/frontend/images/inspiration.png differ diff --git a/templates/frontend/base.html b/templates/frontend/base.html index ff6370f..daf0df6 100644 --- a/templates/frontend/base.html +++ b/templates/frontend/base.html @@ -176,7 +176,7 @@ {% endif %}