Ejemplo n.º 1
0
Archivo: bug.py Proyecto: Etenil/anvil
    def do_new_bug(self, project):
        i = web.input()
        bug = model.bug.Bug()
        bug.subject = i.summary
        bug.description = i.description
        bug.version = i.version
        bug.project = model.project.Project(name=project)

        f = None
        if common.session.user == None:
            f = self.new_anon_form()
            bug.guest = True
            bug.author_extern = i.name
            bug.author_extern_email = i.email
        else:
            f = self.new_user_form()
            bug.guest = False
            bug.author_intern = model.user.User(name=common.session.user)
        if not f.validates():
            return common.render.bugnew(f=form,
                                        proj=project,
                                        htTitle="Report a bug")
        try:
            bug.save()
            event.add(username=common.session.user, projectname=project,
                      type=event.EV_BUG,
                      link=("%s/%s/bugs/%d" % (config.prefix, project, bug.id)),
                      msg=("Bug %d added" % bug.id))
        except:
            pass
        raise web.seeother(config.prefix + '/' + project + '/bugs')
Ejemplo n.º 2
0
Archivo: bug.py Proyecto: Etenil/anvil
    def do_add_comment(self, project, bugnum):
        i = web.input()
        comm = model.bugcomment.BugComment()
        comm.bug = bugnum
        comm.message = i.comment

        if common.session.user != None:
            user = model.user.User(name=common.session.user)
            comm.author = user.name
            comm.author_email = user.email
            comm.extern = False
        else:
            comm.author = i.name
            comm.author_email = i.email
            comm.extern = True

        try:
            comm.save()
            event.add(username=common.session.user,
                      projectname=project, type=event.EV_BUG,
                      link=("%s/%s/bugs/%s" % (config.prefix, project, bugnum)),
                      msg=("Comment added to bug %d" % bugnum))
        except:
            a = 1
        raise web.seeother(config.prefix + '/' + project + '/bugs/' + bugnum)
Ejemplo n.º 3
0
    def make_edit_project(self, name):
        proj = None
        try:
            proj = model.project.Project(name=name)
        except:
            raise web.seeother(config.prefix + "/")

        if not proj.isadmin(common.session.user):
            raise web.seeother(config.prefix + "/+" + name)

        i = web.input()
        proj2 = proj
        proj2.name = i.name
        proj2.homepage = i.homepage
        proj2.description = i.description
        try:
            proj2.save()
            web.seeother(config.prefix + "/" + proj2.name)
        except:
            return common.render.newproject(errors=["Name already in use."], proj=proj, htTitle="New project", form=f)
        else:
            event.add(
                user=proj2.owner.id,
                type=event.EV_PROJECT,
                project=proj2.id,
                link=config.prefix + "/" + proj.name,
                msg=("Edited project %s" % proj2.name),
            )
Ejemplo n.º 4
0
    def make_new(self):
        f = self.new_form()
        error = False
        errors = []

        if not f.validates():
            error = True

        i = web.input()
        proj = model.project.Project()
        proj.name = i.name
        proj.owner = model.user.User(name=common.session.user)
        proj.homepage = i.homepage
        proj.description = i.description
        try:
            anvillib.fs.create_project(proj.name)
            proj.save()
        except:
            error = True
            errors.append("Project already exists.")
        else:
            proj.add_commiter(proj.owner.id)
            event.add(
                user=proj.owner.id,
                type=event.EV_PROJECT,
                project=proj.id,
                link=config.prefix + "/" + proj.name,
                msg="%s created project %s" % (proj.owner.name, proj.name),
            )

        if error:
            raise Exception(error)
            return common.render.newproject(htTitle="New project", form=f)
        else:
            raise web.seeother(config.prefix + "/" + proj.name)
Ejemplo n.º 5
0
Archivo: user.py Proyecto: Etenil/anvil
 def do_register(self):
     f = self.reg_form()
     if not f.validates():
         return common.render.register(form=f,
                                       htTitle="Register")
     i = web.input()
     try:
         # Creating the user on the system
         anvillib.fs.create_user(i.name)
         # Adding the user
         model.user.create_user(name=i.name,
                                email=i.email,
                                password=i.password,
                                homepage=i.homepage,
                                description=i.description)
         common.session.user = i.name
         event.add(username=i.name, type=event.EV_USER,
                   link=config.prefix + '/*' + i.name,
                   msg=("%s registered to %s" % (i.name, config.val('title'))))
         email.send("*****@*****.**", i.email, "Welcome to Anvil",
                    """Thank you for registering on Anvil.""")
         raise web.seeother(config.prefix + '/*' + i.name)
     except model.user.UserError:
         return common.render.register(error="Username already exists!",
                                form=f,
                                htTitle="Register")
Ejemplo n.º 6
0
Archivo: user.py Proyecto: Etenil/anvil
 def del_branch(self, username, branch):
     user = model.user.User(name=username)
     if user.name == common.session.user:
         try:
             anvillib.fs.delete_user_branch(username, branch)
         except:
             pass
         else:
             event.add(user=user.id, type=event.EV_USER,
                       link=config.prefix + '/*' + username,
                       msg=("%s deleted branch %s" % (username, branch)))
     raise web.seeother(config.prefix + '/*' + username)
Ejemplo n.º 7
0
 def del_branch(self, project, branch):
     p = model.project.Project(name=project)
     if p.isadmin(common.session.user):
         try:
             anvillib.fs.delete_project_branch(project, branch)
         except:
             pass
         else:
             event.add(
                 username=common.session.user,
                 type=event.EV_PROJECT,
                 project=p.id,
                 link=config.prefix + "/" + proj.name,
                 msg=("Deleted branch %s of project %s" % (branch, p.name)),
             )
     raise web.seeother(config.prefix + "/" + project)
Ejemplo n.º 8
0
 def rem_commiter(self, proj_name, commiter_name):
     proj = model.project.Project(name=proj_name)
     if proj.isadmin(common.session.user):
         try:
             commiter = model.user.User(name=commiter_name)
         except:
             a = 2
         else:
             proj.rem_commiter(commiter.id)
             event.add(
                 username=common.session.user,
                 type=event.EV_PROJECT,
                 project=proj.id,
                 link=config.prefix + "/" + proj.name,
                 msg=("Removed user %s from project %s" % (commiter_name, proj_name)),
             )
     raise web.seeother(config.prefix + "/" + proj_name)
Ejemplo n.º 9
0
Archivo: bug.py Proyecto: Etenil/anvil
    def do_edit_bug(self, project, bugnum):
        p = model.project.Project(name=project)
        if not p.isadmin(common.session.user):
            raise web.seeother(config.prefix + '/' + project + '/bugs/' + bugnum)

        comm = model.bugcomment.BugComment()

        # Saving bug
        i = web.input()
        bug = model.bug.Bug(bugnum)
        assignee = None
        if i.assigned_to != "*none" and (bug.assigned_to == None or i.assigned_to != bug.assigned_to.name):
            assignee = model.user.User(name=i.assigned_to)
            bug.assigned_to = assignee
            comm.message += '<p class="system-msg">Assigned to ' + assignee.name + '</p>'
        elif bug.assigned_to != None:
                bug.assigned_to = None
                comm.message += '<p class="system-msg">Bug unassigned</p>'

        if bug.status != int(i.status):
            bug.status = int(i.status)
            comm.message += '<p class="system-msg">Status changed to ' + bug.get_status() + '</p>'
        if bug.version != i.version:
            bug.version = i.version
            comm.message += '<p class="system-msg">Version changed to ' + bug.version + '</p>'
        event.add(username=common.session.user,
                  projectname=project, type=event.EV_BUG,
                  link=("%s/%s/bugs/%s" % (config.prefix, project, bugnum)),
                  msg=("Bug #%d edited: %s" % (bug.id, i.comment)))
        bug.save()

        # Adding comment
        user = model.user.User(name=common.session.user)
        comm.author = user.name
        comm.author_email = user.email
        comm.extern = False
        comm.bug = bugnum
        comm.message += i.comment

        comm.save()
        #except:
        #    a = 1
        raise web.seeother(config.prefix + '/' + project + '/bugs/' + bugnum)
Ejemplo n.º 10
0
Archivo: doc.py Proyecto: Etenil/anvil
 def do_edit_doc(self, project, docname):
     p = self._admin_or_die(project)
     d = model.doc.Doc(name=docname)
     f = self._make_doc_form()
     if not f.validates():
         return common.render.docedit(doc=d, form=f, proj=project, htTitle="Edit document")
     i = web.input()
     d.name = normalize_name(i.title)
     d.title = i.title
     d.content = i.content
     event.add(
         username=common.session.user,
         projectname=project,
         type=event.EV_DOC,
         link=config.prefix + "/" + project + "/doc/" + doc.name,
         msg=("Document %s edited" % d.title),
     )
     d.save()
     raise web.seeother(config.prefix + "/" + project + "/doc/" + d.name)
Ejemplo n.º 11
0
Archivo: doc.py Proyecto: Etenil/anvil
 def do_new_doc(self, project):
     p = self._admin_or_die(project)
     f = self._make_doc_form()
     if not f.validates():
         return common.render.docedit(form=f, proj=project, htTitle="New document for " + p.name)
     u = model.user.User(name=common.session.user)
     i = web.input()
     doc = model.doc.Doc()
     doc.project = p.id
     doc.name = normalize_name(i.title)
     doc.title = i.title
     doc.content = i.content
     doc.author = u.id
     event.add(
         user=u.id,
         project=p.id,
         type=event.EV_DOC,
         link=config.prefix + "/" + project + "/doc/" + doc.name,
         msg=("Document %s added" % doc.title),
     )
     doc.save()
     raise web.seeother(config.prefix + "/" + project + "/doc/" + doc.name)
Ejemplo n.º 12
0
 def add_commiter(self, proj_name, commiter_name):
     proj = model.project.Project(name=proj_name)
     if proj.isadmin(common.session.user):
         try:
             commiter = model.user.User(name=commiter_name)
         except:
             return web.notfound()
         # Checking if the commiter is already linked.
         commiters = proj.get_commiters()
         for c in commiters:
             if c.id == commiter.id:
                 return web.forbidden()
         # OK, we add.
         proj.add_commiter(commiter.id)
         event.add(
             username=common.session.user,
             type=event.EV_PROJECT,
             project=proj.id,
             link=config.prefix + "/" + proj.name,
             msg=("Added user %s to project %s as commiter" % (commiter_name, proj_name)),
         )
         return ""
     else:
         return web.forbidden()