From a7d4ba99df094459dc5738e5f4aeacaa1621273c Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Thu, 7 Feb 2013 10:58:26 -0500 Subject: [PATCH] Gauges --- ...o__add_field_userprofile_gauges_site_id.py | 77 +++++++++++++++++++ accounts/models.py | 1 + accounts/templates/account.html | 7 ++ accounts/views.py | 1 + .../blogs/themes/pro-adams/base.html | 53 +------------ templates/analytics.html | 51 ++++++++++++ templates/base.html | 53 +------------ 7 files changed, 139 insertions(+), 104 deletions(-) create mode 100644 accounts/migrations/0011_auto__add_field_userprofile_gauges_site_id.py create mode 100644 templates/analytics.html diff --git a/accounts/migrations/0011_auto__add_field_userprofile_gauges_site_id.py b/accounts/migrations/0011_auto__add_field_userprofile_gauges_site_id.py new file mode 100644 index 0000000..4e5b853 --- /dev/null +++ b/accounts/migrations/0011_auto__add_field_userprofile_gauges_site_id.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'UserProfile.gauges_site_id' + db.add_column('accounts_userprofile', 'gauges_site_id', + self.gf('django.db.models.fields.CharField')(max_length=250, null=True, blank=True), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'UserProfile.gauges_site_id' + db.delete_column('accounts_userprofile', 'gauges_site_id') + + + models = { + 'accounts.userprofile': { + 'Meta': {'object_name': 'UserProfile'}, + 'blog_domain': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}), + 'blog_theme': ('django.db.models.fields.CharField', [], {'default': "'D'", 'max_length': '1'}), + 'blog_title': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}), + 'default_editor': ('django.db.models.fields.CharField', [], {'default': "'C'", 'max_length': '250'}), + 'disqus_shortname': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}), + 'editor_theme': ('django.db.models.fields.CharField', [], {'default': "'default'", 'max_length': '250'}), + 'gauges_site_id': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}), + 'gittip_username': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}), + 'google_analytics_tracking_id': ('django.db.models.fields.CharField', [], {'max_length': '250', 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_pro': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'stripe_id': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'unique': 'True'}) + }, + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + } + } + + complete_apps = ['accounts'] \ No newline at end of file diff --git a/accounts/models.py b/accounts/models.py index 697c338..a6d8431 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -46,5 +46,6 @@ class UserProfile(models.Model): gittip_username = models.CharField(max_length=250, null=True, blank=True) disqus_shortname = models.CharField(max_length=250, null=True, blank=True) google_analytics_tracking_id = models.CharField(max_length=250, null=True, blank=True) + gauges_site_id = models.CharField(max_length=250, null=True, blank=True) User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0]) diff --git a/accounts/templates/account.html b/accounts/templates/account.html index 013191a..b4975af 100644 --- a/accounts/templates/account.html +++ b/accounts/templates/account.html @@ -77,6 +77,13 @@ If you'd like to track visits to your blog site with Google Analytics, enter your tracking ID here. +
+ +
+ {{ form.id_gauges_site_id }} + If you'd like to track visits to your blog site with Gauges, enter your site ID here. +
+
diff --git a/accounts/views.py b/accounts/views.py index 1acb234..9701684 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -31,6 +31,7 @@ def account(request): 'gittip_username': profile.gittip_username, 'disqus_shortname': profile.disqus_shortname, 'google_analytics_tracking_id': profile.google_analytics_tracking_id, + 'gauges_site_id': profile.gauges_site_id, }) return { diff --git a/blogs/templates/blogs/themes/pro-adams/base.html b/blogs/templates/blogs/themes/pro-adams/base.html index 46444c8..8d87db6 100644 --- a/blogs/templates/blogs/themes/pro-adams/base.html +++ b/blogs/templates/blogs/themes/pro-adams/base.html @@ -107,58 +107,7 @@ - {% if not debug %} - - - {% if blog_user.profile.google_analytics_tracking_id %} - - {% endif %} - {% if blog_user.profile.gauges_site_id %} - - {% endif %} - {% endif %} + {% include 'analytics.html' %} diff --git a/templates/analytics.html b/templates/analytics.html new file mode 100644 index 0000000..a7b285f --- /dev/null +++ b/templates/analytics.html @@ -0,0 +1,51 @@ +{% if not debug %} + + + + + {% if blog_user.profile.gauges_site_id %} + + {% endif %} + +{% endif %} diff --git a/templates/base.html b/templates/base.html index 16bc6b1..ea3ed04 100644 --- a/templates/base.html +++ b/templates/base.html @@ -411,58 +411,7 @@ {% endif %} {% endif %} - {% if not debug %} - - - {% if blog_user.profile.google_analytics_tracking_id %} - - {% endif %} - {% if blog_user.profile.gauges_site_id %} - - {% endif %} - {% endif %} + {% include 'analytics.html' %}