require points to edit courses 314/head
authorJacob Hilker <hilker.j@gmail.com>
Tue, 4 Feb 2014 21:28:54 +0000 (16:28 -0500)
committerJacob Hilker <hilker.j@gmail.com>
Tue, 4 Feb 2014 21:29:57 +0000 (16:29 -0500)
karmaworld/apps/users/models.py
karmaworld/templates/courses/course_detail.html

index 15af634a7e465f0734e7096071971164b20a488e..1d23004cbaf2310c4ea69e59015071c3402f4e6c 100644 (file)
@@ -38,6 +38,9 @@ class UserProfile(models.Model):
 
         return sum
 
+    def can_edit_courses(self):
+        return (self.get_points() >= 20)
+
     NO_BADGE = 0
     PROSPECT = 1
     BEGINNER = 2
index 356a81c7eed2176de41fa675fb58b31d9fc8cc74..151419012be40251588b4d19acc12aeb867ad5e7 100644 (file)
           <div class="row">
             <div class="small-12 column center">
               {% if user.is_authenticated %}
-                <a href="#" id="edit-button"><img src="{{ STATIC_URL }}img/edit.png" alt="edit_flag" width="25" height="35"/></a>
+                {% if user.get_profile.can_edit_courses %}
+                  <a href="#" id="edit-button"><img src="{{ STATIC_URL }}img/edit.png" alt="edit_flag" width="25" height="35"/></a>
+                {% endif %}
+
                 {% if already_flagged %}
                   <img src="{{ STATIC_URL }}img/note_flag_disabled.png"
                        alt="course_flag"
       </div>
     </div><!-- /course_header -->
 
-    <section id="edit-course-form">
-      <form>
-        {% csrf_token %}
+    {% if user.get_profile.can_edit_courses %}
+      <section id="edit-course-form">
+        <form>
+          {% csrf_token %}
 
-        <div class="row">
-          <div id="course_form_errors" class="small-12 columns">
-            {{ course_form.non_field_errors }}
+          <div class="row">
+            <div id="course_form_errors" class="small-12 columns">
+              {{ course_form.non_field_errors }}
+            </div>
           </div>
-        </div>
 
-        <div class="row hide">
-          <div class="small-12 columns">
-            <legend>School</legend>
-            <div>
-              <input id="id_school" value="{{ course.school.id }}" name="school" type='hidden'/>
+          <div class="row hide">
+            <div class="small-12 columns">
+              <legend>School</legend>
+              <div>
+                <input id="id_school" value="{{ course.school.id }}" name="school" type='hidden'/>
+              </div>
             </div>
-          </div>
-        </div> <!-- .row -->
+          </div> <!-- .row -->
 
-        <div class="row">
-          <div class="small-12 columns">
-            <legend>Course Name:</legend>
-            <input id="id_name" class="" type="text" name="name" maxlength="255" value="{{ course.name }}"/>
-          </div>
-        </div> <!-- .row -->
+          <div class="row">
+            <div class="small-12 columns">
+              <legend>Course Name:</legend>
+              <input id="id_name" class="" type="text" name="name" maxlength="255" value="{{ course.name }}"/>
+            </div>
+          </div> <!-- .row -->
 
-        <div class="row">
-          <div class="small-12 columns large-6">
-            <legend>Instructor Name:</legend>
-            <input id="id_instructor_name" class="" type="text" name="instructor_name" maxlength="75" value="{{ course.instructor_name }}"/>
-          </div>
+          <div class="row">
+            <div class="small-12 columns large-6">
+              <legend>Instructor Name:</legend>
+              <input id="id_instructor_name" class="" type="text" name="instructor_name" maxlength="75" value="{{ course.instructor_name }}"/>
+            </div>
 
-          <div class="small-12 columns large-6">
-            <legend>Instructor Email:</legend>
-            <input id="id_instructor_email" class="" type="text" name="instructor_email" maxlength="75" value="{{ course.instructor_email }}"/>
-          </div>
-        </div> <!-- .row -->
+            <div class="small-12 columns large-6">
+              <legend>Instructor Email:</legend>
+              <input id="id_instructor_email" class="" type="text" name="instructor_email" maxlength="75" value="{{ course.instructor_email }}"/>
+            </div>
+          </div> <!-- .row -->
 
-        <div class="row">
-          <div class="small-12 columns">
-            <legend>Course url:</legend>
-            <input id="id_url" class="" type="text" name="url" maxlength="255" value="{{ course.url }}"/>
-          </div>
-        </div> <!-- .row -->
+          <div class="row">
+            <div class="small-12 columns">
+              <legend>Course url:</legend>
+              <input id="id_url" class="" type="text" name="url" maxlength="255" value="{{ course.url }}"/>
+            </div>
+          </div> <!-- .row -->
 
-        <div class="row">
-          <div class="small-4 large-8 columns small-centered text-center">
-            <button id="edit-save-btn" type=button><i class="fa fa-save"></i> Save</button>
+          <div class="row">
+            <div class="small-4 large-8 columns small-centered text-center">
+              <button id="edit-save-btn" type=button><i class="fa fa-save"></i> Save</button>
+            </div>
           </div>
-        </div>
-      </form>
-    </section>
+        </form>
+      </section>
+    {% endif %}
 
     <div class="row">
       <div class="small-10 columns small-offset-1"> <hr/> </div>