def save_logo(logo_url, event_id): """ Save the logo :param logo_url: :param event_id: :return: """ upload_path = UPLOAD_PATHS['event']['logo'].format(event_id=event_id) return save_event_image(logo_url, upload_path)
def save_untouched_background(background_url, event_id): """ Save the untouched background image :param background_url: :param event_id: :return: """ upload_path = UPLOAD_PATHS['event']['background_url'].format( event_id=event_id) return save_event_image(background_url, upload_path)
def save_untouched_background(background_url, event_id): """ Save the untouched background image :param background_url: :param event_id: :return: """ upload_path = UPLOAD_PATHS['event']['background_url'].format( event_id=event_id ) return save_event_image(background_url, upload_path)
def save_logo(logo_url, event_id): """ Save the logo :param logo_url: :param event_id: :return: """ upload_path = UPLOAD_PATHS['event']['logo'].format( event_id=event_id ) return save_event_image(logo_url, upload_path)
def save_sponsors_from_json(json, event_id=None): event_id = event_id if event_id else json['event_id'] event = DataGetter.get_event(event_id) sponsors_enabled = json['sponsors_enabled'] if sponsors_enabled: ids = [] for sponsor in json['sponsors']: if sponsor['id'] and represents_int(sponsor['id']): item = Sponsor.query.get(sponsor['id']) else: item = Sponsor(event_id=event_id) if sponsor['name'].strip() == '': continue item.name = sponsor['name'] item.level = sponsor['level'] item.sponsor_type = sponsor['type'] item.url = sponsor['url'] item.description = sponsor['description'] save_to_db(item) if item.logo != sponsor['logo']: if sponsor['logo'] and sponsor['logo'] != '': item.logo = save_event_image( sponsor['logo'], UPLOAD_PATHS['sponsors']['logo'].format( event_id=int(event.id), id=int(item.id))) else: item.logo = '' save_to_db(item) ids.append(item.id) if len(ids) > 0: Sponsor.query.filter(~Sponsor.id.in_(ids)).filter_by( event_id=event_id).delete(synchronize_session='fetch') else: Sponsor.query.filter_by(event_id=event_id).delete( synchronize_session='fetch') event.state = json['state'] if event.location_name.strip( ) != '' else 'Draft' save_to_db(event) return {'event_id': event.id}
def save_sponsors_from_json(json, event_id=None): event_id = event_id if event_id else json['event_id'] event = DataGetter.get_event(event_id) sponsors_enabled = json['sponsors_enabled'] if sponsors_enabled: ids = [] for sponsor in json['sponsors']: if sponsor['id'] and represents_int(sponsor['id']): item = Sponsor.query.get(sponsor['id']) else: item = Sponsor(event_id=event_id) if sponsor['name'].strip() == '': continue item.name = sponsor['name'] item.level = sponsor['level'] item.sponsor_type = sponsor['type'] item.url = sponsor['url'] item.description = sponsor['description'] save_to_db(item) if item.logo != sponsor['logo']: if sponsor['logo'] and sponsor['logo'] != '': item.logo = save_event_image(sponsor['logo'], UPLOAD_PATHS['sponsors']['logo'].format( event_id=int(event.id), id=int(item.id) )) else: item.logo = '' save_to_db(item) ids.append(item.id) if len(ids) > 0: Sponsor.query.filter(~Sponsor.id.in_(ids)).filter_by(event_id=event_id).delete(synchronize_session='fetch') else: Sponsor.query.filter_by(event_id=event_id).delete(synchronize_session='fetch') event.state = json['state'] if event.location_name.strip() != '' else 'Draft' save_to_db(event) return { 'event_id': event.id }