Commits

Wayne Werner committed d891386

Added project filtering, only looking at new projects

Comments (0)

Files changed (3)

             flash("Error on form!")
 
 
-    if (not current_user.is_anonymous()) and user_id == current_user.id:
-        return render_template("my_page.html",
-                               user=current_user,
-                               ebs=slayer.ebs(current_user.id, 
-                                              project=session.get('project')),
-                               form=form)
+    if current_user.is_anonymous() or user_id != current_user.id:
+        form = None
+        user = user
     else:
-        return render_template("my_page.html",
-                               ebs=slayer.ebs(user.id,
-                                              project=session.get('project')),
-                               user=user)
+        user = current_user
+    return render_template("my_page.html",
+                           user=user,
+                           session=session,
+                           ebs=slayer.ebs(user.id, 
+                                          project=session.get('project')),
+                           form=form)
 
 
 @app.route('/user/profile')
     conn = engine.connect()
     if project:
         query = '''select original from tasks t, estimates e where t.id =
-        e.task_id and e.user_id = :user_id and t.project_id = :project_id;'''
+                   e.task_id and e.user_id = :user_id 
+                   and t.project_id = :project_id
+                   and t.status in ('New', 'Open', 'In Progress');'''
     else:
-        query = '''select original from tasks t, estimates e where t.id = e.task_id and e.user_id = :user_id;'''
+        query = '''select original from tasks t, estimates e 
+                   where t.id = e.task_id 
+                   and e.user_id = :user_id
+                   and t.status in ('New', 'Open', 'In Progress');'''
 
     standard = [0.15, 0.3, 0.31, 0.39, 0.63, 0.68, 0.73, 0.82, 0.97, 1.02, 1.1, 1.27,
             1.28, 1.43, 1.57, 1.68, 1.82, 1.84, 1.93, 2.3, 2.57, 2.65, 2.7,
 
 
 def get_project(id):
+    if id is None: return None
     return session.query(Project).get(id)
  
 

templates/my_page.html

         <input type="submit" value="Add Interval" />
     </form>
 {% endif %}
-{{ user }}
-
 {% set total = 0 %}
 {% for date in user.timesheet().dates.items() %}
 <ul>
     {% set total = total + date[1].total %}
 </ul>
 {% endfor %}
-<h2>Grand Total:{{ total/60/60 }}</h2>
+{# <h2>Grand Total:{{ total/60/60 }}</h2> #}
+{% set project = session.get('project') %}
+Estimates for {{ user }}{% if project %} on {{ project }}{% endif %}.
+
 <div id="graph" style="width:600px;height:300px;"></div>
 <script type="text/javascript">
     $(document).ready(function(){