コード例 #1
0
ファイル: models.py プロジェクト: robertavram/ConferenceAPI
    def from_form(cls, mys, parent_key):
        ''' Transform a form into a ConferenceSession object'''

        # copy ConferenceSessionForm/ProtoRPC Message into dict
        REQUIRED_FIELDS = [
            'name',
            'startTime',
            'startDate',
            'duration',
            'speakerKey']
        data = {field.name: getattr(mys, field.name)
                for field in mys.all_fields()}
        del data['websafeConferenceKey']

        # make sure all the required fields are present in the request
        error = filter(lambda x: not data.get(x), REQUIRED_FIELDS)
        if error:
            raise endpoints.BadRequestException(
                ', '.join(error) +
                ' are required')

        try:
            data['startTime'] = utils.make_time(data['startTime'])
            data['startDate'] = utils.make_date(data['startDate'])
        except ValueError:
            raise endpoints.BadRequestException(
                "The date and time need to be properly formated, ex: 2015-12-31, 14:59")

        data['speakerKey'] = ndb.Key(urlsafe=data['speakerKey'])
        data['key'] = parent_key
        return cls(**data)
コード例 #2
0
ファイル: api.py プロジェクト: skwzrd/Lamendo
def make_post_lite(row):
    if row:
        p = PostLite(
            row['post_id'],
            row['post_board_id'],
            row['user'],
            row['post'],
            row['img_filename'],
            row['img_uid'],
            get_file_ext(row['img_filename']),
            make_date(row['date']),
            row['ip'],
        )
        return p
    return None
コード例 #3
0
ファイル: api.py プロジェクト: skwzrd/Lamendo
def make_replies(rows):
    replies = None
    if rows:
        replies = []
        for r in rows:
            _r = Reply(
                int(r['reply_id']),
                int(r['reply_post_id']),
                None
                if not r['parent_reply_id'] else int(r['parent_reply_id']),
                [],
                [],
                r['user'],
                '' if r['reply'] is None else r['reply'],
                r['img_filename'],
                r['img_uid'],
                get_file_ext(r['img_filename']),
                make_date(r['date']),
                r['ip'],
            )
            replies.append(_r)
    return replies
コード例 #4
0
ファイル: cron.py プロジェクト: tperrier/mwachx
    def nightly(self):
        ''' Nightly cron jobs to be run at 1am '''

        email_subject = '{}'.format( datetime.date.today().strftime('%a %b %d (%j) %Y') )
        email_body = [ "Script started at {}".format(datetime.datetime.now()),'']

        if self.options.get('balance'):
            balance = at.balance()
            email_body.extend( ['Africas Talking Balance: {}'.format(balance),''] )

        if self.options.get('success'):
            start = utils.make_date( datetime.date.today() - datetime.timedelta(days=self.options.get('delta_days') ) )
            email_body.append( reports.message_status_groups(start,delta='day') )

        if self.options.get('calls'):
            command_utils.set_edd_calls(email_body)

        email_body = '\n'.join(email_body)
        if self.options.get('email'):
            email(email_subject,email_body)
        else:
            self.stdout.write(email_subject)
            self.stdout.write(email_body)
コード例 #5
0
def add_release_dates(repo_call_diffs, releases):
    for rid in repo_call_diffs:
        repo = rid['repo']
        release = rid['new_release']
        rid['release_date'] = utils.make_date(releases[repo][release],
                                              '%d-%m-%Y')