Add baner template

remotes/origin/hasaccess
Ivlev Denis 8 years ago
parent 9d1261d05a
commit 5cf375ae24
  1. 4
      apps/content/models.py
  2. 5
      project/context_processors.py
  3. 1
      project/settings.py
  4. 6
      project/templates/blocks/baner.html
  5. 1
      project/templates/lilcity/index.html

@ -127,7 +127,7 @@ class Baner(models.Model):
verbose_name_plural = 'Банеры'
ordering = ('-created_at',)
def save(*args, **kwargs):
def save(self, *args, **kwargs):
if self.use:
Baner.objects.filter(use=true).update(use=False)
Baner.objects.filter(use=True).update(use=False)
return super().save(*args, **kwargs)

@ -1,5 +1,10 @@
from apps.config.models import Config
from apps.content.models import Baner
def config(request):
return {"config": Config.load()}
def baner(request):
return {'baner': Baner.objects.filter(use=True).first()}

@ -88,6 +88,7 @@ TEMPLATES = [
'OPTIONS': {
'context_processors': [
'project.context_processors.config',
'project.context_processors.baner',
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',

@ -0,0 +1,6 @@
{% if baner %}
<div class="baner" style="background-image: url({{ baner.image.url }});">
<span class="baner__text">{{ baner.text }}</span>
<a href="{{ baner.url }}" class="baner__link">{{ baner.button_text }}</a>
</div>
{% endif %}

@ -55,6 +55,7 @@
</head>
<body>
<div class="outer js-outer">
{% include "templates/blocks/baner.html" %}
{% include "templates/blocks/header.html" %}
<div id="lilcity-vue-app" class="container">
{% block content %}{% endblock content %}

Loading…
Cancel
Save