def get_comments_for_talks(): talks = Talk.get_list(published=True) tweets = [] for talk in talks: talk_uuid = talk.uuid url = 'https://www.kateheddleston.com/talks/{}'.format(talk_uuid) update_facebook_comments(url, talk_uuid) tweets = tweets + update_tweet_comments(url, talk_uuid)
def create_talk(): data = json.loads(request.data) date = data.get('date') if date: date = datetime.datetime.strptime(date, '%B %d, %Y') data['date'] = date try: talk = Talk.create_talk(**data) except ValueError as e: flash(e.message, 'danger') return json.dumps({'message': e.message}), 400, {'Content-Type': 'application/json'} return json.dumps(talk), 200, {'Content-Type': 'application/json'}
def create_talk(): data = json.loads(request.data) date = data.get('date') if date: date = datetime.datetime.strptime(date, '%B %d, %Y') data['date'] = date try: talk = Talk.create(**data) except ValueError as e: flash(e.message, 'danger') return json.dumps({'message': e.message}), 400, { 'Content-Type': 'application/json' } return json.dumps(talk.to_dict()), 200, { 'Content-Type': 'application/json' }
if len(sys.argv) > 3: uuid = sys.argv[2] image_route = "{}/{}".format(db_table, uuid) filename = sys.argv[3] s3_change_image_resolutions(image_route, filename) elif len(sys.argv) > 2: uuid = sys.argv[2] image_route = "{}/{}".format(db_table, uuid) if db_table == 'galleries': db_item = Gallery.get_gallery(uuid=uuid) for item in db_item.get('items', []): if item.get('image_name'): print(item.get('image_name')) s3_change_image_resolutions(image_route, item.get('image_name')) elif db_table == 'talks': db_item = Talk.get_talk(uuid=uuid) if db_item.get('image_name'): print(db_item.get('image_name')) s3_change_image_resolutions(image_route, db_item.get('image_name')) else: if db_table == 'galleries': db_items = Gallery.get_galleries() for db_item in db_items: image_route = "{}/{}".format(db_table, db_item.get('uuid')) for item in db_item.get('items', []): if item.get('image_name'): print(item.get('image_name')) s3_change_image_resolutions(image_route, item.get('image_name')) elif db_table == 'talks': db_items = Talk.get_talks() for db_item in db_items:
def delete_talk(uuid): Talk.delete_talk(uuid) return_data = {'message': 'Your talk was successfully deleted.'} return json.dumps(return_data), 200, {'Content-Type': 'application/json'}
def edit_talk(uuid): data = json.loads(request.data) talk = Talk.update_talk(uuid, **data) return json.dumps(talk), 200, {'Content-Type': 'application/json'}
def delete_talk(uuid): Talk.delete(uuid=uuid) return_data = {'message': 'Your talk was successfully deleted.'} return json.dumps(return_data), 200, {'Content-Type': 'application/json'}
def talk(uuid): talk = Talk.get(uuid=uuid) if not talk: abort(404) return render_template('talk.html', talk=talk.to_dict())
def api_get_talks(): talks = Talk.get_list(published=False, to_json=True, sort_by='date') return json.dumps(talks), 200, {'Content-Type': 'application/json'}
def get_talks(): if request.is_xhr: talks = Talk.get_talks(published=False) return json.dumps(talks), 200, {'Content-Type': 'application/json'} g.nav_view = 'talks' return render_template('admin/talks.html')
def api_edit_talk(uuid=None): if uuid: talk = Talk.get(uuid=uuid).to_dict() else: talk = Talk.blank() return json.dumps(talk), 200, {'Content-Type': 'application/json'}
if len(sys.argv) > 3: uuid = sys.argv[2] image_route = "{}/{}".format(db_table, uuid) filename = sys.argv[3] s3_change_image_resolutions(image_route, filename) elif len(sys.argv) > 2: uuid = sys.argv[2] image_route = "{}/{}".format(db_table, uuid) if db_table == 'galleries': db_item = Gallery.get_gallery(uuid=uuid) for item in db_item.get('items', []): if item.get('image_name'): print item.get('image_name') s3_change_image_resolutions(image_route, item.get('image_name')) elif db_table == 'talks': db_item = Talk.get_talk(uuid=uuid) if db_item.get('image_name'): print db_item.get('image_name') s3_change_image_resolutions(image_route, db_item.get('image_name')) else: if db_table == 'galleries': db_items = Gallery.get_galleries() for db_item in db_items: image_route = "{}/{}".format(db_table, db_item.get('uuid')) for item in db_item.get('items', []): if item.get('image_name'): print item.get('image_name') s3_change_image_resolutions(image_route, item.get('image_name')) elif db_table == 'talks': db_items = Talk.get_talks() for db_item in db_items:
def talk(uuid): talk = Talk.get_talk(uuid) return render_template('talk.html', talk=talk)
def talks(): g.nav_view = 'talks' talks = Talk.get_talks() return render_template('talks.html', talks=talks)
def talks(): g.nav_view = 'talks' talks = Talk.get_list(published=True, sort_by='date', to_json=True) return render_template('talks.html', talks=talks)
def update_talk(uuid): data = json.loads(request.data) talk = Talk.update_talk(uuid, **data) return json.dumps(talk.to_dict()), 200, { 'Content-Type': 'application/json' }