comparison MPIWGStaff.py @ 175:7d85ebe92ecf

getMemberList gets arrivedWithin parameter.
author casties
date Tue, 11 Jun 2013 11:29:56 +0200
parents 47392bf3fcba
children a8d5ba6729f3
comparison
equal deleted inserted replaced
174:15c3bc75028e 175:7d85ebe92ecf
132 """returns if member key is active""" 132 """returns if member key is active"""
133 res = self.executeZSQL("select * from personal_www where lower(key) = %s and publish_the_data = 'yes'", [key.lower()]) 133 res = self.executeZSQL("select * from personal_www where lower(key) = %s and publish_the_data = 'yes'", [key.lower()])
134 return len(res) > 0 134 return len(res) > 0
135 135
136 136
137 def getMemberList(self, department=None, sortBy='last_name', onlyCurrent=False, limit=0): 137 def getMemberList(self, department=None, sortBy='last_name', onlyCurrent=False, arrivedWithin=None, limit=0):
138 """Return the list of members. 138 """Return the list of members.
139 139
140 Returns a list of MPIWGStaffMember objects. 140 Returns a list of MPIWGStaffMember objects.
141 """ 141 """
142 members = [] 142 members = []
147 query += " and department ilike %s" 147 query += " and department ilike %s"
148 args.append('%%%s%%'%department) 148 args.append('%%%s%%'%department)
149 149
150 if onlyCurrent: 150 if onlyCurrent:
151 query += " and date_from < CURRENT_DATE" 151 query += " and date_from < CURRENT_DATE"
152
153 if arrivedWithin is not None:
154 query += " and date_from > CURRENT_DATE - interval %s"
155 args.append(arrivedWithin)
152 156
153 if sortBy == 'last_name': 157 if sortBy == 'last_name':
154 query += " order by lower(last_name)" 158 query += " order by lower(last_name)"
155 elif sortBy == 'date_from': 159 elif sortBy == 'date_from':
156 query += " order by date_from DESC" 160 query += " order by date_from DESC"