Commits

Julio Flores-Schwarzbeck committed 48ba535

Major bug fixed that was not awarding points to anyone when voted up/dn, in addition to fix bug in UI on preferences and upgraded version number

Comments (0)

Files changed (5)

controllers/members.py

                    1: 'You may not up vote the same entry twice.',
                    2: 'You may not vote up or down anymore on this entry.',
                    3: 'You may not down vote the same entry twice.',
+                   5: 'You do not have the required permissions to up/down '
+                   'vote entries.',
                    6: 'You may not up/down vote your own posts.'}
     anchor = 'questionMain'
     user_id = auth_user.get_user_id()
                     db(db.comments.id==qac_id).update(votes_up=votes_up,
                                                       votes_dn=votes_dn)
 
-                    # In addition, update the auth_role_id of the user that will
-                    # receive the "points"
-                    # Note, to this version, only up/dn votes on questions and
-                    # answers are awarded points to matter for the user's prof.
-                    # Comments do not. (this coud change though)
-                    # Also here update the user's appropriate fields pertaining
-                    # points
-                    if c_type in ('Q', 'A',):
-                        # Will receive the points
-                        target_user_id = object_info.created_by
-                        if points >= 0:
-                            points_prop = 'm_points_up'
-                        else:
-                            points_prop = 'm_points_dn'
+                # In addition, update the auth_role_id of the user that will
+                # receive the "points"
+                # Note, to this version, only up/dn votes on questions and
+                # answers are awarded points to matter for the user's prof.
+                # Comments do not. (this coud change though)
+                # Also here update the user's appropriate fields pertaining
+                # points
+                if c_type in ('Q', 'A',):
+                    # Will receive the points
+                    target_user_id = object_info.created_by
+                    if points >= 0:
+                        points_prop = 'm_points_up'
+                    else:
+                        points_prop = 'm_points_dn'
 
-                        stackhelper.increment_member_property(points_prop,
-                                                              target_user_id,
-                                                              abs(points))
-                        stackhelper.update_user_rank(
-                            target_user_id,
-                            stackhelper.get_user_points(target_user_id))
+                    stackhelper.increment_member_property(points_prop,
+                                                          target_user_id,
+                                                          abs(points))
+                    stackhelper.update_user_rank(
+                        target_user_id,
+                        stackhelper.get_user_points(target_user_id))
         else:
             # "Your up/down voting operation yielded no points...
             # ...You may not up/down vote your own posts"
             err = 6
+    else:
+        # User Cannot Vote.. this most likely will never happen as
+        # the link is disabled on the UI for non-allowed voters..
+        # You do not have the required permissions to up/down vote entries.
+        err = 5
+        
     if err:
         anchor = 'error'
 
 from QAStackHelper import QAStackHelper
 
 # Control Migrations
-migrate = False
-fake_migrate = False # Read web2py docs for this
+migrate = False # False if DB Schema already exists (? - Read Docs Pls)
+fake_migrate = False # True to regen table info for EXISTING tables (run once)
 
-db = DAL('sqlite://qastack2.sqlite', migrate=migrate)
+db = DAL('sqlite://qastack.sqlite', migrate=migrate)
 #db = DAL('mysql://web2py:py2web@ds9.virtual:3306/qastack')
 
 # Import Authentication/Authorization

views/admin/edit_user.html

                 </tr>
                 <tr class="shadedark">
                     <td>{{=XML(T('Reputation Points'))}}:</td>
-                    <td>{{=int(view_info['props']['points_up']) - int(view_info['props']['points_dn'])}} ({{=view_info['props']['points_up']}}/{{=view_info['props']['points_dn']}})</td>
+                    <td>{{=int(view_info['props']['points_up']) - int(view_info['props']['points_dn'])}} (+{{=view_info['props']['points_up']}} / -{{=view_info['props']['points_dn']}})</td>
                 </tr>
                 <tr class="shadedark">
                     <td>{{=XML(T('Question Subscriptions'))}}:</td>

views/members/preferences.html

                        style="vertical-align:middle;height:20px;width:20px;" /><div>Leave empty for no change.</div></a>
                     </td>
                 </tr>
-                <tr>
+                <tr class="shadedark">
                     <td>{{=XML(T('Display Name'))}}:</td>
                     <td>
                         <input type="text" style="width:250px;" class="formelem" name="display_name" id="display_name"
                     <td>{{=XML(T('Questions'))}}:</td>
                     <td>{{=view_info['props']['questions']}}</td>
                 </tr>
-                <tr>
+                <tr class="shadedark">
                     <td>{{=XML(T('Answers'))}}:</td>
                     <td>{{=view_info['props']['answers']}}</td>
                 </tr>
                 </tr>
                 <tr class="shadedark">
                     <td>{{=XML(T('Reputation Points'))}}:</td>
-                    <td>{{=int(view_info['props']['points_up']) - int(view_info['props']['points_dn'])}} ({{=view_info['props']['points_up']}}/{{=view_info['props']['points_dn']}})</td>
+                    <td>{{=int(view_info['props']['points_up']) - int(view_info['props']['points_dn'])}} (+{{=view_info['props']['points_up']}} / -{{=view_info['props']['points_dn']}})</td>
                 </tr>
                 <tr class="shadedark">
                     <td>{{=XML(T('Question Subscriptions'))}}:</td>

views/qastack_layout.html

 
 <div id="footer">
 	<p>QA-Stack is Open Source distributed under the Simplified BSD License -
-	Version RC2 (29-Jul-2011) | <a href="{{=URL(r=request, c='default', f='contact_admin')}}"
+	Version RC3 (30-Jul-2011) | <a href="{{=URL(r=request, c='default', f='contact_admin')}}"
 	title="{{=XML(T('Contact Administrator'))}}">{{=XML(T('Contact Administrator'))}}</a></p>
 </div>