Exemplo n.º 1
0
Arquivo: bug.py Projeto: 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')
Exemplo n.º 2
0
Arquivo: bug.py Projeto: 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)