merging old commit with current master
authorBryan <btbonval@gmail.com>
Wed, 26 Feb 2014 06:12:05 +0000 (01:12 -0500)
committerBryan <btbonval@gmail.com>
Wed, 26 Feb 2014 06:12:05 +0000 (01:12 -0500)
1  2 
karmaworld/apps/courses/forms.py
karmaworld/apps/courses/models.py
karmaworld/apps/courses/views.py
karmaworld/assets/css/global.css
karmaworld/settings/common.py
karmaworld/templates/partial/add_course.html
karmaworld/urls.py
reqs/common.txt

index db186bb8cb14832645fb7f18563d885c02b9c733,35f3a6ce36bf4f06ef75087e901fa19ed804bd31..e2642d35eb234943a647419a417121d595fbf3ee
@@@ -2,32 -2,38 +2,58 @@@
  # -*- coding:utf8 -*-
  # Copyright (C) 2012  FinalsClub Foundation
  
+ from django.conf import settings
  from django.forms import ModelForm
+ from django.forms import CharField
  
 +from ajax_select.fields import AutoCompleteSelectField
 +from ajax_select.fields import AutoCompleteSelectWidget
 +from ajax_select_cascade.fields import AutoCompleteDependentSelectField
 +from ajax_select_cascade.fields import AutoCompleteDependentSelectWidget
 +
  from karmaworld.apps.courses.models import Course
  
  class CourseForm(ModelForm):
 +    school = AutoCompleteSelectField(
 +        'school',
 +        widget=AutoCompleteSelectWidget(
 +            'school',
 +            attrs={'id': 'dom_autocomplete_school'}
 +        )
 +    )
 +    department = AutoCompleteDependentSelectField(
 +        'dept_given_school',
 +        widget=AutoCompleteDependentSelectWidget(
 +            'dept_given_school',
 +             attrs={'data-upstream-id': 'dom_autocomplete_school'},
 +        )
 +    )
+     def __init__(self, *args, **kwargs):
+         """ Add a dynamically named field. """
+         super(CourseForm, self).__init__(*args, **kwargs)
+         self.fields[settings.HONEYPOT_FIELD_NAME] = CharField(required=False)
      class Meta:
          model = Course
 -        fields = ('name', 'school', 'url', 'instructor_name', \
 -                  'instructor_email')
 +        # order the fields
 +        fields = ('school', 'department', 'name', 'instructor_name',
 +                  'instructor_email', 'url')
+     def clean(self, *args, **kwargs):
+         """ Additional form validation. """
+         # Call ModelFormMixin or whoever normally cleans house.
+         cleaned_data = super(CourseForm, self).clean(*args, **kwargs)
+         # parts of this code borrow from
+         # https://github.com/sunlightlabs/django-honeypot
+         hfn = settings.HONEYPOT_FIELD_NAME
+         formhoneypot = cleaned_data.get(hfn, None)
+         if formhoneypot and (formhoneypot != settings.HONEYPOT_VALUE):
+             # Highlight a failure to follow instructions.
+             # When the template dynamically generates the form, replace
+             # 'honeypot' with hfn
+             self._errors['honeypot'] = [u'You did not follow directions.']
+             del cleaned_data[hfn]
+         return cleaned_data
index 10f7770972b7c33928667dc67276dbf23d56461a,573bfe4db8bf5f6620c646c18785507dcad8b162..6ef836c2d566068a155695a12303b1a3ae1d1e1f
@@@ -13,12 -13,8 +13,13 @@@ import reversio
  
  from django.db import models
  from django.utils.text import slugify
+ from django.core.urlresolvers import reverse
  from karmaworld.settings.manual_unique_together import auto_add_check_unique_together
 +from ajax_select import LookupChannel
 +from ajax_select_cascade import DependentLookupChannel
 +from ajax_select_cascade import register_channel_name
 +
 +from karmaworld.utils.ajax_selects import register_channel_name
  
  
  class SchoolManager(models.Manager):
Simple merge
Simple merge
Simple merge
index 2d43e5e65b11bfcfb4adeaf901fc21db0fde68ef,47af638bd8b34b3a7866690c4322e4693779a71a..7b52b5812a384a5fae60fce1994cdaab1552965f
    <form method="POST" action="{% url 'home' %}">
    {% csrf_token %}
  
+     {% for error in course_form.non_field_errors %}
      <div class="row">
        <div class="small-12 columns">
-         {{ course_form.non_field_errors }}
+         {{ error }}
        </div>
      </div>
+     {% endfor %}
  
 -    <div class="row">
 -      <div class="small-12 columns">
 -        <legend>
 -          School
 -          {% for error in course_form.school.errors %}
 -          <span style="color:red">
 -            {{ error }}
 -          </span>
 -          {% endfor %}
 -        </legend>
 -        <div>
 -          <input id="str_school" class="" type="text" name="str_school" placeholder="Select a school"/>
 -          <input id="id_school" name="school" type='hidden'/>
 -        </div>
 -      </div>
 -    </div> <!-- .row -->
 -
 -    <div class="row">
 -      <div class="small-12 columns">
 -        <legend>Course Name:
 -          {% if course_form.name.errors %}
 -            <span style="color:red">
 -            {{ course_form.name.errors }}
 -            </span>
 -          {% endif %}
 -        </legend>
 -        <input id="id_name" class="" type="text" name="name" maxlength="255" />
 -      </div>
 -    </div> <!-- .row -->
 -
 -    <div class="row">
 -      <div class="small-12 columns">
 -        <legend>Do not fill in this field:
 -          {% for error in honeypot_errors %}
 -            <span style="color:red">
 -            {{ error }}
 -            </span>
 -          {% endfor %}
 -        </legend>
 -        <input type="text" name="{{HONEYPOT_FIELD_NAME}}" value="{{HONEYPOT_VALUE}}" />
 -      </div>
 -    </div>
 -
 -    <div class="row">
 -      <div class="small-12 columns large-6">
 -        <legend class="">
 -          Instructor Name:
 -          {% for error in course_form.instructor_name.errors %}
 -            <span style="color:red">
 -            {{ error }}
 -            </span>
 -          {% endfor %}
 -        </legend><!-- -->
 -        <input id="id_instructor_name" class="" type="text" name="instructor_name" maxlength="75" />
 -      </div>
 -
 -      <div class="small-12 columns large-6">
 -        <legend class="">
 -          Instructor Email:
 -          {% for error in course_form.instructor_email.errors %}
 -            <span style="color:red">
 -            {{ error }}
 -            </span>
 -          {% endfor %}
 -        </legend>
 -        <input id="id_instructor_email" class="" type="text" name="instructor_email" maxlength="75" />
 -      </div><!--  -->
 -    </div> <!-- .row -->
 -
 -    <div class="row">
 -      <div class="small-12 columns">
 -        <legend>Course url:
 -          {% for error in course_form.url.errors %}
 -            <span style="color:red">
 -            {{ error }}
 -            </span>
 -          {% endfor %}
 -        </legend>
 -        <input id="id_url" class="" type="text" name="url" maxlength="255" />
 -      </div>
 -    </div> <!-- .row -->
 +    {{ course_form }}
  
      <div class="row">
        <div class="small-4 large-8 columns small-centered text-center">
index 493e1e3bfa28296c462a11d4168eab2f2de07af9,6777de84baabba9a4a169642210b7da88d348119..7cf32d1e4895016940a1c5e26d613caddbb96118
@@@ -12,11 -12,11 +12,10 @@@ from karmaworld.apps.courses.models imp
  from karmaworld.apps.courses.views import AboutView, flag_course, edit_course
  from karmaworld.apps.courses.views import CourseDetailView
  from karmaworld.apps.courses.views import CourseListView
 -from karmaworld.apps.courses.views import school_list
  from karmaworld.apps.courses.views import school_course_list
  from karmaworld.apps.courses.views import school_course_instructor_list
- from karmaworld.apps.notes.views import NoteView, thank_note, NoteSearchView, flag_note, downloaded_note
+ from karmaworld.apps.notes.views import NoteView, thank_note, NoteSearchView, flag_note, downloaded_note, edit_note_tags
  from karmaworld.apps.notes.views import RawNoteDetailView
- from karmaworld.apps.notes.views import PDFView
  from karmaworld.apps.moderation import moderator
  from karmaworld.apps.document_upload.views import save_fp_upload
  from karmaworld.apps.users.views import ProfileView
diff --cc reqs/common.txt
Simple merge