Exemple #1
0
    def default(self, name):
        try:
            project = ProjectModel.objects.get(name=name)
        except ProjectModel.DoesNotExist:
            cherrypy.response.status = 404
            data = {'error_message': '404 Project not found'}
            return render_template('error.html', data)

        data = {'project': project}
        return render_template('project/show.html', data)
Exemple #2
0
    def default(self, username):
        try:
            user = UserModel.objects.get(username=username)
        except UserModel.DoesNotExist:
            cherrypy.response.status = 404
            data = {'error_message': '404 User not found'}
            return render_template('error.html', data)

        projects = ProjectModel.objects(created_by=user)

        data = {'user': user, 'projects': projects}
        return render_template('user/show.html', data)
Exemple #3
0
    def default(self, username):
        try:
            user = UserModel.objects.get(username=username)
        except UserModel.DoesNotExist:
            cherrypy.response.status = 404
            data = {"error_message": "404 User not found"}
            return render_template("error.html", data)

        projects = ProjectModel.objects(created_by=user)

        data = {"user": user, "projects": projects}
        return render_template("user/show.html", data)
Exemple #4
0
    def oauth_callback(self, **params):
        # TODO Handle error messages from the API. Especially those likely to
        # occur such as "access_denied" and "redirect_uri_missmatch"

        try:
            auth_session = getAuthSession(params['code'])
        except KeyError:
            # TODO Determine the best status code for this scenario
            cherrypy.response.status = 409
            data = {'error_message': '409 OAuth2 service disliked the request'}
            return render_template('error.html', data)

        email = getUserEmail(auth_session)
        cherrypy.session['auth_session'] = auth_session

        try:
            user = UserModel.objects.get(email=email)
        except UserModel.DoesNotExist:
            add_flash_message("info", "You don't got an account yet!")
            raise cherrypy.HTTPRedirect("/user/new")

        info = getUserInformation(auth_session)
        user.gravatar_id = info['gravatar_id']
        user.save()

        add_flash_message("success", "You successfully signed in!")
        cherrypy.session['user'] = user

        raise cherrypy.HTTPRedirect("/")
Exemple #5
0
    def sign_up(self, username=None, license_agreement=None):
        if cherrypy.request.method != "POST":
            cherrypy.response.status = 405
            data = {'error_message': '405 Method not allowed'}
            return render_template('error.html', data)

        if license_agreement != 'on':
            data = {'error_message': 'Sorry män'}
            return render_template('error.html', data)

        email = getUserEmail(cherrypy.session['auth_session'])
        user = UserModel(username=username, email=email)
        user.save()

        add_flash_message("success", "You succesfully created a new account!")
        cherrypy.session.delete()
        raise cherrypy.HTTPRedirect("/")
Exemple #6
0
    def sign_up(self, username=None, license_agreement=None):
        if cherrypy.request.method != "POST":
            cherrypy.response.status = 405
            data = {"error_message": "405 Method not allowed"}
            return render_template("error.html", data)

        if license_agreement != "on":
            data = {"error_message": "Sorry män"}
            return render_template("error.html", data)

        email = getUserEmail(cherrypy.session["auth_session"])
        user = UserModel(username=username, email=email)
        user.save()

        add_flash_message("success", "You succesfully created a new account!")
        cherrypy.session.delete()
        raise cherrypy.HTTPRedirect("/")
Exemple #7
0
 def new(self):
     data = {}
     return render_template('register.html', data)
Exemple #8
0
 def index(self):
     data = {"projects": ProjectModel.objects, "users": UserModel.objects}
     return render_template("index.html", data)
Exemple #9
0
 def index(self):
     data = {'projects': ProjectModel.objects, 'users': UserModel.objects}
     return render_template('index.html', data)
Exemple #10
0
 def new(self):
     data = {}
     return render_template("register.html", data)