diff --git a/amadeus/static/js/themes.js b/amadeus/static/js/themes.js
index 505b6c0..53664ef 100644
--- a/amadeus/static/js/themes.js
+++ b/amadeus/static/js/themes.js
@@ -8,6 +8,7 @@ if (window.File && window.FileList && window.FileReader) {
function Init() {
var small = $("#id_small_logo"),
large = $("#id_large_logo"),
+ fav = $("#id_favicon"),
filedrag = $(".filedrag"),
common = $(".common-file-input");
diff --git a/amadeus/templates/base.html b/amadeus/templates/base.html
index 76b85b5..198fd1a 100644
--- a/amadeus/templates/base.html
+++ b/amadeus/templates/base.html
@@ -5,7 +5,7 @@
- {{ title }} | Amadeus
+ {{ title }} | {{ theme.title }}
diff --git a/themes/forms.py b/themes/forms.py
index b299583..5a74c1d 100644
--- a/themes/forms.py
+++ b/themes/forms.py
@@ -5,6 +5,18 @@ from .models import Themes
class BasicElemetsForm(forms.ModelForm):
+ def clean_favicon(self):
+ image = self.cleaned_data.get('favicon', False)
+
+ if image:
+ if hasattr(image, '_size'):
+ if image._size > self.MAX_UPLOAD_SIZE:
+ self._errors['favicon'] = [_("The image is too large. It should have less than 2MB.")]
+
+ return ValueError
+
+ return image
+
def clean_small_logo(self):
image = self.cleaned_data.get('small_logo', False)
@@ -31,7 +43,7 @@ class BasicElemetsForm(forms.ModelForm):
class Meta:
model = Themes
- fields = ['title', 'small_logo', 'large_logo', 'footer_note']
+ fields = ['title', 'favicon', 'small_logo', 'large_logo', 'footer_note']
class CSSStyleForm(forms.ModelForm):
diff --git a/themes/migrations/0004_themes_favicon.py b/themes/migrations/0004_themes_favicon.py
new file mode 100644
index 0000000..4e3255e
--- /dev/null
+++ b/themes/migrations/0004_themes_favicon.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10 on 2017-01-12 20:42
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import themes.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('themes', '0003_auto_20170112_1408'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='themes',
+ name='favicon',
+ field=models.ImageField(blank=True, default='favicon_amadeus.png', upload_to='themes/', validators=[themes.models.validate_img_extension], verbose_name='Favicon'),
+ ),
+ ]
diff --git a/themes/models.py b/themes/models.py
index 896655b..964225e 100644
--- a/themes/models.py
+++ b/themes/models.py
@@ -10,6 +10,7 @@ def validate_img_extension(value):
class Themes(models.Model):
title = models.CharField(_("Title"), max_length = 200, default = "Projeto Amadeus")
+ favicon = models.ImageField(verbose_name = _("Favicon"), blank = True, upload_to = 'themes/', default = 'favicon_amadeus.png', validators = [validate_img_extension])
small_logo = models.ImageField(verbose_name = _("Small Logo"), blank = True, upload_to = 'themes/', default = 'logo_pequena_amadeus.png', validators = [validate_img_extension])
large_logo = models.ImageField(verbose_name = _("Large Logo"), blank = True, upload_to = 'themes/', default = 'logo_grande_amadeus.png', validators = [validate_img_extension])
footer_note = models.TextField(_("Footer Note"), blank = True)
diff --git a/themes/templates/themes/basic_update.html b/themes/templates/themes/basic_update.html
index d7c08a8..9c325d9 100644
--- a/themes/templates/themes/basic_update.html
+++ b/themes/templates/themes/basic_update.html
@@ -19,7 +19,7 @@
{% csrf_token %}
{% for field in form %}
- {% if field.auto_id == 'id_small_logo' or field.auto_id == 'id_large_logo' %}
+ {% if field.auto_id == 'id_small_logo' or field.auto_id == 'id_large_logo' or field.auto_id == 'id_favicon' %}
{% if field.field.required %}
{% else %}
@@ -36,7 +36,20 @@
-
{% trans 'Click or drop files here' %}
+
+ {% trans 'Click or drop files here' %}
+
+ {% trans 'Recommended dimensions' %}:
+
+ {% if field.auto_id == 'id_small_logo' %}
+ 927px x 955px
+ {% trans 'It is recommended to be a white image' %}
+ {% elif field.auto_id == 'id_favicon' %}
+ 927px x 955px
+ {% else %}
+ 1286px x 955px
+ {% endif %}
+