Exemplo n.º 1
0
def create_channel(channel_payload: ChannelType, request: Request,
                   response: Response):

    # Get logged in user
    user = auth_module.get_me(request=request)

    if user is None:
        return {"msg": "access denied!"}

    # Channel fields
    channel = Channel()
    channel.name = channel_payload.name
    channel.summary = channel_payload.summary
    channel.tags = channel_payload.tags
    channel.admins = [user.get("_id")]

    # Channel cover
    cover = Photo()
    cover._id = uuid.uuid4()
    cover.filename = "path-filename"
    cover.path = "path-photo"
    channel.cover = cover

    channel.save()

    return {"msg": "create channel route!"}
Exemplo n.º 2
0
def channels_add():
    rdata = request.get_json()
    name = rdata.get('name', None)
    sim_id = rdata.get('sim_id', None)
    sim_pass = rdata.get('sim_pass', None)
    phone = rdata.get('phone', None)
    balance_ussd = rdata.get('balance_ussd', None)

    channel = Channel()
    channel.name = name
    channel.sim_id = sim_id
    channel.sim_pass = sim_pass
    channel.phone = phone
    channel.balance_ussd = balance_ussd
    channel.save()

    return jsonify(channel)