1. Scott Nixon
  2. inbounding

Commits

Scott Nixon  committed 2b97702

Finished adding Help Boxes. Combined the Configuraiton and Refer tabs. Form saves mailchimp config to the database.

  • Participants
  • Parent commits 6fd3100
  • Branches default

Comments (0)

Files changed (12)

File inbounding/dispatch/admin.py

View file
  • Ignore whitespace
 from django.contrib import admin
 
-from models import Action, Refer
+from models import Action, Refer, Template
 
 admin.site.register(Action)
 admin.site.register(Refer)
+admin.site.register(Template)

File inbounding/dispatch/context_processors.py

View file
  • Ignore whitespace
+import socket
+from urllib2 import urlopen, URLError, HTTPError
+
+from django.conf import settings
+from django.template import Library, Node, TemplateSyntaxError
+
+
+def context_settings(request):
+    domain  = settings.DOMAIN    
+    main_css  = settings.MAIN_CSS
+    main_js   = settings.MAIN_JS
+
+    if settings.DEBUG:
+        debug = settings.DEBUG
+    else:
+        debug = False
+
+    return { "domain" : domain, "debug": debug, "main_css": main_css, 
+              "main_js": main_js }

File inbounding/dispatch/forms.py

View file
  • Ignore whitespace
 
 class MailChimpForm(ModelForm):
     class Meta:
-        model = Action#, Refer
+        model = Action
         
     

File inbounding/dispatch/migrations/0009_auto__chg_field_action_template.py

View file
  • Ignore whitespace
+# encoding: 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):
+        
+        # Renaming column for 'Action.template' to match new field type.
+        db.rename_column('dispatch_action', 'template_id', 'template')
+        # Changing field 'Action.template'
+        db.alter_column('dispatch_action', 'template', self.gf('django.db.models.fields.IntegerField')(null=True))
+
+        # Removing index on 'Action', fields ['template']
+        db.delete_index('dispatch_action', ['template_id'])
+
+
+    def backwards(self, orm):
+        
+        # Adding index on 'Action', fields ['template']
+        db.create_index('dispatch_action', ['template_id'])
+
+        # Renaming column for 'Action.template' to match new field type.
+        db.rename_column('dispatch_action', 'template', 'template_id')
+        # Changing field 'Action.template'
+        db.alter_column('dispatch_action', 'template_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['dispatch.Template'], null=True))
+
+
+    models = {
+        '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'})
+        },
+        'dispatch.action': {
+            'Meta': {'object_name': 'Action'},
+            'code': ('django.db.models.fields.TextField', [], {}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'lastmod': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'template': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
+            'tpl_values': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+            'type': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'url': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        },
+        'dispatch.customerprofile': {
+            'Meta': {'object_name': 'CustomerProfile'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'mugshot': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'blank': 'True'}),
+            'privacy': ('django.db.models.fields.CharField', [], {'default': "'registered'", 'max_length': '15'}),
+            'site': ('django.db.models.fields.related.ForeignKey', [], {'default': '1', 'to': "orm['sites.Site']"}),
+            'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'my_profile'", 'unique': 'True', 'to': "orm['auth.User']"})
+        },
+        'dispatch.refer': {
+            'Meta': {'object_name': 'Refer'},
+            'action': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['dispatch.Action']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+        },
+        'dispatch.template': {
+            'Meta': {'object_name': 'Template'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+        },
+        'sites.site': {
+            'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"},
+            'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        }
+    }
+
+    complete_apps = ['dispatch']

File inbounding/dispatch/migrations/0010_auto__add_field_action_published.py

View file
  • Ignore whitespace
+# encoding: 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 'Action.published'
+        db.add_column('dispatch_action', 'published', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False)
+
+
+    def backwards(self, orm):
+        
+        # Deleting field 'Action.published'
+        db.delete_column('dispatch_action', 'published')
+
+
+    models = {
+        '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'})
+        },
+        'dispatch.action': {
+            'Meta': {'object_name': 'Action'},
+            'code': ('django.db.models.fields.TextField', [], {}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'null': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'label': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'lastmod': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'published': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'template': ('django.db.models.fields.IntegerField', [], {'null': 'True'}),
+            'tpl_values': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+            'type': ('django.db.models.fields.CharField', [], {'max_length': '8'}),
+            'url': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        },
+        'dispatch.customerprofile': {
+            'Meta': {'object_name': 'CustomerProfile'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'mugshot': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'blank': 'True'}),
+            'privacy': ('django.db.models.fields.CharField', [], {'default': "'registered'", 'max_length': '15'}),
+            'site': ('django.db.models.fields.related.ForeignKey', [], {'default': '1', 'to': "orm['sites.Site']"}),
+            'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'my_profile'", 'unique': 'True', 'to': "orm['auth.User']"})
+        },
+        'dispatch.refer': {
+            'Meta': {'object_name': 'Refer'},
+            'action': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['dispatch.Action']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+        },
+        'dispatch.template': {
+            'Meta': {'object_name': 'Template'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+        },
+        'sites.site': {
+            'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"},
+            'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        }
+    }
+
+    complete_apps = ['dispatch']

File inbounding/dispatch/models.py

View file
  • Ignore whitespace
 from django.db import models
 from django.contrib.auth.models import User
 from django.contrib.sites.models import Site
+from django.db.models.signals import pre_save
+from django.utils import simplejson as json
 
 from userena.models import UserenaBaseProfile
 
     Templates are preformatted Action Boxes that allow users to
     get up and running quickly
     '''
+
     name = models.CharField(max_length=128)
     
     def __unicode__(self):
         return self.name
 
+def mc_template(data):
+    obj = json.loads(data)
+    print obj['mailchimpkey']
+    print obj['mailchimplistid']
 
 class Action(models.Model):
     ACTION_TYPES = (
     url = models.CharField(max_length=128)
     code = models.TextField()
     type = models.CharField(max_length=8, choices=ACTION_TYPES,)
-    template = models.ForeignKey(Template, null=True)
+    template = models.IntegerField(null=True)
     # Template values will store template specific information in json.
     tpl_values = models.TextField(null=True)
+    published = models.BooleanField(default=0)
     user = models.ForeignKey(User)
     created = models.DateTimeField(auto_now_add=True,null=True)
     lastmod = models.DateTimeField(auto_now=True)
     def __unicode__(self):
         return self.label + " | " + self.user.username + " : " + self.url
 
+"""
+Save signal for sets a pubdate when the users selects publish but 
+does not specify a date.
+"""
+def create_html_from_template(sender, **kwargs):
+    obj = kwargs['instance']
+    if obj.template:
+        # created mailchimp form from json data.
+        print "created via a template"
+
+pre_save.connect(create_html_from_template, sender=Action)
+
+
 
 class Refer(models.Model):
     name = models.CharField(max_length=128)

File inbounding/dispatch/static/css/love.css

View file
  • Ignore whitespace
     color: white;
     text-align: center;
     line-height: 1.1;
-}
+}
+
+
+/* MailChimp styling */
+.modal-footer .close { 
+    margin-top: 0 !important;
+}
+.refer-fieldset { 
+    margin-top: 1.3em; 
+}
+.error {color: red;}
+.helpboxes { 
+    margin-top:1.3em; 
+    padding-left:1.5em;
+}
+.onoff {
+    display: block;
+    width: 94px;
+    height: 27px;
+    overflow: hidden;
+    border-radius: 3px;
+}	
+
+.onoff input[type=checkbox] + label {
+    text-indent: -9999px;
+    display: block;
+    width: 160px;
+    height: 27px;
+    line-height: 27px;
+    background: transparent url(/static/img/onoff.png) no-repeat -56px 0;
+    -webkit-transition: background-position 0.3s ease-in-out;
+    -moz-transition: background-position 0.3s ease-in-out;
+    position: relative;
+    top: -26px;
+}
+
+.onoff input[type=checkbox]:checked + label {
+    -webkit-transition: background-position 0.3s ease-in-out;
+    -moz-transition: background-position 0.3s ease-in-out;
+    background-position: -3px 0;
+}

File inbounding/dispatch/templates/client/mc_form.html

View file
  • Ignore whitespace
+<html>
+<head>
+<title>Signup Form</title>
+</head>
+<body>
+<!-- Begin MailChimp Signup Form -->
+<link href="http://cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css"><style type="text/css">#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }/* Add your own MailChimp form style overrides in your site stylesheet or in this style block. We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */</style>
+<div id="mc_embed_signup"> 
+<form action="http://{{ domain }}/subscribe/0a66cc769c/" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
+{% csrf_token %}
+<label for="mce-EMAIL">Subscribe to our mailing list</label><input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required> 
+<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div></form></div>
+<!--End mc_embed_signup-->
+
+</body>
+</html>

File inbounding/dispatch/templates/mailchimp.html

View file
  • Ignore whitespace
 {% block main %}
 <h2 class="">MailChimp</h2>
 <br>
-<style>
-.error {color: red;}
-</style>
 <script>
 $(document).ready( function () {
   $("#mcconfigform").validate({
     }
   }
 });
+
+  $("#mc-apikey-modal .cancel-btn").click(function () {
+      $("#mc-apikey-modal").modal("hide");
+   });
+
   $("#referlistform").validate({
   rules: {
      referuri0: {
       required: true,
       message: "At least 1 refer domain is required."
+      }
     }
-  }
-});
-
+  });
 
 });
 </script>
     <div class="span12">
       <div class="span12">
 	<ul class="tabs" data-tabs="tabs">
-	  <li class="active"><a href="#mc-config">MailChimp Configuration</a></li>
-	  <li><a href="#refer-list">Referrer List</a></li>
+	  <li class="active"><a href="#mc-config">Configuration</a></li>
+	  <!-- <li><a href="#refer-list">Referrer List</a></li> -->
 	  <li><a href="#preview">Preview</a></li>
 	</ul>
       </div>
 
       <div class="tab-content">
 	<div class="active" id="mc-config">
-	  <form action="#" class="form-stacked" name="mc-config-form" id="mcconfigform">
+	  <form method="POST" class="form-stacked" name="mc-config-form" id="mcconfigform">
 	    <fieldset>
+	      <legend>MailChimp Configuration</legend>
 	      {% csrf_token %}
 	      <div class="alert-message block-message error hide" data-alert>
 		<a class="close" href="#">×</a>
 	    <div class="span6">
 	      <label for='label'>Label</label>
 	      <div class="input">
-		<input name='label' class="span6" type='text' placeholder="Your Action Label" autofocus="autofocus">
+		<input name='label' class="span6" type='text' placeholder="Action Label" autofocus="autofocus">
 	      </div>
 	    </div>
 	    
 	    <div class="span6">
 	      <label for='mailchimp-key'>MailChimp API Key</label>
 	      <div class="input">
-		<input name='mailchimpkey' class="span6" type='text' placeholder="Your MailChimp API Key">
+		<input name='mailchimpkey' class="span6" type='text' placeholder="">
 	      </div>
 	    </div>
-	    <div class="span5">
+	    <div class="span5 helpboxes">
 	      <a class="" data-controls-modal="mc-apikey-modal" data-backdrop="static">Get your API Key.</a>
 
 	      <div id="mc-apikey-modal" class="modal hide">
 		  </p>
 		</div>
 		<div class="modal-footer">
-		  <a href="#" class="btn large secondary">Cancel</a>
+		  <a href="#" class="close btn large secondary">Cancel</a>
 		  <a href="https://us2.admin.mailchimp.com/account/api/" target="_new_window" class="btn large primary">Go to MailChimp</a>
 		</div>
 
 	  </div>
 
 
-	  <div class='clearfix'>
-	    <label for='mailchimp-listid'>MailChimp Unique List ID</label>
+	  <div class='clearfix row'>
+	    <div class="span6">
+	      <label for='mailchimp-listid'>MailChimp Unique List ID</label>
 	      <div class="input">
-		<input name='mailchimplistid' class="span6" type='text' placeholder="Your MailChimp Unique List ID">
+		<input name='mailchimplistid' class="span6" type='text' placeholder="">
 	      </div>
+	    </div>
+
+	    <div class="span5 helpboxes">
+	      <a class="" data-controls-modal="mc-apikey-modal" data-backdrop="static">Get your List ID.</a>
+
+	      <div id="mc-apikey-modal" class="modal hide">
+
+		<div class="modal-header" data-show="false">
+		  <a href="#" class="close">×</a>
+		  <h3>MailChimp List ID Instructions</h3>
+		</div>
+		<div class="modal-body">
+		  <p>
+		    <ol>
+		      <li>Go to MailChimp.com.</li>
+		      <li>Select the Lists menu.</li>
+		      <li>Find "settings" for your list. Click on "list settings and unique id."</li>
+		      <li>Copy the "unique id" at the bottom of the page.</li>
+		    </ol>
+		  </p>
+		</div>
+		<div class="modal-footer">
+		  <a href="#" class="close btn large secondary">Cancel</a>
+		  <a href="https://us2.admin.mailchimp.com/lists/" target="_new_window" class="btn large primary">Go to MailChimp</a>
+		</div>
+
+	      </div>
+
+	    </div>
+
+
 	  </div>
 
-	  <div class='clearfix'>
-	    <label for='url'>Target URL</label>
-	    <div class="input">
-	      <input name='url' type='text' class="span6" placeholder="What is the URL for this Action Box?">
+
+	  <div class="clearfix row">
+	    <div class="span6">
+	      <label for='url'>Target URL</label>
+	      <div class="input">
+		<input name='url' type='text' class="span6" placeholder="What is the URL for this Action Box?">
 	      </div>
-	  </div>
-
-	  <div class='clearfix'>
-	    <label for='action-box'>What type of Action Box?</label>
-	    <div class="input">
-	      <select name="action-box" class="span6">
-		<option value="">Floated Action Box</option>
-		<option value="">Embedded Action Box</option>
-	      </select>
+	    </div>
+	    <div class="span5 helpboxes">
+	      <a href="#" rel="popover" data-content="Put the webpage URL that you would like to display the Action Box. Such as google.com/path/ which will match all urls with 'google.com/path/'." data-original-title="A URL to your content." data-placement="right">What is a Target URL?</a>
 	    </div>
 	  </div>
 
+	  <div class='clearfix row'>
+	    <div class="span6">
+	      <label for='action-box'>What type of Action Box?</label>
+	      <div class="input">
+		<select name="action-box" class="span6">
+		  <option value="2">Floated Action Box</option>
+		  <option value="1">Embedded Action Box</option>
+		</select>
+	      </div>
+	    </div>
+	    <div class="span5 helpboxes">
+	      <a href="#" rel="popover" data-content="A Floated box will is fixed in the bottom right corner of your website. Othewise, you chose the location with Embedded boxes." data-original-title="Floated vs. Embedded." data-placement="right">What is a Action Box?</a>
+	    </div>
+	  </div>
 	</fieldset>
+
+	<fieldset class="refer-fieldset">
+	  <legend>Refer Domains</legend>
+	  <div class="clearfix row">
+	    <div class="span6">
+	      <label for='referuri0'>Refer URI</label>
+	      <div class="input">
+		<input name='referuri0' type='text' class="span6" placeholder="google.com">
+	      </div>
+	    </div>
+	    <div class="span5 helpboxes">
+		<a href="#" rel="popover" data-content="Use the domain name of sites that are sending you visitors. Such as google.com or stumbleupon.com without any trailing information. Do not use google.com/path/." data-original-title="Refer's are domain names. " data-placement="right">What is the Refer?</a>
+	    </div>
+	  </div><!-- end row -->
+	</fieldset>
+
+
+	<div class="actions">
+	  <input name='submit' id="mc_config_button" value="Save MailChimp" type="Submit" class="btn large primary">
+	</div>
+      </form>
+      </div>
+
+<!--
+      <div id="refer-list">
+      <form action="#" class="form-stacked" name="referlistform" id="referlistform">
+	{% csrf_token %}
 	<div class="actions">
 	  <input name='submit' value="Save" type="Submit" class="btn large primary">
 	</div>
       </form>
       </div>
-      <div id="refer-list">
-      <form action="#" class="form-stacked" name="referlistform" id="referlistform">
-	{% csrf_token %}
-	<fieldset>
-	  <div class="row">
-	    <div class="span6">
-	      <label for='referuri0'>Refer URI</label>
-	      <div class="input">
-		<input name='referuri0' type='text' placeholder="google.com" autofocus="autofocus">
-	      </div>
-	    </div>
-	    <div span="span5">
-		<a href="#" rel="popover" data-content="Refer's are domain names. Such as google.com or stumbleupon.com without any trailing information. Do not use google.com/path/." data-original-title="What sites are sending you Visitors?" data-placement="right">What is the Refer?</a>
-		<script>
-		  $(function () {
-		  $("a[rel=popover]")
-                  .popover({
-                  offset: 10,
-		  delayOut: 500
-                  })
-                  .click(function(e) {
-                  e.preventDefault()
-                  })
-		  })
-		</script>
-	    </div>
-	  </div><!-- end row -->
-	</fieldset>
-	<div class="actions">
-	  <input name='submit' value="Save" type="Submit" class="btn large primary">
-	</div>
-      </form>
+-->
+      <div id="preview" class="preview">
+	<iframe src="http://127.0.0.1:8100/subscribe/" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:; height:;" allowTransparency="true"></iframe>
+      </div>
       </div>
 
-      <div id="preview" class="preview">
-	This is the preview.
-      </div>
-      </div>
-
 
     </div>
 
-<style>
-.onoff {
-  display: block;
-  width: 94px;
-  height: 27px;
-  overflow: hidden;
-  border-radius: 3px;
-}	
-
-onoff input[type=checkbox] {
-  display: none;
-}
-
-.onoff input[type=checkbox] + label {
-  text-indent: -9999px;
-  display: block;
-  width: 160px;
-  height: 27px;
-  line-height: 27px;
-  background: transparent url(/static/img/onoff.png) no-repeat -56px 0;
-  -webkit-transition: background-position 0.3s ease-in-out;
-  -moz-transition: background-position 0.3s ease-in-out;
-  position: relative;
-  top: -26px;
-}
-
-.onoff input[type=checkbox]:checked + label {
-  -webkit-transition: background-position 0.3s ease-in-out;
-  -moz-transition: background-position 0.3s ease-in-out;
-  background-position: -3px 0;
-}
-</style>
-
     <div class="span4">
       <h2>Action Status</h2>
 
 
 </div>
 
+<script>
+  $(function () {
+  $("a[rel=popover]")
+  .popover({
+  offset: 10,
+  delayOut: 500
+  })
+  .click(function(e) {
+  e.preventDefault()
+  })
+  })
+</script>
+
 {% endblock %}

File inbounding/dispatch/templates/site-template.html

View file
  • Ignore whitespace
   <title>{% block title %}{% endblock %}</title>
   <link rel="stylesheet" href="{{ STATIC_URL }}css/bootstrap.min.css">
   <link href="{{ STATIC_URL }}css/love.css" rel="stylesheet" type="text/css" media="screen" />
-  <link href="{{ STATIC_URL }}css/on-off-switch.css" rel="stylesheet" type="text/css" media="screen" />
-
   
   <script src="{{ STATIC_URL }}js/jquery-1.6.4.min.js"></script>
   <script src="{{ STATIC_URL }}js/jquery.validate.min.js"></script>
   <script type="text/javascript" src="http://use.typekit.com/onq3hhx.js"></script>
   <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
 
-  <script src="{{ STATIC_URL }}js/iphone-style-checkboxes.js"></script
-
   {% block extrahead %}
   {% endblock %}	
 </head>
     <div class="topbar-inner">
       <div class="container">
         <h3><a href="#">ContextKick</a></h3>
-        <ul class="nav">
-	  <li class="active" style="width:250px;"></li>
+        <ul class="nav" style="float:right;">
+	  {% if request.user.is_authenticated %}
+	  <li><a href="{% url dashboard-url %}">Dashboard</a></li>
+	  {% endif %}
+	  <li>
+            <form class="pull-right" action="http://contextkick.us2.list-manage1.com/subscribe/post?u=e90a2006ccc99ae7bcab745a2&amp;id=0a66cc769c" method="post">
+	      <input type="email" name="EMAIL" placeholder="Get Email Updates" required>
+	      <input type="submit" class="label success" value="Join">
+            </form>
+	  </li>
         </ul>
-        <form class="pull-right" action="http://contextkick.us2.list-manage1.com/subscribe/post?u=e90a2006ccc99ae7bcab745a2&amp;id=0a66cc769c" method="post">
-	  <input type="email" name="EMAIL" placeholder="Get Email Updates" required>
-	  <input type="submit" class="label success" value="Join">
-        </form>
         
       </div>
     </div><!-- /topbar-inner -->

File inbounding/dispatch/urls.py

View file
  • Ignore whitespace
 from django.conf.urls.defaults import patterns, include, url
 
-from dispatch.views import HomeView, Dashboard, MailChimp
+from dispatch.views import HomeView, Dashboard
 from dispatch.models import Action, Refer
 
 urlpatterns = patterns('dispatch.views',
     url(r'^dashboard/$', Dashboard.as_view(), name="dashboard-url"),
-    url(r'^mailchimp/$', MailChimp.as_view(), name="mailchimp-url"),
+    url(r'^mailchimp/$', 'mailchimp', name="mailchimp-url"),
     url(r'^action/(?P<id>\d)/$', 'action_page'),                       
     url(r'^action/$', 'action_page'),                       
     url(r'^capture/$', 'ref_log'), 
     (r'^accounts/', include('userena.urls')),                  
+    url(r'^subscribe/(?P<id>[-\w]+)/$', 'mc_signup'), 
+    url(r'^subscribe/$', 'mc_signup'),                
 )
 
 urlpatterns = urlpatterns + patterns('',

File inbounding/dispatch/views.py

View file
  • Ignore whitespace
 from django.views.generic import ListView, TemplateView 
-from django.views.generic import FormView
+from django.views.generic.edit import ProcessFormView, ModelFormMixin, BaseUpdateView
 from django.shortcuts import render_to_response, get_object_or_404
 from django.http import HttpResponse, Http404, HttpResponseRedirect
 from django.template import RequestContext
 from django.contrib.auth.decorators import login_required
 from django.utils.decorators import method_decorator
 from django.views.generic.create_update import create_object, update_object
+from django.utils import simplejson
+from django.conf import settings
 
 from mailsnake import MailSnake
 
 from models import Refer, Action
-from forms import ActionForm
+from forms import ActionForm, MailChimpForm
 
 
 class HomeView(TemplateView):
     def get_queryset(self, *args, **kwargs):
         return Action.objects.filter(user=self.request.user)
 
-    #@method_decorator(login_required)
+    @method_decorator(login_required)
     def dispatch(self, *args, **kwargs):
         return super(Dashboard, self).dispatch(*args, **kwargs)
 
+def mailchimp(request, id=None):
+    if request.method == 'POST':
+        '''
+        Defaults to only save for the MailChimp template
+        Turn the POST object into json to be stored in the database.
+        '''
+        data = simplejson.dumps(request.POST)
+        obj, created = Action.objects.get_or_create(pk=id,
+                                                    defaults={
+                                                    'label': request.POST['label'], 
+                                                    'url': request.POST['url'],
+                                                    'code': 'code here',
+                                                    'type': request.POST['action-box'],
+                                                    'template': '1',
+                                                    'tpl_values': data,
+                                                    'user': request.user})
+        return HttpResponse("Updated")
+    else:
+        return render_to_response('mailchimp.html', locals(),context_instance=RequestContext(request))
 
+'''
 class MailChimp(TemplateView):
     template_name = "mailchimp.html"
 
+    form_class = MailChimpForm
+
+    def get_form(self, MailChimpForm):
+        form = MailChimpForm()
+        return form
+
+    def get(self, request, *args, **kwargs):
+        context = self.get_context_data(**kwargs)
+        return self.render_to_response(context)
+
+    def post(self, request, *args, **kwargs):
+        print request.POST
+        return self.render_to_response(context)
+'''
+    
+
 @login_required
 def action_page(request, id=None):
     # MUST FIX LOGIC.
     return HttpResponse("Success")
 
 
-def mc_signup(request):
+
+
+def mc_signup(request, id=None):
     '''
     OAuth enhancement: http://apidocs.mailchimp.com/oauth2/
     API Docs: http://apidocs.mailchimp.com/api/rtfm/
 
     Exceptions http://apidocs.mailchimp.com/api/1.3/exceptions.field.php
     '''
-    ck_list_id = mc_list_id = '0a66cc769c'
-    ck_api_key = mc_api_key ='30060673b5472f3674d20c65782422ca-us2'
 
-    ms = MailSnake(mc_api_key)
-    if ms.ping():
-        ms.listSubscribe(id=mc_list_id, email_address='scott@happyherbivore.com')
-    else:
-        pass
+    if request.method == 'POST':
+        post = request.POST
+        ck_list_id = mc_list_id = '0a66cc769c'
+        ck_api_key = mc_api_key ='30060673b5472f3674d20c65782422ca-us2'
+
+        ms = MailSnake(mc_api_key)
+        if ms.ping():
+            ms.listSubscribe(id=mc_list_id, email_address=post['EMAIL'])
+        else:
+            pass
         #schedule task to subscribe
 
-    return HttpResponse("Done with Banannas")
+        return HttpResponse("Done with Banannas")
+    else:
+        return render_to_response('client/mc_form.html', locals(),context_instance=RequestContext(request))