Exemplo n.º 1
0
def add_project_member(prj_id):
    form = AddProjectMemberForm(request.form)
    if request.method == 'POST' and form.validate():
        try:
            # Add new member to project
            proj = Project.get_project_for_projectid(prj_id)
            proj.add_member(name=form.name.data, email=form.email.data, 
                role=Project.ROLE_MEMBER)
            # Create an appkey for the new member
            
            key = utils.generate_key(APPKEY_LENGTH)
            prjmemkey = ProjectMemberKey(prj_id=proj.prj_id, appkey=key, 
                member_email=form.email.data)
            prjmemkey.save()
            flash("New member has been added.")
            return redirect(url_for('.view_project', prj_id=prj_id))   
        except NotUniqueException:
            flash("The member email already exists. Can not add it.", 
                category="error")
            return render_template('add_project_member.html', form=form, 
                prj_id=prj_id)
        else:
            print 'Another exception is raised.'
    # if method is GET, show a form.        
    return render_template('add_project_member.html', form=form, prj_id=prj_id)    
Exemplo n.º 2
0
def view_project(prj_id):
    prj = Project.get_project_for_projectid(prj_id)
    if prj is not None and (prj.owner == current_user.username):
        memkeys = ProjectMemberKey.get_memberkeys_for_project(prj_id)
        return render_template('project_details.html', prj=prj, memkeys=memkeys)
    
    return render_template('404.html')
Exemplo n.º 3
0
def create_project():
    #with lock:
    form = CreateProjectForm(request.form)
    if request.method == 'POST' and form.validate():
        new_proj = Project(prj_name=form.name.data, prj_desc=form.desc.data,
            is_private=form.is_private.data, owner=current_user.get_id())
        print 'project.is_private:', new_proj.is_private
        prj_id = new_proj.save()
        # Add a user as an owner of a project
        proj = Project.get_project_for_projectid(prj_id)
        print 'project.is_private 2:', proj.is_private
        owner_name = current_user.firstname + ' ' + current_user.lastname
        proj.add_member(name=owner_name, email=current_user.get_id(), 
            role=Project.ROLE_OWNER)
        flash("New project has been created.", category='index_page')
        # Generate a project owner's appkey & save it to ProjectMemberKey coll.
        #keygen = KeyGenerator()
        #key = keygen.getkey(APPKEY_LENGTH)
        key = utils.generate_key()
        prjmemkey = ProjectMemberKey(prj_id=proj.prj_id, appkey=key, 
            member_email=proj.owner)
        prjmemkey.save()
        return redirect(url_for('.list_projects'))

    return render_template('create_project.html', form=form)
Exemplo n.º 4
0
def add_project_member(prj_id):
    # form = AddProjectMemberForm(request.form)
    # if request.method == 'POST' and form.validate():
    debug_set = current_app.config["DEBUG"]
    if debug_set == True:
        print "\n\n\n==========> account->views.py -> add_project_member() "
    form = AddProjectMemberForm()
    if form.validate_on_submit():
        try:
            # Add new member to project
            proj = Project.get_project_for_projectid(prj_id)
            proj.add_member(name=form.name.data, email=form.email.data, role=Project.ROLE_MEMBER)
            # Create an appkey for the new member

            key = utils.generate_key(settings.APPKEY_LENGTH)
            prjmemkey = ProjectMemberKey(prj_id=proj.prj_id, appkey=key, member_email=form.email.data)
            prjmemkey.save()
            flash("New member has been added.")
            return redirect(url_for(".view_project", prj_id=prj_id))
        except NotUniqueException:
            flash("The member email already exists. Can not add it.", category="error")
            return render_template("add_project_member.html", form=form, prj_id=prj_id)
        else:
            print "Another exception is raised."
    # if method is GET, show a form.
    return render_template("add_project_member.html", form=form, prj_id=prj_id)
Exemplo n.º 5
0
def create_project():
    # with lock:
    # form = CreateProjectForm(request.form)
    # if request.method == 'POST' and form.validate_on_submit():
    debug_set = current_app.config["DEBUG"]
    if debug_set == True:
        print "\n\n\n==========> account->views.py -> create_project() "
        # print "=====> is_private() :", form.is_private.data

    form = CreateProjectForm()
    if form.validate_on_submit():
        new_proj = Project(
            prj_name=form.name.data,
            prj_desc=form.desc.data,
            is_private=form.is_private.data,
            owner=current_user.get_id(),
        )
        prj_id = new_proj.save()
        # Add a user as an owner of a project
        proj = Project.get_project_for_projectid(prj_id)
        print "project.is_private 2:", proj.is_private
        owner_name = current_user.firstname + " " + current_user.lastname
        proj.add_member(name=owner_name, email=current_user.get_id(), role=Project.ROLE_OWNER)
        flash("New project has been created.", category="index_page")
        # Generate a project owner's appkey & save it to ProjectMemberKey coll.
        # keygen = KeyGenerator()
        # key = keygen.getkey(settings.APPKEY_LENGTH)
        key = utils.generate_key()
        prjmemkey = ProjectMemberKey(prj_id=proj.prj_id, appkey=key, member_email=proj.owner)
        prjmemkey.save()
        return redirect(url_for(".list_projects"))

    return render_template("create_project.html", form=form)
Exemplo n.º 6
0
def view_project(prj_id):
    debug_set = current_app.config["DEBUG"]
    if debug_set == True:
        print "\n\n\n==========> account->views.py -> view_project() "
    prj = Project.get_project_for_projectid(prj_id)
    # Read Application Setting to check a project type
    if settings.SINGLE_PROJECT_MODE and settings.USE_SINGLE_PROJECT_FORM:
        isPublished = True
    else:
        isPublished = False

    if prj is not None and (prj.owner == current_user.username):
        memkeys = ProjectMemberKey.get_memberkeys_for_project(prj_id)
        return render_template("project_details.html", prj=prj, memkeys=memkeys, isPublished=isPublished)

    return render_template("404.html")
Exemplo n.º 7
0
def delete_project_member(prj_id, member_email):
    proj = Project.get_project_for_projectid(prj_id)
    proj.delete_member(member_email)
    return redirect(url_for('.view_project', prj_id=prj_id))