コード例 #1
0
    def make_domain():
        r = get_request()

        if not is_teacher():
            return ERRORS.INVALID_CREDENTIALS

        if not r.is_json:
            return ERRORS.BAD_REQUEST

        data = r.json

        if not {'domain', 'name'} <= set(data):
            return ERRORS.MISSING_PARAMETERS

        domain, nom = data['domain'], data['name']

        ## Search for similar domains
        f = Domaine.query.filter(Domaine.domaine.ilike(f"{domain}")).all()

        if len(f):
            return flask.jsonify(f[0]), 200

        # Create new domain
        dom = Domaine.create(domaine=domain, nom=nom)
        db_session.add(dom)
        db_session.commit()

        return flask.jsonify(dom), 201
コード例 #2
0
def import_domain_from_file(filename: str):
    """
    Import base file for populating domain table
    Domain line must be:

    internal_name  display_name
  """

    with open(filename) as fp:
        i = 0
        for line in fp:
            i += 1
            parts: List[str] = line.strip().split('\t')

            try:
                domain, name = parts
            except:
                print(
                    f"Invalid line {i}: Incorrect number of elements in line.")
                continue

            d: Domaine = Domaine.query.filter_by(domaine=domain).all()

            if len(d):
                continue

            d = Domaine.create(domaine=domain, nom=name)
            db_session.add(d)

    db_session.commit()
コード例 #3
0
  def make_internship():
    r = get_request()
    stu = get_student_or_none()

    if not r.is_json:
      return ERRORS.BAD_REQUEST

    if not stu:
      return ERRORS.STUDENT_NOT_FOUND

    data = r.json

    if not {'promo_year', 'company', 'domain', 'contact'} <= set(data):
      return ERRORS.MISSING_PARAMETERS

    promo_year, id_entreprise, domain, id_contact = data['promo_year'], data['company'], data['domain'], data['contact']
    
    # Check if promo_year is okay for this student !
    if stu.annee_sortie:
      if not int(stu.annee_entree) <= int(data['promo_year']) <= int(stu.annee_sortie):
        return ERRORS.INVALID_DATE
    else:
      if not int(stu.annee_entree) <= int(data['promo_year']):
        return ERRORS.INVALID_DATE

    ## Check company id
    ent: Entreprise = Entreprise.query.filter_by(id_entreprise=id_entreprise).one_or_none()

    if not ent:
      return ERRORS.COMPANY_NOT_FOUND

    ##  Domain to id
    dom: Domaine = Domaine.query.filter_by(domaine=domain).one_or_none()

    if not dom:
      return ERRORS.DOMAIN_NOT_FOUND
    
    id_domain = dom.id_domaine


    ## Check contact id
    if id_contact is not None:
      cont: Contact = Contact.query.filter_by(id_contact=id_contact).one_or_none()

      if not cont:
        return ERRORS.CONTACT_NOT_FOUND

    # Create new internship
    stu.refresh_update()
    inter = Stage.create(
      promo=promo_year, 
      id_entreprise=int(id_entreprise), 
      id_domaine=id_domain, 
      id_contact=int(id_contact) if id_contact is not None else None, 
      id_etu=stu.id_etu
    )
    db_session.add(inter)
    db_session.commit()

    return flask.jsonify(inter), 201
コード例 #4
0
ファイル: company.py プロジェクト: alkihis/promo-app-server
    def make_entreprise():
        r = get_request()
        stu = get_student_or_none()

        if not stu or not r.is_json:
            return ERRORS.BAD_REQUEST

        data = r.json

        if not {'name', 'city', 'size', 'status'} <= set(data):
            return ERRORS.MISSING_PARAMETERS

        name, city, size, status = data['name'], data['city'], data[
            'size'], data['status']

        ## Search for similar company
        f = Entreprise.query.filter(
            and_(Entreprise.nom.ilike(f"{name}"),
                 Entreprise.ville.ilike(f"{city}"))).all()

        if len(f):
            return flask.jsonify(f[0])

        if type(name) is not str:
            return ERRORS.INVALID_INPUT_TYPE

        special_check = r"^[\w_ -]+$"
        if not re.match(special_check, name):
            return ERRORS.INVALID_INPUT_VALUE

        # Checks for size and status (enum voir TS interfaces.ts)
        if type(size) is not str:
            return ERRORS.INVALID_INPUT_TYPE

        valid_comp_size = {"small", "big", "medium", "very_big"}
        if size not in valid_comp_size:
            return ERRORS.UNEXPECTED_INPUT_VALUE

        # Checks for status (enum voir TS interfaces.ts)
        if type(status) is not str:
            return ERRORS.INVALID_INPUT_TYPE

        valid_comp_status = {"public", "private"}
        if status not in valid_comp_status:
            return ERRORS.UNEXPECTED_INPUT_VALUE

        gps_coords = get_location_of_company(city)

        # Create new company
        comp = Entreprise.create(nom=name,
                                 ville=city,
                                 taille=size,
                                 statut=status,
                                 lat=gps_coords[0],
                                 lng=gps_coords[1])
        db_session.add(comp)
        db_session.commit()

        return flask.jsonify(comp), 201
コード例 #5
0
def addObjectAttributes(userId, groupId, objectAttributes):
    if ObjectAttributes.query.filter(
            ObjectAttributes.objectId == groupId).filter(
                ObjectAttributes.name == objectAttributes.name).first():
        print("This attribute already exists!")
        return
    if isValidUser(userId) and isValidRouteGroup(groupId):
        db_session.add(objectAttributes)
        db_session.commit()
コード例 #6
0
def addRoute(userId, routeGroup):
    if isValidUser(userId):
        # if isValidRoute(routeGroup.objectName):
        #     print ('in error', routeGroup.objectName)
        #     generalLogger.error("Error: RouteGroup '" + routeGroup.objectName + "' already added to userID '" + str(userId) + "'")
        #     return
        # print('IN DB', routeGroup)
        db_session.add(routeGroup)
        db_session.commit()
        generalLogger.info("RouteGroup '" + routeGroup.objectName + "' added to userID '" + str(userId) + "'")
コード例 #7
0
def create_a_student(data, with_mail=True):
    # Si toutes ces clés ne sont pas présentes dans le dict
    if not {
            'first_name', 'last_name', 'email', 'year_in', 'entered_in',
            'graduated'
    } <= set(data):
        return ERRORS.MISSING_PARAMETERS

    first_name, last_name, email = data['first_name'], data['last_name'], data[
        'email']
    year_in, entree, diplome = data['year_in'], data['entered_in'], data[
        'graduated']

    student_check = Etudiant.query.filter_by(mail=email).all()
    if len(student_check):
        return ERRORS.STUDENT_EXISTS

    special_check = r"^[\w_ -]+$"
    if not re.match(special_check, first_name):
        return ERRORS.INVALID_INPUT_VALUE

    if not re.match(special_check, last_name):
        return ERRORS.INVALID_INPUT_VALUE

    email_catch = r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
    if not re.match(email_catch, email):
        return ERRORS.INVALID_EMAIL

    current_date = datetime.datetime.now().date().year

    if type(diplome) is not bool:
        return ERRORS.INVALID_INPUT_TYPE

    try:
        if int(year_in) > current_date or int(year_in) < 2015:
            return ERRORS.INVALID_DATE
    except:
        return ERRORS.INVALID_INPUT_TYPE

    # Create student
    etu = Etudiant.create(nom=last_name,
                          prenom=first_name,
                          mail=email,
                          annee_entree=year_in,
                          entree_en_m1=entree == "M1",
                          diplome=diplome)

    db_session.add(etu)
    db_session.commit()

    # Create a token automatically and send the welcome e-mail
    if with_mail:
        send_welcome_mail(etu.id_etu)

    return etu
コード例 #8
0
def import_students_from_file(filename: str):
    """
    Import base file for populating students
    Student line must be:

    first_name  last_name email graduation_year  is_graduated(1/0)
  """
    with open(filename) as fp:
        i = 0
        for line in fp:
            i += 1

            if not line.strip():
                continue

            parts: List[str] = line.strip().split('\t')

            try:
                first_name, last_name, email, graduation_year, is_in_m1, is_graduated = parts
            except:
                print(
                    f"Invalid line {i}: Incorrect number of elements in line.")
                continue

            try:
                year_in = int(graduation_year) - 2
                graduation_year = int(graduation_year)

                if graduation_year < 2015:
                    raise ValueError("Invalid gradutation date")
            except:
                print(
                    f"Invalid line {i}: Graduation year is not valid ({graduation_year})."
                )
                continue

            e: Etudiant = Etudiant.query.filter_by(mail=email).one_or_none()
            if e:
                print(
                    f"Line {i}: Student already exists (conflict in e-mail address)"
                )
                continue

            etu = Etudiant.create(nom=last_name,
                                  prenom=first_name,
                                  mail=email,
                                  annee_entree=year_in,
                                  annee_sortie=graduation_year,
                                  entree_en_m1=(is_in_m1 == "1"),
                                  diplome=(is_graduated == "1"))

            db_session.add(etu)

    db_session.commit()
コード例 #9
0
def create_ask_creation_token(mail: str, matches):
    ## Check if AskCreation already sended
    AskCreation.query.filter_by(mail=mail).delete()

    token = generate_random_token()

    a = AskCreation.create(token, mail)
    db_session.add(a)
    db_session.commit()

    return '<a href="' + SITE_URL + '/profile_create?token=' + str(
        a.token) + f'" target="_blank">{matches.group(1)}</a>'
コード例 #10
0
    def make_contact():
        r = get_request()
        if not r.is_json:
            return ERRORS.BAD_REQUEST

        data = r.json

        if not {'name', 'mail', 'id_entreprise'} <= set(data):
            return ERRORS.MISSING_PARAMETERS

        name, mail, id_entreprise = data['name'], data['mail'], data[
            'id_entreprise']

        ## Search for similar contact
        f = Contact.query.filter(
            and_(Contact.nom.ilike(f"{name}"), Contact.mail.ilike(f"{mail}"),
                 Contact.id_entreprise.ilike(f"{id_entreprise}"))).all()

        if len(f):
            return flask.jsonify(f[0]), 200

        #Check id_entreprise
        ent: Entreprise = Entreprise.query.filter_by(
            id_entreprise=id_entreprise).one_or_none()

        if not ent:
            return ERRORS.COMPANY_NOT_FOUND

        special_check = r"^[\w_ -]+$"
        if not re.match(special_check, name):
            return ERRORS.INVALID_INPUT_VALUE

        email_catch = r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"
        if not re.match(email_catch, mail):
            return ERRORS.INVALID_EMAIL

        # Create new contact
        cont = Contact.create(nom=name, mail=mail, id_entreprise=id_entreprise)
        db_session.add(cont)
        db_session.commit()

        return flask.jsonify(cont), 201
コード例 #11
0
    def create_formation():
        r = get_request()
        stu: Etudiant = get_student_or_none()

        if not stu or not r.is_json:
            return ERRORS.BAD_REQUEST

        data = r.json

        if not {'name', 'location', 'level'} <= set(data):
            return ERRORS.MISSING_PARAMETERS

        branch, location, level = data['name'], data['location'], data['level']

        if type(branch) is not str:
            return ERRORS.INVALID_INPUT_TYPE

        if type(level) is not str:
            return ERRORS.INVALID_INPUT_TYPE

        valid_levels = {"licence", "master", "phd", "other"}
        if level not in valid_levels:
            return ERRORS.UNEXPECTED_INPUT_VALUE

        ## Search for similar formations
        f = Formation.query.filter(
            and_(Formation.filiere.ilike(f"{branch}"),
                 Formation.lieu.ilike(f"{location}"),
                 Formation.niveau.ilike(f"{level}"))).all()

        if len(f):
            return flask.jsonify(f[0])

        # Create new formation
        form = Formation.create(filiere=branch, lieu=location, niveau=level)
        db_session.add(form)
        db_session.commit()

        return flask.jsonify(form), 201
コード例 #12
0
    def make_emploi():
        r = get_request()
        stu = get_student_or_none()

        if not r.is_json:
            return ERRORS.BAD_REQUEST

        if not stu:
            return ERRORS.STUDENT_NOT_FOUND

        user_id = stu.id_etu
        data = r.json

        if not {
                'start', 'end', 'contract', 'salary', 'level', 'company',
                'domain', 'contact'
        } <= set(data):
            return ERRORS.MISSING_PARAMETERS

        start, end, contract, salary, level, id_entreprise = data[
            'start'], data['end'], data['contract'], data['salary'], data[
                'level'], data['company']
        domain, id_contact = data['domain'], data['contact']

        list_d: List[Domaine] = Domaine.query.filter_by(domaine=domain).all()

        if not len(list_d):
            return ERRORS.DOMAIN_NOT_FOUND
        try:
            id_entreprise = int(id_entreprise)

            if salary is not None:
                salary = int(salary)

            if id_contact is not None:
                id_contact = int(id_contact)
        except:
            return ERRORS.INVALID_INPUT_TYPE

        id_domain = list_d[0].id_domaine

        try:
            start = convert_date(start)
        except:
            return ERRORS.INVALID_DATE

        if end is not None:
            try:
                end = convert_date(end)
            except:
                return ERRORS.INVALID_DATE

        # Teste si l'entreprise existe
        e = Entreprise.query.filter_by(
            id_entreprise=id_entreprise).one_or_none()
        if not e:
            return ERRORS.COMPANY_NOT_FOUND

        # Teste si le contact existe
        if id_contact is not None:
            c = Contact.query.filter_by(id_contact=id_contact).one_or_none()
            if not c:
                return ERRORS.CONTACT_NOT_FOUND

        #CHECK Contract in ENUM
        if type(contract) is not str:
            return ERRORS.INVALID_INPUT_TYPE

        #as_describe in client part interfaces.ts jobtypes
        valid_contracts = {"cdi", "alternance", "cdd", "these", 'other'}
        if contract not in valid_contracts:
            return ERRORS.UNEXPECTED_INPUT_VALUE

        #CHECK Level in ENUM
        if type(level) is not str:
            return ERRORS.INVALID_INPUT_TYPE

        #as_describe in client part interfaces.ts joblevels
        valid_levels = {
            "technicien", "ingenieur", "doctorant", "alternant", "other"
        }
        if level not in valid_levels:
            return ERRORS.UNEXPECTED_INPUT_VALUE
        # Create new emploi
        stu.refresh_update()
        emp = Emploi.create(debut=start,
                            fin=end,
                            contrat=contract,
                            niveau=level,
                            id_entreprise=id_entreprise,
                            id_domaine=id_domain,
                            id_contact=id_contact,
                            id_etu=user_id,
                            salaire=salary)
        db_session.add(emp)
        db_session.commit()

        return flask.jsonify(emp), 201
コード例 #13
0
ファイル: UserDB.py プロジェクト: shuklavk/APIBuilder
def addUser(user):
    if not isValidUser(user.id):
        db_session.add(user)
        db_session.commit()
        return True
    return False
コード例 #14
0
def index():
    if 'step' not in request.form:
        logger.debug('Request to homepage')
        return render_template('index.html')

    logger.debug(request.form['step'])

    # Step 1: Consent Form
    if request.form['step'] == 'consent':
        logger.debug('Request to consent page')
        return render_template('consent.html', step='consent')

    # Step 2: Tutorial Video
    if request.form['step'] == 'tutorial':
        logger.debug('Request to tutorial page')

        # Check for existing cookie
        if 'USER_COOKIE' in request.cookies:
            return render_template('error.html')

        # Create new user and save to database
        new_user = User()
        db_session.add(new_user)
        db_session.commit()

        # Update new user's cookie and ip address
        user_id = new_user.id
        new_user.cookie = 'MC_TEXT_VIZ_USER_{}'.format(user_id)
        # TODO: need to get correct IP address!
        # print(request.environ.get('HTTP_X_REAL_IP', request.remote_addr))
        # print(request.headers.get('X-Forwarded-For', request.remote_addr))
        # print(request.headers.get('X-Real-IP'))
        new_user.ip_address = request.remote_addr
        # line below produces key error
        # new_user.ip_address = os.environ["REMOTE_ADDR"]

        # Select and save visualization type
        viz_types = map(lambda x: x.name, list(VizType))
        viz_type = viz_types[user_id % len(viz_types)]
        new_user.viz_type = viz_type
        db_session.commit()

        resp = make_response(
            render_template('tutorial.html',
                            step='tutorial',
                            viz_type=viz_type))
        resp.set_cookie(cookie_names['tutorial'], new_user.cookie)
        return resp

    # Step 3: Visualization
    if request.form['step'] == 'viz':
        logger.debug('Request to visualization page')

        # check for reload
        if cookie_names['viz'] in request.cookies:
            return render_template('error.html')

        # Get info for current user
        current_user = get_user_from_cookie(request, 'USER_COOKIE')
        viz_type = current_user.viz_type

        # save start time
        current_user.start_time = str(datetime.datetime.now())
        db_session.commit()

        resp = make_response(
            render_template('viz.html', step='viz', viz_type=viz_type))
        resp.set_cookie(cookie_names['viz'], 'true')
        return resp

    # Step 4: Feedback
    if request.form['step'] == 'feedback':
        logger.debug('Request to feedback page')

        # check for reload
        if cookie_names['feedback'] in request.cookies:
            return render_template('error.html')

        # save response from previous page (viz)
        save_viz_response(request)

        resp = make_response(render_template('feedback.html', step='feedback'))
        resp.set_cookie(cookie_names['feedback'], 'true')
        return resp

    # Step 5: Thank you
    if request.form['step'] == 'thanks':
        logger.debug('Request to thank-you page')

        # check for reload
        if cookie_names['thanks'] in request.cookies:
            return render_template('error.html')

        # Save feedback to database
        current_user = get_user_from_cookie(request, 'USER_COOKIE')
        current_user.feedback = request.form['general_feedback']
        db_session.commit()

        resp = make_response(render_template('thanks.html'))
        resp.set_cookie(cookie_names['thanks'], 'true')
        return resp
コード例 #15
0
def import_legacy_db(filename: str):
    with sqlite3.connect(filename) as conn:
        cur = conn.cursor()

        # Initialise les domaines
        doms = cur.execute('''
      SELECT nomDomaine FROM Domaine
    ''').fetchall()

        for d in doms:
            domaine = d[0]
            orm_domaine = Domaine.create(domaine, domaine)
            db_session.add(orm_domaine)

        db_session.commit()

        # Insertion des étudiants
        students: List[Tuple[str, str, str, str]] = cur.execute('''
      SELECT DISTINCT e.emailetu, nometu, prenometu, annee 
      FROM Etudiant e 
      JOIN Promo p
      ON e.emailetu=p.emailetu
    ''').fetchall()

        town_to_real_loc = {}

        emails = set()
        for student in students:
            email, nom, prenom, annee = student

            if email in emails:
                continue

            emails.add(email)

            year_out = annee.split('/')[1]
            year_in = str(int(year_out) - 2)

            e = Etudiant.create(nom=nom,
                                prenom=prenom,
                                mail=email,
                                annee_entree=year_in,
                                annee_sortie=year_out,
                                entree_en_m1=True,
                                diplome=True)

            db_session.add(e)

        db_session.commit()
        # Insertion des emplois
        promo: List[Tuple[str, str, str, str, str, str, str, str,
                          int]] = cur.execute(''' 
      SELECT annee, emailetu, remuneration, nomorga, lieu, contrat, datedebut, statut, nomdomaine, idExp
      FROM Promo 
      NATURAL JOIN Embauche
      NATURAL JOIN Organisation
      NATURAL JOIN Experience
      NATURAL JOIN InsertionPro
      NATURAL JOIN ExpDom
      NATURAL JOIN Domaine
    ''').fetchall()

        exps = set()
        for experience in promo:
            annee, email, remuneration, nomorga, lieu, contrat, datedebut, statut, domaine, id_exp = experience

            if id_exp in exps:
                continue

            exps.add(id_exp)

            remuneration = int(remuneration)
            if remuneration == 0:
                remuneration = None
            else:
                remuneration *= 12

            # Cherche si nomorga existe
            companies: List[Entreprise] = Entreprise.query.filter_by(
                nom=nomorga).all()
            if len(companies):
                selected = companies[0]
            else:
                original_lieu = lieu
                if lieu in town_to_real_loc:
                    lieu = town_to_real_loc[lieu]

                gps_coords = get_location_of_company(lieu, force=True)
                town_to_real_loc[original_lieu] = gps_coords[2]

                selected = Entreprise.create(nom=nomorga,
                                             ville=gps_coords[2],
                                             taille="small",
                                             statut="public",
                                             lat=gps_coords[0],
                                             lng=gps_coords[1])

                db_session.add(selected)
                db_session.commit()

            jb = Emploi.create(debut=convert_date(datedebut),
                               fin=None,
                               contrat=convert_contrat(contrat),
                               niveau=convert_level(statut),
                               id_entreprise=selected.id_entreprise,
                               id_domaine=Domaine.query.filter_by(
                                   nom=domaine).one_or_none().id_domaine,
                               id_contact=None,
                               id_etu=Etudiant.query.filter_by(
                                   mail=email).one_or_none().id_etu,
                               salaire=remuneration)

            db_session.add(jb)

        # Insertion des stages
        stages: List[Tuple[str, str, str, str, str, str, str,
                           str]] = cur.execute(''' 
      SELECT emailetu, nomorga, lieu, nomdomaine, typestage, idExp, nomtut, emailtut
      FROM Promo 
      NATURAL JOIN Embauche
      NATURAL JOIN Organisation
      NATURAL JOIN Experience
      NATURAL JOIN Stage s
      NATURAL JOIN ExpDom
      NATURAL JOIN Domaine
      LEFT JOIN Dirige d
      ON d.idS=s.idS
      NATURAL JOIN TUTEUR
    ''').fetchall()
        for stage in stages:
            emailetu, nomorga, lieu, domaine, typestage, id_exp, nom_tuteur, email_tuteur = stage

            etu: Etudiant = Etudiant.query.filter_by(
                mail=emailetu).one_or_none()

            if not etu:
                continue
            # Cherche si nomorga existe
            companies: List[Entreprise] = Entreprise.query.filter_by(
                nom=nomorga).all()
            if len(companies):
                selected = companies[0]
            else:
                original_lieu = lieu
                if lieu in town_to_real_loc:
                    lieu = town_to_real_loc[lieu]

                gps_coords = get_location_of_company(lieu, force=True)
                town_to_real_loc[original_lieu] = gps_coords[2]

                selected = Entreprise.create(nom=nomorga,
                                             ville=gps_coords[2],
                                             taille="small",
                                             statut="public",
                                             lat=gps_coords[0],
                                             lng=gps_coords[1])

                db_session.add(selected)
                db_session.commit()

            promo = int(str(etu.annee_entree))
            if typestage == "M1" or typestage == "volontaire":
                promo += 1
            else:
                promo += 2

            promo = str(promo)

            tuteur = None
            if email_tuteur:
                tuteur: Contact = Contact.query.filter_by(
                    mail=email_tuteur).one_or_none()
                if not tuteur:
                    tuteur = Contact.create(
                        mail=email_tuteur,
                        nom=nom_tuteur,
                        id_entreprise=selected.id_entreprise)

                    db_session.add(tuteur)
                    db_session.commit()

            s = Stage.create(
                promo=promo,
                id_entreprise=selected.id_entreprise,
                id_domaine=Domaine.query.filter_by(
                    nom=domaine).one_or_none().id_domaine,
                id_contact=(tuteur.id_contact if tuteur else None),
                id_etu=etu.id_etu)

            db_session.add(s)

        db_session.commit()
コード例 #16
0
ファイル: update.py プロジェクト: d-fan/youtube-podcast
#!/usr/bin/python

from server import Channel, Podcast, db_session, config, init_db

if __name__ == "__main__":
    init_db()
    channel_list = config["channels"]
    for channel_name in channel_list:
        channel = Channel.query.filter(Channel.name == channel_name).first()
        if not channel:
            channel = Channel(channel_name)
            db_session.add(channel)
            db_session.commit()
        channel.load()
        for video_id in channel.videos:
            podcast = Podcast(video_id, channel.channel_id)
            podcast = Podcast.query.filter(Podcast.video_id == video_id).first()
            if not podcast:
                podcast = Podcast(video_id, channel.channel_id)
                db_session.add(channel)
                db_session.commit()
            print "Downloading %s" % str(podcast)
            podcast.download()
        # video_id = channel.videos[0]
        # podcast = Podcast.query.filter(Podcast.video_id == video_id).first()
        # if not podcast:
        #   podcast = Podcast(video_id, channel.channel_id)
        #   db_session.add(channel)
        #   db_session.commit()
        # podcast.download()
コード例 #17
0
ファイル: APIGroupDB.py プロジェクト: shuklavk/APIBuilder
def addAPI(userId, apiGroup):
    if isValidUser(userId):
        db_session.add(apiGroup)
        db_session.commit()