예제 #1
0
파일: database.py 프로젝트: defkan/meetin
def update_user_detail(userId, form):
    temp = get_user_detail(userId)
    sql = '''
    UPDATE userdetail
    SET universityId = %s,
    photoUrl = %s,
    birthDate = %s,
    bio  =%s,
    urlInstagram = %s,
    urlTwitter = %s,
    urlFacebook = %s,
    occupation = %s,
    gender = %s
    WHERE userId = %s
    '''
    if (form.photoUrl.data):
        photoUrl = 'img/profile/' + photo_save_profile(form.photoUrl.data)
    else:
        photoUrl = temp['photoUrl']
    gender = ''
    if (form.gender.data):
        if (form.gender.data == 1):
            gender = 'Male'
        elif (form.gender.data == 2):
            gender = 'Female'
        elif (form.gender.data == 3):
            gender = 'Other'

    values = (form.university.data, photoUrl, form.birthDate.data,
              form.bio.data, form.urlInstagram.data, form.urlTwitter.data,
              form.urlFacebook.data, form.occupation.data, gender, userId)
    cursor.execute(sql, values)
    sql_connection.commit()
예제 #2
0
파일: database.py 프로젝트: defkan/meetin
def create_user(username, email, password):
    photo = 'img/profile/dummy.png'
    sql = 'INSERT INTO user(username,email,password) VALUES(%s,%s,%s)'
    cursor.execute(sql, (username, email, password))
    id_user = cursor.lastrowid
    sql = 'INSERT INTO userdetail(userId,urlInstagram,urlTwitter,urlFacebook,photoUrl) VALUES(%s,%s,%s,%s,%s)'
    cursor.execute(sql, (id_user, 'instagram', 'twitter', 'facebook', photo))
    sql_connection.commit()
    user_info = {"userId": id_user, "username": username, "email": email}
    return User(user_info)
예제 #3
0
파일: database.py 프로젝트: defkan/meetin
def create_event(userId, form):
    sql = 'INSERT INTO event(adminId,categoryId,eventName,description,eventPhotoUrl,eventLink,eventDate) VALUES(%s,%s,%s,%s,%s,%s,%s)'
    if (form.eventPhotoUrl.data):
        photoUrl = 'img/event_photo/' + photo_save_event(
            form.eventPhotoUrl.data)
    else:
        photoUrl = 'img/event_photo/dummy.jpg'

    values = (userId, form.category.data, form.eventName.data,
              form.description.data, photoUrl, form.eventLink.data,
              form.eventdate.data)
    cursor.execute(sql, values)
    id_event = cursor.lastrowid
    sql_connection.commit()
    return id_event
예제 #4
0
파일: database.py 프로젝트: defkan/meetin
def update_event(eventId, form):
    event = get_event(eventId=eventId)
    sql = '''UPDATE event
        SET categoryId = %s,
        eventName = %s,
        description = %s,
        eventPhotoUrl = %s,
        eventLink = %s,
        eventdate = %s
        WHERE eventId = %s
     '''
    if (form.eventPhotoUrl.data):
        photoUrl = 'img/event_photo/' + photo_save_event(
            form.eventPhotoUrl.data)
    else:
        photoUrl = event['eventPhotoUrl']

    values = (form.category.data, form.eventName.data, form.description.data,
              photoUrl, form.eventLink.data, form.eventdate.data, eventId)
    cursor.execute(sql, values)

    sql_connection.commit()
예제 #5
0
파일: database.py 프로젝트: defkan/meetin
def update_enrollment(enrollmentId, reson):
    sql = 'UPDATE enrollment SET reason = %s WHERE enrollmentId = %s'
    cursor.execute(sql, (reson, enrollmentId))
    sql_connection.commit()
예제 #6
0
파일: database.py 프로젝트: defkan/meetin
def add_enrollment(userId, eventId, reason):
    sql = 'INSERT INTO enrollment(userId,eventId,reason) VALUES(%s,%s,%s)'
    cursor.execute(sql, (userId, eventId, reason))
    sql_connection.commit()
예제 #7
0
파일: database.py 프로젝트: defkan/meetin
def delete_enrollment(enrollmentId):
    sql = 'DELETE FROM enrollment WHERE enrollmentId = %s'
    cursor.execute(sql, (enrollmentId, ))
    sql_connection.commit()
예제 #8
0
파일: database.py 프로젝트: defkan/meetin
def add_university(universityName):
    sql = 'INSERT INTO university(universityName) values(%s)'
    cursor.execute(sql, (universityName, ))
    sql_connection.commit()
예제 #9
0
파일: database.py 프로젝트: defkan/meetin
def create_category(categoryName):
    sql = 'INSERT INTO category(categoryName) VALUES(%s)'
    cursor.execute(sql, (categoryName, ))
    sql_connection.commit()
예제 #10
0
파일: database.py 프로젝트: defkan/meetin
def delete_user(userId):
    sql = 'DELETE FROM user WHERE userId = %s'
    cursor.execute(sql, (userId, ))
    sql_connection.commit()