當前位置: 首頁>>代碼示例>>Python>>正文


Python Directory.get_users方法代碼示例

本文整理匯總了Python中Directory.get_users方法的典型用法代碼示例。如果您正苦於以下問題:Python Directory.get_users方法的具體用法?Python Directory.get_users怎麽用?Python Directory.get_users使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Directory的用法示例。


在下文中一共展示了Directory.get_users方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: users_page

# 需要導入模塊: import Directory [as 別名]
# 或者: from Directory import get_users [as 別名]
 def users_page(self, request):
   '''Shows the users (embedded in the main page table)'''
   # the title
   request.writeln('<center><div class="i">Users:</div></center>')
   
   # current users
   request.writeln('''
     <p align="center">
     <select name="userselect" id="userselect" size="15">
   ''')
   users = Directory.get_users()
   users.sort(lambda a,b: cmp(a.username, b.username))
   for user in users:
     if user.superuser == '1':
       request.writeln('<option value="">' + html(user.name) + '</option>')
     else:
       request.writeln('<option value="' + user.id + '">' + html(user.name) + '</option>')
   request.writeln('''
     </select>
     </p>
     <p align="center">
       <a href="javascript:editUser();">Edit</a>
       |
       <a href="javascript:deleteUser();">Delete</a>
     </p>
     <hr>
     <p align="center">
       <a href="''' + request.cgi_href(_adminaction='edituser') + '''">Add New User</a>
       |
       <a href="''' + request.cgi_href(_adminaction='generateusers') + '''">Autogenerate Users</a>
       |
       <a href="''' + request.cgi_href(_adminaction='exportusers') + '''">Export User Information</a>
     </p>
   ''')
開發者ID:ssaltzman,項目名稱:POET,代碼行數:36,代碼來源:Administrator.py

示例2: do_delete_users

# 需要導入模塊: import Directory [as 別名]
# 或者: from Directory import get_users [as 別名]
 def do_delete_users(self, request):
   '''Delete ranges of autogenerated users'''
   prefix = request.getvalue('prefix', '')
   if len(prefix) == 0:
     return
   for user in Directory.get_users():
     if len(user.name) >= len(prefix) and user.name[:len(prefix)] == prefix:
       user.delete()
開發者ID:ssaltzman,項目名稱:POET,代碼行數:10,代碼來源:Administrator.py

示例3: meetings_page

# 需要導入模塊: import Directory [as 別名]
# 或者: from Directory import get_users [as 別名]
  def meetings_page(self, request):
    '''Shows the meetings (embedded in the main page table)'''
    request.writeln('<div class="module"><h1>Programs</h1>')
    
    # current meetings
    request.writeln('''
      <div align="center" name="meetingselect" id="meetingselect">
	<div id="meetinglist">
    ''')
    
    meetings = Directory.get_meetings()
    meetings.sort(lambda a,b: cmp(a.name, b.name))
    for meeting in meetings:
      request.writeln('''<div class="progBox">
			<span style="display:none;" id="meetinginfo_''' + meeting.id + '''">''' + str(meeting.id) + '''/''' + meeting.view + '''/''' + meeting.name + '''</span>
			<span style="float:left;">'''+meeting.name+'''</span>
			<span style="float:right;">
			  <a class="ui-icon ui-icon-pencil" href='javascript:editMeeting("''' + meeting.id + '''");'></a>
			  <a class="ui-icon ui-icon-closethick" href='javascript:deleteMeeting("''' + meeting.id + '''");'></a>
			  <a class="ui-icon ui-icon-plusthick" href='javascript:renameMeeting("''' + meeting.id + '''");'></a>
			</span>
		      </div>
    ''')
    request.writeln('''</div><br/>
	  <center>
	    <div id="programFormDialog" style="display:none;" title="Create New Program">
	    ''' + request.cgi_form(_adminaction='newmeeting', meetingname=None, meetingview=None, meetingusers=None, name='npForm') + '''
	      <select style="display:none;" name="meetingview"><option value="poet">POET Acquisition Collaboration</option></select>
	      <table border=0 style="height:100%;padding:10px;">
		<tr>
		  <td>Name:</td><td><input type="text" name="meetingname" size="20" /></td>
		</tr>
		<tr>
		  <td>Users:</td><td><select name="meetingusers" multiple size="5">
    ''')
    users = Directory.get_users()
    users.sort(lambda a,b: cmp(a.username, b.username))
    for user in users:
	request.writeln('''<option id="'''+ user.id + '''">''' + user.name + '''</option>''')
    request.writeln('''
		  </select></td>
		</tr>
		<tr>
		  <td><input type="submit" id="newProgram" value="Create" onclick="document.npForm.submit();" /></td><td><input type="button" id="cancelNP" value="Cancel" /></td>
		</tr>
	      </table>
	      </form>
	    </div>
	    <input type="button" id="createNP" value="Create New Program"></input>	  
	  </center>
	</div>
      </div>
    ''')
開發者ID:ssaltzman,項目名稱:POET,代碼行數:55,代碼來源:Administrator.py

示例4: export_users

# 需要導入模塊: import Directory [as 別名]
# 或者: from Directory import get_users [as 別名]
 def export_users(self, request):
   '''Exports the users for import into another application'''
   request.writeln('''
     <div align="center" class="i">Export User Information</div>
     <p>
     Copy and paste the following data into your favorite editor.  Save the file with a ".csv" extension and then
     load into Excel or another application.  Note that this feature is present for researchers running treatments 
     (to print out lists of usernames and passwords to give participants) rather than
     for administrators who want to snoop passwords.
     </p>
   ''')
   request.writeln('<pre><tt>')
   request.writeln('User ID,Username,Password,Real Name,Email')
   for user in Directory.get_users():
     request.writeln('\t'.join([ user.id, self._format_csv(user.username), self._format_csv(user.password), self._format_csv(user.name), self._format_csv(user.email)]))
   request.writeln('</tt></pre>')      
開發者ID:ssaltzman,項目名稱:POET,代碼行數:18,代碼來源:Administrator.py

示例5: send_admin_page

# 需要導入模塊: import Directory [as 別名]
# 或者: from Directory import get_users [as 別名]

#.........這裏部分代碼省略.........
          request.writeln('''<tr><td align='left'>&nbsp;</td><td align='center'><b> <a href='#asset_row' onclick=switchCheckBoxes('see_check'''+str(ctr)+''+str(group_ctr)+'''')>See</a> : <a href='#asset_row' onclick=switchCheckBoxes('move_check'''+str(ctr)+''+str(group_ctr)+'''')>Move</a></b></td></tr>''')
          user_ctr=0
          for member in group:
              user = Directory.get_user(member.user_id) #user is the actual user object.  member is the child of a group
              request.writeln('''<tr><td align='right'>'''+user.name+'''</td>''')
              try:
                  asset.visible_by.index(user.id)
                  request.writeln('''<td align='left'>&nbsp;&nbsp;<input id="see_check'''+str(ctr)+""+str(group_ctr)+""+str(user_ctr)+'''" name="_'''+str(user.id)+''':see"  value='on' checked type='checkbox'> : ''')                    
              except ValueError: #not in the asset yet --> no check                   
                  request.writeln('''<td align='left'>&nbsp;&nbsp;<input id="see_check'''+str(ctr)+""+str(group_ctr)+""+str(user_ctr)+'''" name="_'''+str(user.id)+''':see"  value='on' type='checkbox'> : ''')
              
              try:
                  asset.move_by.index(user.id)
                  request.writeln('''<input id='move_check'''+str(ctr)+""+str(group_ctr)+""+str(user_ctr)+'''' name="_'''+str(user.id)+''':move" value='on' checked type='checkbox'></td></tr>''')
              except ValueError: #not in the asset yet --> no check                   
                  request.writeln('''<input id='move_check'''+str(ctr)+""+str(group_ctr)+""+str(user_ctr)+'''' name="_'''+str(user.id)+''':move" value='on' type='checkbox'></td></tr>''')
              
              user_ctr=user_ctr+1
                          
          request.writeln('''
              <tr><td>&nbsp;</td><td><input type='submit' value='Assign'></td></tr></table></form>
          </tr>''')
          ctr=ctr+1
      
      request.writeln('</table>')
      request.writeln('</center>')
      
  

    ##### Strikecom Teams #####
    request.writeln('<a name="teams"></a><h1>Game Teams:</h1>')
    # groups in this meeting
    groups = datagate.get_child_items(teams.id)
    allusers = Directory.get_users()
    allusers.sort(lambda a,b: cmp(a.username, b.username))
    request.writeln('''
      <script language='JavaScript' type='text/javascript'>
      <!--
        var old_td;
        var old_index = -1;
        var assetindex;
        
        function addTeam() {
          var text = prompt("New Team Name:");
          if (text != null && text != '') {
            text = encode(text);
            window.location.href = "''' + request.cgi_href(global_meetingid=game.id,gm_action='StrikeCom.addgroup', itemid=game.id, name=None) + '''&name=" + text + "#teams";
          }
        }
        function switchCheckBoxes(switch_id)
        {
        //Conan can be changed to work differently.  Other than just ! the boxes 
            var mode = 'move';
            if(switch_id.indexOf('see')!=-1)
            {
               mode = 'see';
            }
            
            var ctr = 0;
            var boxes = document.getElementById(switch_id+""+ctr);
            while(boxes!=null)
            {
             boxes.checked = !boxes.checked;
             
             ctr++;
             boxes = document.getElementById(switch_id+""+ctr);
開發者ID:ssaltzman,項目名稱:POET,代碼行數:70,代碼來源:StrikeCom.py

示例6: send_content

# 需要導入模塊: import Directory [as 別名]
# 或者: from Directory import get_users [as 別名]
  def send_content(self, request):
    '''The top feedback frame'''
    # this is quite a process, but I've timed it on my Mac G4 and it only takes 0.01 seconds
    # on faster server, it would go even faster (the G4's not that fast compared to a dedicated server)
    rights = self.get_user_rights(request)
    
    # get the activity and treeroot
    activity = datagate.get_item(request.getvalue('global_rootid', ''))
    ratingRefreshRate = 20000
    if hasattr(activity, 'ratingRefreshRate'):
      try: ratingRefreshRate = int(activity.ratingRefreshRate) * 1000
      except TypeError: pass
    
    # calculate the individual scores (we calculate for all individuals)
    indivs = {}
    ratingnames = self.get_rating_names(activity)
    ratinginfo = dict( [ (ratingname, self.get_rating_adjustment(activity, ratingname)) for ratingname in ratingnames ] )
    for item in activity.get_parent().get_child_items(deep=1):

      # combine the ratings for this item into a data structure that we can access easily
      raters = {}
      for key in item.__dict__.keys():
        if key.find('rating_') == 0:
          parts = key.split('_')
          if len(parts) == 3: 
            dummy, rating, raterid = parts
            if not raters.has_key(raterid):
              raters[raterid] = {}
            raters[raterid][rating] = int(getattr(item, key)) * ratinginfo[rating] # rating * adjustment
    
      # add a comment point for the author of this item
      self._get_individual_scores(indivs, item.creatorid)['numComments'] += 1
      
      # add points for the ratings score
      if len(raters) > 0:
        total = 0.0
        for user_ratings in raters.values():
          user_product = 1
          for rating in user_ratings.values():
            user_product *= rating
          total += user_product
        average = total / len(raters)
      else:
        average = 0.0
      self._get_individual_scores(indivs, item.creatorid)['ratingsScore'] += average

      # add a rating point to everyone who rated this comment
      for raterid in raters.keys():
        self._get_individual_scores(indivs, raterid)['numRatings'] += 1
          
    # drop off the administrator
    for user in Directory.get_users():
      if user.superuser == '1' and indivs.has_key(user.id):
        del indivs[user.id]
        
    # calculate the group averages
    group = { 'numCommentsTotal': 0.0, 'ratingsScoreTotal': 0.0, 'numRatingsTotal': 0.0, 'numComments': 0.0, 'ratingsScore' : 0.0, 'numRatings': 0.0 }
    if len(indivs) > 0:
      for indiv in indivs.values():
        group['numCommentsTotal'] += indiv['numComments']
        group['ratingsScoreTotal'] += indiv['ratingsScore']
        group['numRatingsTotal'] += indiv['numRatings']
      group['numComments'] = group['numCommentsTotal'] / len(indivs)
      group['ratingsScore'] = group['ratingsScoreTotal'] / len(indivs)
      group['numRatings'] = group['numRatingsTotal'] / len(indivs)

    # save any goal/timer changes from the administrator      
    bars = 30
    elapsed_time = 0
    timer_duration = 0
    goal = 100

    # get the meeting timer/goal info from the admin if he's saved something
    if self.meeting_timer.has_key('z'): # do we have a timer for this meeting?
      timer_start, timer_duration, goal = self.meeting_timer['z']
      elapsed_time = time.time() - timer_start
      
    # calculate the scale and number of goal bars
    scale = float(bars) / float(goal)
    num_goal_bars = goal * scale
    if timer_duration <= 0 or elapsed_time >= timer_duration:
      num_elapsed_goal_bars = num_goal_bars
    else:
      num_elapsed_goal_bars = num_goal_bars * (elapsed_time / float(timer_duration))
              
    # adjust for the multiplier
    myratings = self._get_individual_scores(indivs, request.session.user.id)
    myratings['numRatingsN'] = myratings['numRatings']
    myratings['numRatings'] *= float(activity.ratingMultiplier)
    myratings['numCommentsN'] = myratings['numComments']
    myratings['numComments'] *= float(activity.commentMultiplier) 
    myratings['ratingsScoreN'] = ''
    myratings['ratingsScore'] *= float(activity.ratingsScoreMultiplier)
    myscore = myratings['numRatings'] + myratings['numComments'] + myratings['ratingsScore']
    group['numRatings'] *= float(activity.ratingMultiplier) 
    group['numComments'] *= float(activity.commentMultiplier) 
    group['ratingsScore'] *= float(activity.ratingsScoreMultiplier) 
    groupscore = group['numRatings'] + group['numComments'] + group['ratingsScore']
    
    # history for individual pacing
#.........這裏部分代碼省略.........
開發者ID:ssaltzman,項目名稱:POET,代碼行數:103,代碼來源:RatingDashboard.py


注:本文中的Directory.get_users方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。