예제 #1
0
    def validate(self):
        self.rv = Form.validate(self)
        if not self.rv:
            return False
        tUser = User.getByUsername(self.login_username.data)
        if tUser == None:  #not a valid username
            tUser = User.getByEmail(
                self.login_username.data
            )  #check if it is actaully an email address
            if tUser == None:
                self.login_username.errors.append(
                    "The username you have entered does not exist")
                return False
            if tUser.is_oauth_user:
                self.login_username.errors.append(
                    "The email you have entered is associated with a Facebook account, please login using Facebook."
                )

        if not tUser.validatePassword(self.login_password.data):
            self.login_password.errors.append(
                "It seems you have entered an incorrect password")
            return False

        self.user = tUser
        return True
예제 #2
0
def artwork(username,artworkUrlName=None): #TODO: better formatting of artworkName, %20 is horrible looking
    user = User.getByUsername(username)
    if user:
        artpiece = Artwork.query.filter(Artwork.user_id == user.id).filter(Artwork.url_name == artworkUrlName).first_or_404()
        return render_template('artpiece.html',artpiece=artpiece)
    else:
        app.logger.debug("Invalid artpiece page accessed:{username:%s, artworkName:%s}" % (username,artworkName))
        return 'error, artwork does not exist' #TODO: Better error
예제 #3
0
def artists(username=None):
    if username:  #browse directly to a user's artist page
        user = User.getByUsername(username)
        if user:
            return render_template('artist.html', artist=user)
        else:  #general, view all artists page
            app.logger.debug("Invalid artist's page accessed:{%s}" % username)
            return 'error, artist does not exist!'  #TODO: Better error
    else:
        artists = User.query.filter(User.has_image == True).all()
        return render_template('artists.html', artists=artists)
예제 #4
0
def artists(username=None):
    if username: #browse directly to a user's artist page
        user = User.getByUsername(username)
        if user:
            return render_template('artist.html',artist=user)
        else: #general, view all artists page
            app.logger.debug("Invalid artist's page accessed:{%s}" % username)
            return 'error, artist does not exist!' #TODO: Better error
    else:
        artists = User.query.filter(User.has_image==True).all()
        return render_template('artists.html',artists=artists)
예제 #5
0
def artwork(
    username,
    artworkUrlName=None
):  #TODO: better formatting of artworkName, %20 is horrible looking
    user = User.getByUsername(username)
    if user:
        artpiece = Artwork.query.filter(Artwork.user_id == user.id).filter(
            Artwork.url_name == artworkUrlName).first_or_404()
        return render_template('artpiece.html', artpiece=artpiece)
    else:
        app.logger.debug(
            "Invalid artpiece page accessed:{username:%s, artworkName:%s}" %
            (username, artworkName))
        return 'error, artwork does not exist'  #TODO: Better error
예제 #6
0
    def validate(self):
        self.rv = Form.validate(self)
        if not self.rv:
            return False
        tUser = User.getByUsername(self.login_username.data)
        if tUser ==None: #not a valid username
            tUser = User.getByEmail(self.login_username.data) #check if it is actaully an email address
            if tUser == None: 
                self.login_username.errors.append("The username you have entered does not exist")
                return False
            if tUser.is_oauth_user:
                self.login_username.errors.append("The email you have entered is associated with a Facebook account, please login using Facebook.")

        if not tUser.validatePassword(self.login_password.data):
            self.login_password.errors.append("It seems you have entered an incorrect password")
            return False

        self.user = tUser
        return True