Added django-solo
Added config app Added google analytics integration in config settings
This commit is contained in:
parent
d4397f21b5
commit
93f6ffc571
|
@ -5,6 +5,7 @@ South==0.8.4
|
|||
# Admin
|
||||
django-suit==0.2.6
|
||||
django-reversion==1.8.0
|
||||
django-solo==1.0.4
|
||||
|
||||
# Fixes
|
||||
longerusername==0.4
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
from django.contrib import admin
|
||||
from solo.admin import SingletonModelAdmin
|
||||
from .models import SiteConfiguration, SocialConfiguration
|
||||
|
||||
|
||||
admin.site.register(SiteConfiguration, SingletonModelAdmin)
|
||||
admin.site.register(SocialConfiguration, SingletonModelAdmin)
|
|
@ -0,0 +1,51 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from south.utils import datetime_utils as datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
# Adding model 'SiteConfiguration'
|
||||
db.create_table(u'config_siteconfiguration', (
|
||||
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
('site_name', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)),
|
||||
('maintenance_mode', self.gf('django.db.models.fields.BooleanField')(default=False)),
|
||||
))
|
||||
db.send_create_signal(u'config', ['SiteConfiguration'])
|
||||
|
||||
# Adding model 'SocialConfiguration'
|
||||
db.create_table(u'config_socialconfiguration', (
|
||||
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
('twitter_account', self.gf('django.db.models.fields.CharField')(max_length=64, null=True, blank=True)),
|
||||
('google_analytics', self.gf('django.db.models.fields.CharField')(max_length=16, null=True, blank=True)),
|
||||
))
|
||||
db.send_create_signal(u'config', ['SocialConfiguration'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
# Deleting model 'SiteConfiguration'
|
||||
db.delete_table(u'config_siteconfiguration')
|
||||
|
||||
# Deleting model 'SocialConfiguration'
|
||||
db.delete_table(u'config_socialconfiguration')
|
||||
|
||||
|
||||
models = {
|
||||
u'config.siteconfiguration': {
|
||||
'Meta': {'object_name': 'SiteConfiguration'},
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'maintenance_mode': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'site_name': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'})
|
||||
},
|
||||
u'config.socialconfiguration': {
|
||||
'Meta': {'object_name': 'SocialConfiguration'},
|
||||
'google_analytics': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'blank': 'True'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'twitter_account': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True', 'blank': 'True'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['config']
|
|
@ -0,0 +1,28 @@
|
|||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from solo.models import SingletonModel
|
||||
|
||||
|
||||
class SiteConfiguration(SingletonModel):
|
||||
site_name = models.CharField(max_length=255, null=True, blank=True)
|
||||
maintenance_mode = models.BooleanField(default=False)
|
||||
|
||||
def __unicode__(self):
|
||||
return _("Site Configuration")
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Site Configuration")
|
||||
verbose_name_plural = _("Site Configuration")
|
||||
|
||||
|
||||
class SocialConfiguration(SingletonModel):
|
||||
twitter_account = models.CharField(max_length=64, blank=True, null=True)
|
||||
google_analytics = models.CharField(max_length=16, blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return _("Social Configuration")
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Social Configuration")
|
||||
verbose_name_plural = _("Social Configuration")
|
|
@ -38,6 +38,7 @@ INSTALLED_APPS = (
|
|||
# Admin
|
||||
'suit',
|
||||
'django.contrib.admin',
|
||||
'solo',
|
||||
|
||||
# Django
|
||||
'django.contrib.auth',
|
||||
|
@ -56,6 +57,7 @@ INSTALLED_APPS = (
|
|||
'south',
|
||||
|
||||
# Apps
|
||||
'shelfzilla.apps.config',
|
||||
'shelfzilla.apps.users',
|
||||
'shelfzilla.apps.homepage',
|
||||
'shelfzilla.apps.landing',
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', '{{ social_config.google_analytics }}', '{{ request.get_host }}');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
|
@ -1,4 +1,6 @@
|
|||
{% load i18n %}
|
||||
{% load i18n solo_tags %}
|
||||
{% get_solo 'config.SiteConfiguration' as site_config %}
|
||||
{% get_solo 'config.SocialConfiguration' as social_config %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -78,5 +80,9 @@
|
|||
|
||||
<script src="/static/js/site.js"></script>
|
||||
{% block extra_js %}{% endblock %}
|
||||
|
||||
{% if social_config.google_analytics %}
|
||||
{% include "_includes/google_analytics.html" %}
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
|
|
Reference in New Issue