diff --git a/accounts/migrations/0009_auto__add_field_userprofile_google_analytics_tracking_id.py b/accounts/migrations/0009_auto__add_field_userprofile_google_analytics_tracking_id.py new file mode 100644 index 0000000..4e63e91 --- /dev/null +++ b/accounts/migrations/0009_auto__add_field_userprofile_google_analytics_tracking_id.py @@ -0,0 +1,75 @@ +# -*- 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.google_analytics_tracking_id' + db.add_column('accounts_userprofile', 'google_analytics_tracking_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.google_analytics_tracking_id' + db.delete_column('accounts_userprofile', 'google_analytics_tracking_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'}), + '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 c21f3ee..a5bbe37 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -24,5 +24,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) 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 5a26757..65ae57a 100644 --- a/accounts/templates/account.html +++ b/accounts/templates/account.html @@ -64,6 +64,13 @@ If you have your own Disqus account that you'd like to use for your blog comments, enter your shortname here. +
+ +
+ {{ form.google_analytics_tracking_id }} + If you'd like to track visits to your blog site with Google Analytics, enter your tracking ID here. +
+
diff --git a/accounts/views.py b/accounts/views.py index b35810e..e045021 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -29,6 +29,7 @@ def account(request): 'gittip_username': profile.gittip_username, 'disqus_shortname': profile.disqus_shortname, + 'google_analytics_tracking_id': profile.google_analytics_tracking_id, }) return { diff --git a/blogs/templates/blogs/themes/default/base.html b/blogs/templates/blogs/themes/default/base.html index 5d15519..5141705 100644 --- a/blogs/templates/blogs/themes/default/base.html +++ b/blogs/templates/blogs/themes/default/base.html @@ -78,10 +78,10 @@ {% endblock %} {% block analytics %} - {% if blog_user.username == 'rochacbruno' %} + {% if blog_user.profile.google_analytics_tracking_id %} {% endif %} + {% if blog_user.profile.google_analytics_tracking_id %} + + {% endif %} diff --git a/templates/pro.html b/templates/pro.html index 79aa406..381ac67 100644 --- a/templates/pro.html +++ b/templates/pro.html @@ -31,6 +31,7 @@
  • Exclusive Pro-only theme for your blog. Here's a preview of the first available theme (working on more).
  • GitTip integration ("tip" link on every snipt next to your username, and on your profile). Sample.
  • Ability to use your own Disqus account for comments on your Snipt blog.
  • +
  • Ability to use your own Google Analytics account for tracking visits to your Snipt blog.
  • {% if request.user.profile.is_pro %}

    You're already a Pro. You know that ;)