async def putChannel(channel: Channel): db = connect_db() ins_id = put_channel(db, channel) if ins_id != '': return {'success'} else: return {'fail'}
async def putSubscriber(subscriber: Subscriber): db = connect_db() check_user = get_subscriber_single(db, subscriber) if check_user: Channel_distric = get_channel_by_district(db, check_user["Distric_id"]) if Channel_distric != None: chat_url = Channel_distric["Chat_url"] chat_name = Channel_distric["Name"] return { 'Name': chat_name, 'link': chat_url, 'success': "Already exist" } else: return {'suceess': 'Already exist', 'link': 'None'} else: ins_id = put_subscriber(db, subscriber) if ins_id != '': Channel_distric = get_channel_by_district(db, subscriber.Distric_id) if Channel_distric != None: chat_url = Channel_distric["Chat_url"] chat_name = Channel_distric["Name"] return {'Name': chat_name, 'link': chat_url, 'success': ins_id} else: return {'suceess': ins_id, 'link': 'None'} else: return {'fail'}
async def putResource(item: Item): db = connect_db() ins_id = put_resources(db, item) if ins_id != '': return {'success': ins_id} else: return {'fail'}
def getChannel(distric_id): db = connect_db() Channel_distric = get_channel_by_district(db, distric_id) if Channel_distric: chat_url = Channel_distric["Chat_url"] chat_name = Channel_distric["Name"] return {'Name': chat_name, 'link': chat_url, 'success': 'yep'} else: return {'success': 'nope'}
async def putResource(volunteer: Volunteer): db = connect_db() ins_id = put_volunteer(db, volunteer) if ins_id != '': ret = send_volunteer_email(volunteer) return {'success'} else: #ret = send_email(volunteer, 'Fails') return {'fail'}
def getChannel(): db = connect_db() data = get_channel(db) return JSONResponse(content=data)
def getResource(city): db = connect_db() data = get_bed(db, city) return JSONResponse(content=data)
def getResource(resource, start: int = 0, end: int = 10): db = connect_db() # print(resource) data = get_resources(db, resource, start, end) # print(data) return JSONResponse(content=data)