예제 #1
0
def News():
    if not IsAuthenticated():
        newsList = newsviewhandler.Get()
        newsList.sort(key=lambda x: x.updateDate, reverse=True)

        newsList = newsList[:3]

        for n in newsList:
            n.updateDate = n.updateDate.strftime('%d.%m.%Y')

        return render_template('news.html',
                               newsList=newsList,
                               authenticated=IsAuthenticated(),
                               admin=IsAdmin(),
                               fullName=GetFullNameSession())

    searchBy = request.args.get('searchBy', "", type=STRING)

    filterParameter = FilterParameter("MUSICIANNAME", "LIKE",
                                      "%" + searchBy + "%")
    filterExpression = FilterExpression()
    filterExpression.AddParameter(filterParameter)

    newsList = newsviewhandler.Get(filterExpression)
    newsList.sort(key=lambda x: x.updateDate, reverse=True)

    for n in newsList:
        n.updateDate = n.updateDate.strftime('%d.%m.%Y')

    return render_template('news.html',
                           newsList=newsList,
                           authenticated=IsAuthenticated(),
                           admin=IsAdmin(),
                           fullName=GetFullNameSession())
예제 #2
0
def Account():
    if IsAuthenticated():
        return redirect('/')

    return render_template('loginregister.html',
                           currentUser=User(),
                           authenticated=IsAuthenticated(),
                           fullName=GetFullNameSession())
예제 #3
0
def Home():
    if not IsAuthenticated():
        return redirect('/')

    user = userhandler.GetByID(GetUserIdSession())

    return render_template('userhome.html',
                           currentUser=user,
                           authenticated=IsAuthenticated(),
                           fullName=GetFullNameSession())
예제 #4
0
def UpdateNews():
    if not IsAuthenticated():
        return jsonify("You must be logged in to update news")

    if not IsAdmin():
        return jsonify("You must have admin privileges to update news")

    newsId = request.args.get('newsId', "", type=int)
    title = request.args.get('title', "", type=STRING)
    musicianName = request.args.get('musicianName', "", type=STRING)
    imgUrl = request.args.get('imgUrl', "", type=STRING)
    content = request.args.get('content', "", type=STRING)

    musician = musicianhandler.GetByMusicianName(musicianName)

    news = newshandler.GetByID(newsId)

    news.title = title
    news.musicianId = musician.musicianId
    news.imgUrl = imgUrl
    news.content = content

    validationMsg = news.IsValid()

    if validationMsg != "":
        return jsonify(validationMsg)

    newshandler.Update(news)

    return jsonify("")
예제 #5
0
def AddNews():
    if not IsAuthenticated():
        return jsonify("You must be logged in to add news")

    if not IsAdmin():
        return jsonify("You must have admin privileges to add news")

    news = News()

    news.title = request.args.get('addnews_title', "", type=STRING)
    news.content = request.args.get('addnews_content', "", type=STRING)

    musicianName = request.args.get('addnews_musician', "", type=STRING)

    musician = musicianhandler.GetByMusicianName(musicianName)
    news.musicianId = musician.musicianId

    imgUrl = request.args.get('addnews_imgUrl', "", type=STRING)

    if imgUrl != "":
        news.imgUrl = imgUrl

    validationMsg = news.IsValid()

    if validationMsg != "":
        return jsonify(validationMsg)

    news.createdBy = GetUserIdSession()

    newshandler.Insert(news)

    return jsonify("")
def UpdateMusician():
    if not IsAuthenticated():
        return jsonify("You must be logged in to update a concert area")

    if not IsAdmin():
        return jsonify(
            "You must have admin privileges to update a concert area")

    concert_areaId = request.args.get('concert_areaId', "", type=int)
    name = request.args.get('name', "", type=STRING)
    address = request.args.get('address', "", type=STRING)
    date = request.args.get('date', "", type=STRING)

    filterParameter1 = FilterParameter("CONCERT_AREANAME", "LIKE", name)

    filterExpression = FilterExpression()
    filterExpression.AddParameter(filterParameter1)

    concert_areaList = concert_areahandler.Get(filterExpression)

    if len(musicianList) > 0:
        return jsonify(
            "This musician already exists. Enter a different musician name.")

    concert_area = concert_areahandler.GetByID(concert_areaId)

    concert_area.name = name
    concert_area.address = address
    concert_area.capacity = capacity

    concert_areahandler.Update(concert_area)

    return jsonify("")
def AddConcert_area():
    if not IsAuthenticated():
        return jsonify("You must be logged in to add a concert area")

    if not IsAdmin():
        return jsonify("You must have admin privileges to add a concert area")

    concert_area = Concert_area()

    concert_area.name = request.args.get('concert_areaadd_concert_areaName',
                                         "",
                                         type=STRING)
    concert_area.address = request.args.get(
        'concert_areaadd_concert_areaaddress', "", type=STRING)
    concert_area.capacity = request.args.get(
        'concert_areaadd_concert_areacapacity', "", type=STRING)

    filterParameter = FilterParameter("CONCERT_AREANAME", "LIKE",
                                      concert_area.name)
    filterExpression = FilterExpression()
    filterExpression.AddParameter(filterParameter)

    concert_area = concert_areahandler.Get(filterExpression)

    if len(concert_area) > 0:
        return jsonify("This concert area already exists")

    if len(concert_area.capacity) != 7 and not musician.establishYear.isdigit(
    ):
        return jsonify(
            "Concert area's capacity cannot be equal or bigger than 1000000")

    concert_areahandler.Insert(concert_area)

    return jsonify("")
예제 #8
0
def home_page():
    if request.method == 'GET':
        now = datetime.datetime.now()

        return render_template('intro.html',
                               current_time=now.ctime(),
                               authenticated=IsAuthenticated(),
                               fullName=GetFullNameSession())
예제 #9
0
def UpdateUser():
    if not IsAuthenticated():
        return redirect('/')

    try:
        user = User()

        user.firstName = request.args.get('usersettings_firstName',
                                          "",
                                          type=STRING)
        user.lastName = request.args.get('usersettings_lastName',
                                         "",
                                         type=STRING)
        user.username = request.args.get('usersettings_username',
                                         "",
                                         type=STRING)
        user.email = request.args.get('usersettings_email', "", type=STRING)
        user.password = request.args.get('usersettings_password',
                                         "",
                                         type=STRING)

        user.userId = GetUserIdSession()

        validationMessage = user.IsValid()

        if validationMessage != "":
            return jsonify(validationMessage)

        filterParameter = FilterParameter("USERUSERNAME", "LIKE",
                                          user.username)
        filterExpression = FilterExpression()
        filterExpression.AddParameter(filterParameter)
        users = userhandler.Get(filterExpression)

        if len(users) > 0 and users[0].userId != GetUserIdSession():
            return jsonify("This username is already taken")

        filterParameter = FilterParameter("USEREMAIL", "LIKE", user.email)
        filterExpression = FilterExpression()
        filterExpression.AddParameter(filterParameter)
        users = userhandler.Get(filterExpression)

        if len(users) > 0 and users[0].userId != GetUserIdSession():
            return jsonify("This e-mail address is already taken")

        userhandler.Update(user)
        SetUserIdSession(user.userId)
        SetFullNameSession(user.firstName + " " + user.lastName)
        SetUsernameSession(user.username)

        return jsonify("")
    except:
        return jsonify("Unexpected error occured")
예제 #10
0
def DeleteUser():
    if not IsAuthenticated():
        return redirect('/')

    try:
        userhandler.Delete(GetUserIdSession())
        SetUserIdSession(-1)
        SetFullNameSession("")
        SetUsernameSession("")

        return jsonify(True)
    except:
        return jsonify(False)
예제 #11
0
def Musicians():
    searchBy = request.args.get('searchBy', "", type=STRING)

    filterParameter = FilterParameter("MUSICIANNAME", "LIKE",
                                      "%" + searchBy + "%")
    filterExpression = FilterExpression()
    filterExpression.AddParameter(filterParameter)

    musicianList = musicianhandler.Get(filterExpression)

    return render_template('musicians.html',
                           musicianList=musicianList,
                           authenticated=IsAuthenticated(),
                           admin=IsAdmin(),
                           fullName=GetFullNameSession())
def Concert_area():
    searchBy = request.args.get('searchBy', "", type=STRING)

    filterParameter = FilterParameter("CONCERT_AREANAME", "LIKE",
                                      "%" + searchBy + "%")
    filterExpression = FilterExpression()
    filterExpression.AddParameter(filterParameter)

    concert_areaList = concert_areahandler.Get(filterExpression)

    return render_template('concert_area.html',
                           concert_areaList=concert_areaList,
                           authenticated=IsAuthenticated(),
                           admin=IsAdmin(),
                           fullName=GetFullNameSession())
예제 #13
0
def DeleteNews():
    if not IsAuthenticated():
        return redirect('/')

    if not IsAdmin():
        return redirect('/')

    newsId = request.args.get('newsId', "", type=int)

    try:
        newshandler.Delete(newsId)

        return jsonify(True)
    except:
        return jsonify(False)
def DeleteConcert_area():
    if not IsAuthenticated():
        return redirect('/')

    if not IsAdmin():
        return redirect('/')

    concert_areaId = request.args.get('concert_areaId', "", type=int)

    try:
        concert_areahandler.Delete(concert_areaId)

        return jsonify(True)
    except:
        return jsonify(False)
예제 #15
0
def Register():
    if IsAuthenticated():
        return redirect('/')

    user = User()

    user.firstName = request.args.get('registerFirstName', "", type=STRING)
    user.lastName = request.args.get('registerLastName', "", type=STRING)
    user.username = request.args.get('registerUsername', "", type=STRING)
    user.email = request.args.get('registerEmail', "", type=STRING)
    user.password = request.args.get('registerPassword', "", type=STRING)
    user.userType = 2

    validationMessage = user.IsValid()

    if validationMessage != "":
        return jsonify(validationMessage)

    filterParameter = FilterParameter("USERUSERNAME", "LIKE", user.username)
    filterExpression = FilterExpression()
    filterExpression.AddParameter(filterParameter)
    users = userhandler.Get(filterExpression)

    if len(users) > 0:
        return jsonify("Username already exists")

    filterParameter = FilterParameter("USEREMAIL", "LIKE", user.email)
    filterExpression = FilterExpression()
    filterExpression.AddParameter(filterParameter)
    users = userhandler.Get(filterExpression)

    if len(users) > 0:
        return jsonify("Email already exists")

    user = userhandler.Insert(user)

    SetUserIdSession(user.userId)
    SetFullNameSession(user.firstName + " " + user.lastName)
    SetUsernameSession(user.username)

    return jsonify("")