Commits

Scott Nixon committed d7cb664

Updated action and dashboard to support bootstrap but still incomplete. Added flatpages.

Comments (0)

Files changed (10)

inbounding/dispatch/admin.py

 from django.contrib import admin
+from django.contrib.flatpages.admin import FlatPageAdmin, FlatpageForm
+from django.contrib.flatpages.models import FlatPage
 
 from models import Action, Refer, Template
 
 admin.site.register(Action)
 admin.site.register(Refer)
 admin.site.register(Template)
+
+

inbounding/dispatch/forms.py

 
 class ActionForm(ModelForm):
     id = forms.CharField(widget=forms.HiddenInput())
-    label = forms.CharField(widget=forms.TextInput(attrs={'class':'input-text url'}))
-    url = forms.CharField(widget=forms.TextInput(attrs={'class':'input-text url'}))
-    code = forms.CharField(widget=forms.Textarea(attrs={'class':'input-text url'}))
+    label = forms.CharField(widget=forms.TextInput(attrs={'class':'span6'}))
+    url = forms.CharField(widget=forms.TextInput(attrs={'class':'span6'}))
+    code = forms.CharField(widget=forms.Textarea(attrs={'class':'span6'}))
 
     class Meta:
         model = Action
-        exclude = ('created', 'user', 'lastmod')
+        exclude = ('created', 'user', 'lastmod', 'tpl_values', 'template')
         
         #    def __init__(self, user, *args, **kwargs):
         #        self.user = user

inbounding/dispatch/templates/action.html

-{% extends "subpage.html" %}
+{% extends "site-template.html" %}
+
+{% block title %}
+Modify an Action
+{% endblock %}
 
 {% block main %}
-<h1>Modify Actions</h1>
-<br/>
+<div class="container">
 
-<form action="." method="post" class="form">
+  <div class="row">
+    <div class="span12">
+      <h1>Modify Actions</h1>
+    </div>
+  </div>
 
-/ <a href="{% url dashboard-url %}">Dashboard</a> / 
+  <div class="row">
+    <div class="span6">
+      <form action="." method="post" class="form">
 
-  <ul>
-    {% for field in form %}
-    <li>
-      {{ field.label_tag }}
-      {{ field.errors }}                              
-      {{ field }}
-    </li>
-  </ul>
-  {% endfor %}
-  {% csrf_token %}
-  <input type="hidden" name="user" id="id_user" value="{{ request.user.id }}">
-  <p><input class="input-submit" type="submit" value="Save Action" /></p>
-</form>
+	/ <a href="{% url dashboard-url %}">Dashboard</a> / 
 
-<div>
-  <h2>Example Calls to Action</h2>
+	<ul>
+	  {% for field in form %}
+	  <li>
+	    {{ field.label_tag }}
+	    {{ field.errors }}                              
+	    {{ field }}
+	  </li>
 
+	{% endfor %}
+	</ul>
+	{% csrf_token %}
+	<input type="hidden" name="user" id="id_user" value="{{ request.user.id }}">
+	<p><input class="input-submit" type="submit" value="Save Action" /></p>
+      </form>
+    </div>
+  </div>
 
-    <h3>Facebook Like button</h3>
-    <code>
+  <div class="row">
+    <div class="span12">
+      <h2>Example Calls to Action</h2>
+
+
+      <h3>Facebook Like button</h3>
+      <code>
       &lt;div id=&quot;fb-root&quot;&gt;&lt;/div&gt;
 &lt;script&gt;(function(d, s, id) {
   var js, fjs = d.getElementsByTagName(s)[0];
 
 &lt;div class=&quot;fb-like&quot; data-href=&quot;google.com&quot; data-send=&quot;false&quot; data-layout=&quot;button_count&quot; data-width=&quot;150&quot; data-show-faces=&quot;false&quot;&gt;&lt;/div&gt;
 
-    </code>
-    <p>Instructions: Copy all the entire code and replace google.com with your URL.</p>
-    <h3>Twitter Follow Button</h3>
-    <code>
+      </code>
+      <p>Instructions: Copy all the entire code and replace google.com with your URL.</p>
+      <h3>Twitter Follow Button</h3>
+      <code>
       &lt;iframe allowtransparency=&quot;true&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; src=&quot;//platform.twitter.com/widgets/follow_button.html?screen_name=googlecom&quot;
   style=&quot;width:300px; height:20px;&quot;&gt;&lt;/iframe&gt;
 
-    </code>
-    <p>Instructions: Copy and paste into the Code box above change the screen_name=googlecom to your Twitter name.</p>
+      </code>
+      <p>Instructions: Copy and paste into the Code box above change the screen_name=googlecom to your Twitter name.</p>
 
-    <h3>Google Plus button</h3>
-    <code>
+      <h3>Google Plus button</h3>
+      <code>
       &lt;!-- Place this tag where you want the +1 button to render --&gt;
       &lt;g:plusone annotation=&quot;inline&quot; href=&quot;google.com&quot;&gt;&lt;/g:plusone&gt;
 
       var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(po, s);
       })();
       &lt;/script&gt;
-    </code>
-    <p>Instructions: Copy this code and update the href="google.com" with your domain.</p>
+      </code>
+      <p>Instructions: Copy this code and update the href="google.com" with your domain.</p>
 
 
-    <h3>Mail Chimp Subscribe</h3>
-    <code>
-      
-    </code>
-    <p>Instructions: </p>
+      <h3>Mail Chimp Subscribe</h3>
+      <code>
+	
+      </code>
+      <p>Instructions: </p>
 
+    </div>
+  </div>
 
 </div>
 
+</div> <!-- end container -->
 {% endblock %}

inbounding/dispatch/templates/dashboard.html

 {% extends "site-template.html" %}
 
 {% block main %}
-<h2 class="">Your Actions</h2>
-<br>
-<div>
-  <h3 class=""><a href="{% url dispatch.views.action_page %}">+ Add an Action</a></h3>
-  <h3 class=""><a href="{% url mailchimp-url %}">MailChimp</a></h3>
-  <ul class="ul">
-  {% for action in object_list %}
-      <li><a href="{% url dispatch.views.action_page action.id %}">{{ action.label }}</a></li>
-  {% endfor %}
-  </ul>
-</div>
+<div class="container">
+  <p>&nbsp;</p>
+  <div class="row">
+    <div class="span12">
+      <h2 class="">Your Actions</h2>
+    </div>
+  </div>
+  
+  <div class="row">
+    <div class="span6">
+      <h3 class=""><a href="{% url dispatch.views.action_page %}">+ Add an Action</a></h3>
+      <h3 class=""><a href="{% url mailchimp-url %}">MailChimp</a></h3>
+      <ul class="ul">
+	{% for action in object_list %}
+	<li><a href="/action/{{ action.id }}/">{{ action.label }}</a></li>
+	{% endfor %}
+      </ul>
+    </div>
+  </div>
 
-<section>
-  <h1>Getting Started</h1>
+<div class="row">
+  <section>
+    <h1>Getting Started</h1>
 
-  <p>
-<pre class="prettyprint">
+    <p>
+      <pre class="prettyprint">
 &lt;script&gt;
 (function() {
     function async_load(){
         window.addEventListener(&#39;load&#39;, async_load, false);
 })();
 &lt;/script&gt;
-</pre>
-  </p>
+      </pre>
+    </p>
 
-</section>
+  </section>
+</div>
+
+</div><!-- end container -->
 
 {% endblock %}

inbounding/dispatch/templates/mailchimp.html

     },
     referuri0: {
       required: true,
-      url: true,
       message: "At least 1 refer domain is required."
     }
   }

inbounding/dispatch/templates/site-template.html

       {% block main %}
       {% endblock %}
    
- 
+
     <footer class="bottom">
-      <p>2011 ContextKick. | <a href="">Login</a></p>
+      <div class="container">
+	<p>2011 ContextKick. | <a href="/accounts/signin/">Login</a> | <a href="/about/">About</a> | <a href="/jobs/">Jobs</a></p>
+      </div>    
     </footer>
 
 
 
 
+
 </body>
 </html>

inbounding/dispatch/urls.py

 urlpatterns = patterns('dispatch.views',
     url(r'^dashboard/$', Dashboard.as_view(), name="dashboard-url"),
     url(r'^mailchimp/$', 'mailchimp', name="mailchimp-url"),
-    url(r'^action/(?P<id>\d)/$', 'action_page'),                       
+    url(r'^action/(?P<id>\d+)/$', 'action_page', name="action-id-url"),                       
     url(r'^action/$', 'action_page'),                       
     url(r'^capture/$', 'ref_log'), 
     (r'^accounts/', include('userena.urls')),                  

inbounding/dispatch/views.py

     def dispatch(self, *args, **kwargs):
         return super(Dashboard, self).dispatch(*args, **kwargs)
 
+@login_required
 def mailchimp(request, id=None):
     if request.method == 'POST':
         '''
                                                     'template': '1',
                                                     'tpl_values': data,
                                                     'user': request.user})
+        if created: 
+            action = Action.objects.get(pk=obj.pk)
+            Refer.objects.create(name=request.POST['referuri0'], action=action)
+
         if not created:
             # Add fields to be updated
             Action.objects.update(pk=obj.pk)
-        return HttpResponse("Updated")
+        return HttpResponseRedirect(reverse('dashboard-url'))
     else:
         if id:
             pass

inbounding/settings_default.py

     'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
-    #'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
+    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
     #'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
 )
 
     'django.contrib.staticfiles',
     'django.contrib.admin',
     'django.contrib.sites',
+    'django.contrib.flatpages',
+
     #custom apps
     'dispatch',
 

inbounding/urls.py

     url(r'^admin/', include(admin.site.urls)),
     #(r'^accounts/', include('userena.urls')),
     (r'^', include('dispatch.urls')),
+    (r'', include('django.contrib.flatpages.urls')),	
 )