Julio Flores-Schwarzbeck avatar Julio Flores-Schwarzbeck committed 373aae1

Part of v1.1 upgrade, 70% completed

Comments (0)

Files changed (6)

controllers/default.py

 import json
 
 
-from gluon.contrib.login_methods.email_auth import email_auth
-
 # IDE "helper" not part of the framework
 if False:
     from gluon.globals import *
                         
                         # Get Forum Last Updated Data
                         #select
-                        #    zft.modifying_user,
+                        #    zft.modifying_user_if,
                         #    zft.modifying_date,
                         #    zft.topic_id,
                         #    zft.parent_flag,
                         where_statement = (db.zf_topic.forum_id==forum_id) & \
                         (db.zf_topic.disabled_flag==0)
                         last_update_info = db(
-                            where_statement).select(db.zf_topic.modifying_user,
+                            where_statement).select(
+                            db.zf_topic.modifying_user_id,
                             db.zf_topic.modifying_date,
                             db.zf_topic.id,
                             db.zf_topic.parent_flag,
                         if last_update_info:
                             last_updated = last_update_info[0].modifying_date
                             last_updated_by = last_update_info[
-                                0].modifying_user
+                                0].modifying_user_id
                             if last_update_info[0].parent_flag:
                                 last_updated_topic_id = last_update_info[0].id
                             else:
                 # This test must be evaluated when:
                 # - The User is Anonymous
                 # - AND the forum allow anonymous replies
-                view_info['errors'].append('Please make sure all required fields are properly filled')
+                view_info['errors'].append('Please make sure all required '
+                                           'fields are properly filled')
                 view_info.update({'preview': True})
-            elif req.add and (security_info['can_reply'] or auth_user.is_admin()):
+            elif req.add and (security_info['can_reply'] or \
+                              auth_user.is_admin()):
                 if req.response_content.strip():
                     now = request.now.strftime('%Y-%m-%d %H:%M:%S')
                     # User is requesting addition of a response (child topic)
                         reply_to_topic_id=0,
                         ip_address=request.remote_addr)
 
-                    # Update the modifying date, and the modifying user of its parent also
+                    # Update the modifying date, and the modifying user of
+                    # its parent also
                     db(db.zf_topic.id == topic_id).update(
                         modifying_date=now,
                         modifying_user_id=user_id)
     view_info['errors'] = []
     view_info['messages'] = []
     security_info = {'can_add': False, 'can_reply': False}
-    emoticons = ['icon_arrow.png', 'icon_biggrin.png', 'icon_confused.png', 'icon_cool.png', 'icon_cry.png', 'icon_exclaim.png', 'icon_idea.png', 'icon_lol.png', 'icon_mad.png', 'icon_mrgreen.png', 'icon_neutral.png', 'icon_question.png', 'icon_razz.png', 'icon_redface.png', 'icon_rolleyes.png', 'icon_sad.png', 'icon_smile.png', 'icon_twisted.png', 'icon_wink.png']
+    emoticons = ['icon_arrow.png',
+                 'icon_biggrin.png',
+                 'icon_confused.png',
+                 'icon_cool.png',
+                 'icon_cry.png',
+                 'icon_exclaim.png',
+                 'icon_idea.png',
+                 'icon_lol.png',
+                 'icon_mad.png',
+                 'icon_mrgreen.png',
+                 'icon_neutral.png',
+                 'icon_question.png',
+                 'icon_razz.png',
+                 'icon_redface.png',
+                 'icon_rolleyes.png',
+                 'icon_sad.png',
+                 'icon_smile.png',
+                 'icon_twisted.png',
+                 'icon_wink.png']
     view_info.update({'emoticons': emoticons})
     if req.form_submitted:
         topic_id = int(req.topic_id)
         forum_id = topic.forum_id
 
         if req.edit_topic:
-            if req.title and req.content and req.creation_user and req.creation_date and req.modifying_user and req.modifying_date:
+            if req.title and req.content and req.creation_user and \
+            req.creation_date and req.modifying_user and req.modifying_date:
                 title = parse_content(req.title)
                 creation_user = req.creation_user
                 creation_date = req.creation_date
                     parent_topic_id = topic_id
                     locked_flag = req.locked_flag is not None
                     sticky_flag = req.sticky_flag is not None
-                    system_announcement_flag = req.system_announcement_flag is not None
+                    system_announcement_flag = req.system_announcement_flag \
+                                               is not None
                     db(db.zf_topic.id==topic_id).update(title=title,
                         content=req.content,
-                        creation_user=creation_user,
+                        creation_user_id=creation_user,
                         creation_date=creation_date,
-                        modifying_user=modifying_user,
+                        modifying_user_id=modifying_user,
                         modifying_date=modifying_date,
                         locked_flag=locked_flag,
                         sticky_flag=sticky_flag,
                     # Just Update child-required fields
                     db(db.zf_topic.id==topic_id).update(title=title,
                         content=req.content,
-                        creation_user=creation_user,
+                        creation_user_id=creation_user,
                         creation_date=creation_date,
-                        modifying_user=modifying_user,
+                        modifying_user_id=modifying_user,
                         modifying_date=modifying_date)
-                redirect(URL(r=request, c='default', f='view_topic', args=[parent_topic_id]))
+                redirect(URL(r=request, c='default', f='view_topic',
+                             args=[parent_topic_id]))
             else:
                 view_info['errors'].append('All fields are required')
                 return dict(request=request, topic=topic, view_info=view_info)
                 parent_topic_id = topic_id
                 db(db.zf_topic.parent_id==parent_topic_id).delete()
                 db(db.zf_topic.id==parent_topic_id).delete()
-                redirect_to = URL(r=request, c='default', f='view_forum', args=[forum_id])
+                redirect_to = URL(r=request, c='default', f='view_forum',
+                                  args=[forum_id])
             else:
                 parent_topic_id = topic.parent_id
                 db(db.zf_topic.id==topic_id).delete()
-                redirect_to = URL(r=request, c='default', f='view_topic', args=[parent_topic_id])
+                redirect_to = URL(r=request, c='default', f='view_topic',
+                                  args=[parent_topic_id])
             redirect(redirect_to)
         else:
             if topic.parent_flag:
                 parent_topic_id = topic.id
             else:
                 parent_topic_id = topic.parent_id
-            redirect(URL(r=request, c='default', f='view_topic', args=[parent_topic_id]))
+            redirect(URL(r=request, c='default', f='view_topic',
+                         args=[parent_topic_id]))
     else:
         topic_id = int(request.args[0])
         topic = db(db.zf_topic.id==topic_id).select()[0]
     topic_id = int(request.args[1])
     child_id = int(request.args[0])
     if auth_user.is_auth():
-        db.zf_topic_inappropriate.insert(topic_id=topic_id, child_id=child_id, creation_user=auth_user.get_user_name(), creation_date=request.now.strftime('%Y-%m-%d %H:%M:%S'), read_flag=False)
+        db.zf_topic_inappropriate.insert(
+            topic_id=topic_id,
+            child_id=child_id,
+            creation_user_id=auth_user.get_user_id(),
+            creation_date=request.now,
+            read_flag=False)
     redirect(URL(r=request, c='default', f='view_topic', args=[topic_id]))
 
 def rss():
                     items = [
                         rss2.RSSItem(
                             title = topic.title,
-                            link = URL(r=request, c='default', f='view_topic', args=[topic.id]),
-                            description = parse_content(topic.content, 'forumfull'),
-                            pubDate = topic.modifying_date) for topic in rss_topics]
+                            link = URL(r=request, c='default', f='view_topic',
+                                       args=[topic.id]),
+                            description = parse_content(topic.content,
+                                                        'forumfull'),
+                            pubDate = topic.modifying_date) \
+                        for topic in rss_topics]
                     )
-    #raise ValueError, rss_feed
     response.headers['Content-Type'] = 'application/rss+xml'
     return rss2.dumps(rss_feed)
 
     view_info['errors'] = []
     if len(search_str) >= 3:
         search_str = '%%%s%%' % (search_str)
-        results = db(\
-            (\
-                (\
-                    (db.zf_topic.title.lower().like(search_str)) &\
-                    (db.zf_topic.parent_flag==True)\
-                ) |\
-                (db.zf_topic.content.lower().like(search_str))\
-            ) &\
-            (db.zf_topic.disabled_flag==False) &\
-            (db.zf_forum.id==db.zf_topic.forum_id)\
-        ).select(db.zf_topic.ALL, db.zf_forum.forum_title, orderby=~db.zf_topic.modifying_date, limitby=(0, 100))
+        results = db(((
+            (db.zf_topic.title.lower().like(search_str)) &
+            (db.zf_topic.parent_flag==True)) |
+            (db.zf_topic.content.lower().like(search_str))) &
+            (db.zf_topic.disabled_flag==False) &
+            (db.zf_forum.id==db.zf_topic.forum_id)).select(
+            db.zf_topic.ALL, db.zf_forum.forum_title,
+            orderby=~db.zf_topic.modifying_date, limitby=(0, 100))
     else:
-        view_info['errors'].append('Search string must be three or more characters')
-    return dict(request=request, search_str=request.vars.search_str, results=results, view_info=view_info)
+        view_info['errors'].append('Search string must be three or more '
+                                   'characters')
+    return dict(request=request, search_str=request.vars.search_str,
+                results=results, view_info=view_info)
 
 @auth_user.requires_login()
 def preferences():
                 if req.new_passwd == req.new_passwd_confirm:
                     hash_passwd = hashlib.sha1(
                         auth_user.get_user_name() + req.new_passwd).hexdigest()
-                    db(db.auth_users.id==auth_email).update(
+                    db(db.auth_users.id==user_id).update(
                         auth_passwd=hash_passwd)
                 else:
                     view_info['errors'].append('Password and confirmation do '

controllers/zadmin.py

     view_info = {}
     view_info['errors'] = []
     view_info['users'] = {}
-    list_order = ~db.auth_users.is_enabled|~db.auth_users.auth_created_on
+    list_order = ~db.auth_users.is_enabled | ~db.auth_users.auth_created_on
     all_users = db().select(db.auth_users.ALL, orderby=list_order)
     for this_user in all_users:
-        auth_alias = this_user.auth_alias
-        user_posts = db((db.zf_topic.creation_user==auth_alias) & (db.zf_topic.parent_flag==True)).count()
-        user_replies = db((db.zf_topic.creation_user==auth_alias) & (db.zf_topic.parent_flag==False)).count()
-        sql_roles = db((db.auth_user_role.auth_user_id==this_user.id) & (db.auth_roles.id==db.auth_user_role.auth_role_id)).select(db.auth_roles.auth_role_name)
-        user_roles = ','.join([auth_role_name.auth_role_name for auth_role_name in sql_roles])
-        view_info['users'].update({auth_alias: {'roles': user_roles, 'posts': user_posts, 'replies': user_replies, 'join_date': this_user.auth_created_on}})
+        user_id = this_user.id
+        #auth_email = this_user.auth_email
+        user_posts = db((db.zf_topic.creation_user_id == user_id) &
+            (db.zf_topic.parent_flag==True)).count()
+        user_replies = db((db.zf_topic.creation_user_id == user_id) &
+            (db.zf_topic.parent_flag==False)).count()
+        sql_roles = db((db.auth_user_role.auth_user_id == user_id) &
+            (db.auth_roles.id==db.auth_user_role.auth_role_id)).select(
+            db.auth_roles.auth_role_name)
+        user_roles = ','.join([auth_role_name.auth_role_name \
+                               for auth_role_name in sql_roles])
+        view_info['users'].update(
+            {user_id: {'roles': user_roles,
+                          'posts': user_posts,
+                          'replies': user_replies,
+                          'join_date': this_user.auth_created_on}})
     return dict(request=request, users=all_users, view_info=view_info)
 
 def user_edit():
                 db.Field('forum_id', db.zf_forum),
                 db.Field('title', 'string', length=255, required=True),
                 db.Field('content', 'text', required=True),
-                db.Field('parent_id', 'integer', required=True, default=0),
+                db.Field('parent_id', 'integer', required=False, default=0),
                 db.Field('creation_user_id', db.auth_users),
                 db.Field('creation_date', 'datetime', required=True),
                 db.Field('modifying_user_id', db.auth_users),
                 db.Field('modifying_date', 'datetime', required=True),
-                db.Field('hits', 'integer', required=True, default=0),
+                db.Field('hits', 'integer', required=False, default=0),
                 db.Field('parent_flag', 'boolean', required=False),
                 db.Field('locked_flag', 'boolean', required=False),
                 db.Field('disabled_flag', 'boolean', required=False),
                 db.Field('poll_flag', 'boolean', required=False),
                 db.Field('system_announcement_flag', 'boolean',
                          required=False),
-                db.Field('reply_to_topic_id', 'integer', required=True,
+                db.Field('reply_to_topic_id', 'integer', required=False,
                          default=0),
                 db.Field('ip_address', 'string', required=True),
                 migrate='zf_topic.table', fake_migrate=fake_migrate)
 db.define_table('zf_topic_inappropriate',
                 db.Field('topic_id', db.zf_topic),
                 db.Field('child_id', 'integer', required=True),
-                db.Field('creation_user', 'string', required=True, length=255),
+                db.Field('creation_user_id', 'string', required=True, length=255),
                 db.Field('creation_date', 'datetime', required=True),
                 db.Field('read_flag', 'boolean', default=False, required=True),
                 migrate='zf_topic_inappropriate.table',

views/default/add_topic.html

                 <tr>
                     <td><span class="warning">*</span> {{=XML(T('Creator'))}}:</td>
                     <td>
-                        <input type="text" id="creation_user" name="creation_user" value="{{=request.vars.get('creation_user', auth_user.get_user_name())}}" style="width:200px;" />
+                        <input disabled="disabled" type="text" id="creation_user_email" name="creation_user_email" value="{{=request.vars.get('creation_user', auth_user.get_user_name())}}" style="width:200px;" />
+                        <input type="hidden" id="creation_user" name="creation_user" value="{{=auth_user.get_user_id()}}" />
                         @
                         <input type="text" id="creation_date" name="creation_date" value="{{=request.vars.get('creation_date', request.now.strftime('%Y-%m-%d %H:%M:%S'))}}" style="width:200px;" />
                     </td>
                 <tr>
                     <td><span class="warning">*</span> {{=XML(T('Modificator'))}}:</td>
                     <td>
-                        <input type="text" id="modifying_user" name="modifying_user" value="{{=request.vars.get('modifying_user', auth_user.get_user_name())}}" style="width:200px;" />
+                        <input disabled="disabled" type="text" id="modifying_user_email" name="modifying_user_email" value="{{=request.vars.get('modifying_user', auth_user.get_user_name())}}" style="width:200px;" />
+                        <input type="hidden" id="modifying_user" name="modifying_user" value="{{=auth_user.get_user_id()}}" />
                         @
                         <input type="text" id="modifying_date" name="modifying_date" value="{{=request.vars.get('modifying_date', request.now.strftime('%Y-%m-%d %H:%M:%S'))}}" style="width:200px;" />
                     </td>

views/default/view_forum.html

                                     <br /><span class="small">{{=parse_content(this_topic.content[:view_info['zfsp_topic_teaser_length']], mode='forumpreview')}} ..</span>
                                 {{pass}}
                             </td>
-                            <td class="cell3d center-xy">{{=this_topic.creation_user}}</td>
+                            <td class="cell3d center-xy">{{=forumhelper.get_member_property('zfmp_display_name', this_topic.creation_user_id, 'Anonymous User')}}</td>
                             <td class="cell3d center-xy">{{=topic_replies_info[this_topic.id]}}</td>
                             <td class="cell3d center-xy">{{=this_topic.hits}}</td>
                             <td class="cell3d center-xy">
                                         {{=this_topic.modifying_date.strftime(str(T('%b %d, %Y - %I:%M %p')))}}
                                     </span>
                                     <br /><span class="small">{{=XML(T('By'))}}</span>
-                                    {{if this_topic.modifying_user == 'Anonymous User':}}
+                                    {{if this_topic.modifying_user_id == 0:}}
                                         <b class="small">{{=XML(T('Anonymous User'))}}</b>
                                     {{else:}}
                                         {{if auth_user.is_auth():}}
-                                            <a href="{{=URL(r=request, c='pm', f='message_new', args=[this_topic.modifying_user])}}"
-                                               title="{{=this_topic.modifying_user}}"
-                                               class="{{if (request.now - this_topic.modifying_date).days == 0:}}"smallb-new"{{else:}}"smallb"{{pass}}">{{=this_topic.modifying_user}}</a>
+                                            <a href="{{=URL(r=request, c='pm', f='message_new', args=[this_topic.modifying_user_id])}}"
+                                               title=""
+                                               class="{{if (request.now - this_topic.modifying_date).days == 0:}}"smallb-new"{{else:}}"smallb"{{pass}}">{{=forumhelper.get_member_property('zfmp_display_name', this_topic.modifying_user_id, 'user_%s' % (this_topic.modifying_user_id))}}</a>
                                         {{else:}}
-                                            <b class="small">{{=this_topic.modifying_user}}</b>
+                                            <b class="small">{{=forumhelper.get_member_property('zfmp_display_name', this_topic.modifying_user_id, 'user_%s' % (this_topic.modifying_user_id))}}</b>
                                         {{pass}}
                                     {{pass}}
                                 </div>

views/zadmin/users.html

             {{for idx, user in enumerate(users):}}
                 <tr class="{{if not user.is_enabled:}}shadedarker{{else:}}shadelight{{pass}}">
                     <td class="cell3d center-xy">{{=idx + 1}}</td>
-                    <td class="cell3d center-xy"><a href="{{=URL(r=request, c='zadmin', f='user_edit', args=[user.auth_alias])}}" title="{{=XML(T('Edit User'))}}" class="linkb">{{=user.auth_alias}}</a></td>
+                    <td class="cell3d center-xy"><a href="{{=URL(r=request, c='zadmin', f='user_edit', args=[user.id])}}" title="{{=XML(T('Edit User'))}}" class="linkb">{{=forumhelper.get_member_property('zfmp_display_name', user.id, 'user_%s' % (user.id))}}</a></td>
                     <td class="cell3d center-xy"><a href="mailto:{{=user.auth_email}}" title="{{=user.auth_email}}">{{=user.auth_email}}</a></td>
-                    <td class="cell3d center-xy">{{=view_info['users'][user.auth_alias]['roles']}}</a></td>
-                    <td class="cell3d center-xy">{{=view_info['users'][user.auth_alias]['posts']}}</td>
-                    <td class="cell3d center-xy">{{=view_info['users'][user.auth_alias]['replies']}}</td>
-                    <td class="cell3d center-xy">{{=view_info['users'][user.auth_alias]['join_date']}}</td>
+                    <td class="cell3d center-xy">{{=view_info['users'][user.id]['roles']}}</a></td>
+                    <td class="cell3d center-xy">{{=view_info['users'][user.id]['posts']}}</td>
+                    <td class="cell3d center-xy">{{=view_info['users'][user.id]['replies']}}</td>
+                    <td class="cell3d center-xy">{{=view_info['users'][user.id]['join_date']}}</td>
                 </tr>
             {{pass}}
         </tbody>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.