Пример #1
0
    def findUsers(self, uid=0, email="", passkey="", first_name="", last_name="", order_by=None, reverse=False):
        """ return found users """
        reverse = niceboolean(reverse)
        if uid or email or passkey or first_name or last_name:
            try:
                uid = int(uid)
            except ValueError:
                uid = 0
            if email is not None:
                email = "%%%s%%" % email.strip()
            if passkey is not None:
                passkey = passkey.strip()
            if first_name is not None:
                first_name = first_name.strip()
            if last_name is not None:
                last_name = last_name.strip()
            return self._findUsers(
                uid=uid,
                email=email,
                passkey=passkey,
                first_name=first_name,
                last_name=last_name,
                order_by=order_by,
                reverse=reverse,
            )

        else:
            return self._getUsers(order_by=order_by, reverse=reverse)
Пример #2
0
def manage_addModule(dispatcher, id, title, meta_type, product_name,
                       management_home_page, management_page, adder_page, editor_page,
                       is_container=False, parent_meta_type='',
                       REQUEST=None):
    """ create instance """
    dest = dispatcher.Destination()

    instance = Module(id.strip(), title.strip(), meta_type.strip(), 
                      product_name.strip(), management_home_page.strip(),
                      management_page.strip(), adder_page.strip(), editor_page.strip(),
                      niceboolean(is_container), parent_meta_type.strip()
                      )
    dest._setObject(id, instance)
    object = dest._getOb(id)
    
    if REQUEST is not None:
        REQUEST.RESPONSE.redirect(REQUEST.URL1+'/manage_workspace')
Пример #3
0
    def sortByHeader(self, key):
        """ return a query string which makes this key the 
        order_by key """

        qs = self.REQUEST.QUERY_STRING
        a = cgi.parse_qs(qs)
        if a.get("order_by", ["add_date"])[0] == key:
            a["reverse"] = [not niceboolean(a.get("reverse", [True])[0])]
        else:
            a["reverse"] = [a.get("reverse", [True])[0]]

        a["order_by"] = [key]
        items = []
        for k, vs in a.items():
            for v in vs:
                items.append("%s=%s" % (k, url_quote_plus(v)))
        return "?" + "&".join(items)
Пример #4
0
    def _sendreminders(self, max_send=100, verbose=False):
        """ the method to be hit by the cron job """
        verbose = niceboolean(verbose)
        max_send = int(max_send)
        msgs = []
        
        records = self._getRemindersToSend(max_send, order='uid')
        
        count = 0

        uid = None
        
        reminders = [] # group them in a list like this
        for record in records:
            if uid is None:
                reminders.append(record)
                uid = record.uid
            elif uid == record.uid:
                reminders.append(record)
            else:
                # different user
                self.sendUsersReminders(uid, reminders)
                count += len(reminders)
                
                uid = record.uid
                reminders = [record]
                
        if reminders:
            self.sendUsersReminders(uid, reminders)
            count += len(reminders)
            
        if verbose and count:
            msg = "Sent %s reminders\n" % count
            msg += '\n'.join(msgs)
            LOG("RememberYourFriends.Cron", INFO, msg)
            return msg
        
        else:
            return "Sent %s reminders" % count