Ejemplo n.º 1
0
    def multiedit(self, *args, **kw):
        pname = request.environ['PATH_INFO'].split('/')[1]
        alltags = [tag for tag in DBSession.query(Tags).order_by('name').all()]
        principals = DBSession.query(Group).get(3)
        owners = DBSession.query(Group).get(2)
        come_from = request.headers['Referer']
        if kw:
            try:
                if isinstance(kw['argv'], basestring):
                    argv = [kw['argv']]
                else:
                    argv = [id for id in kw['argv']]
            except Exception:
                argv = None
            try:
                if kw.has_key('notes') != u'':
                    notes = kw['notes']
                else:
                    notes = None
            except Exception:
                notes = None
            try:
                priority = int(kw['priority'])
            except Exception:
                priority = None
            if argv:
                userid = request.identity['repoze.who.userid']
                for arg in argv:
                    try:
                        if isinstance(kw['text_tags'], basestring):
                            tagi = [
                                DBSession.query(Tags).get(int(kw['text_tags']))
                            ]
                        else:
                            tagi = [
                                DBSession.query(Tags).get(int(id))
                                for id in kw['text_tags']
                            ]
                    except Exception:
                        tagi = None
                    scompound = DBSession.query(SCompound).get(int(arg))
                    shistory = SHistory()
                    shistory.gid = scompound.mol.gid
                    shistory.user = userid
                    shistory.status = u'Multi - edit'
                    shistory.changes = u''
                    if kw.has_key('owner') and kw['owner'] != u'None' and kw[
                            'owner'] != scompound.owner:
                        scompound.owner = kw['owner']
                        shistory.changes += u' Właściciel: ' + kw['owner'] + ';'
                    if kw.has_key(
                            'principal') and kw['principal'] != u'None' and kw[
                                'principal'] != scompound.principal:
                        scompound.principal = kw['principal']
                        shistory.changes += u' Odbiorca: ' + kw[
                            'principal'] + ';'
                    if priority and priority != scompound.priority:
                        scompound.priority = int(kw['priority'])
                        shistory.changes += u'; Priorytet: ' + kw[
                            'priority'] + ';'
                        pcompound = DBSession.query(PCompound).get(
                            scompound.pid)
                        if pcompound:
                            pcompound.priority = int(kw['priority'])
                            phistory = PHistory()
                            phistory.project = pname
                            phistory.date = datetime.now().strftime(
                                "%Y-%m-%d %H:%M:%S")
                            phistory.user = userid
                            phistory.status = 'Priorytet'
                            phistory.changes = u'Priority: ' + kw['priority']
                            pcompound.history += [phistory]
                            DBSession.add(phistory)
                    if tagi and scompound.mol.tags != tagi:
                        scompound.mol.tags = tagi
                        shistory.changes += u' Tags: '
                        for tag in tagi:
                            shistory.changes += str(tag.name) + ';'
                    if notes and notes != scompound.notes:
                        scompound.notes = notes
                        shistory.changes += u' Notes: ' + notes
                    scompound.history += [shistory]
                    DBSession.add(shistory)
                    DBSession.flush()
                    #transaction.commit()
                if kw.has_key('come_from'):
                    come_from = kw['come_from']
                else:
                    come_from = request.headers['Referer']
                flash(l_(u'Task completed successfully'))
                redirect(come_from)

        return dict(alltags=alltags,
                    args=args,
                    users=principals.users,
                    owners=owners.users,
                    come_from=come_from,
                    page='kierownik',
                    pname=pname)
Ejemplo n.º 2
0
 def multiedit(self, *args, **kw):
     pname = request.environ['PATH_INFO'].split('/')[1]
     alltags =[tag for tag in DBSession.query(Tags).order_by('name').all() ]
     principals = DBSession.query (Group).get(3)
     owners = DBSession.query (Group).get(2)
     come_from = request.headers['Referer']
     if kw:
         try:
             if isinstance(kw['argv'], basestring):
                 argv = [kw['argv']]
             else:
                 argv = [id for id in kw['argv']]
         except Exception:
             argv = None
         try:
             if kw.has_key('notes') != u'':
                 notes = kw['notes']
             else:
                 notes = None
         except Exception:
             notes = None
         try:
             priority = int(kw['priority'])
         except Exception:
             priority = None
         if argv:
             userid = request.identity['repoze.who.userid']
             for arg in argv:
                 try:
                     if isinstance(kw['text_tags'], basestring):
                         tagi = [DBSession.query( Tags ).get(int(kw['text_tags']))]
                     else:
                         tagi = [DBSession.query( Tags ).get(int(id)) for id in kw['text_tags']]
                 except Exception:
                     tagi = None
                 scompound = DBSession.query(SCompound).get(int(arg))
                 shistory = SHistory()
                 shistory.gid = scompound.mol.gid
                 shistory.user = userid
                 shistory.status = u'Multi - edit'
                 shistory.changes = u''
                 if kw.has_key('owner') and kw['owner'] != u'None' and kw['owner'] != scompound.owner:
                     scompound.owner = kw['owner']
                     shistory.changes += u' Właściciel: ' + kw['owner'] + ';'
                 if kw.has_key('principal') and kw['principal'] != u'None' and kw['principal'] != scompound.principal:
                     scompound.principal = kw['principal']
                     shistory.changes += u' Odbiorca: ' + kw['principal'] + ';'
                 if priority and priority != scompound.priority:
                     scompound.priority = int(kw['priority'])
                     shistory.changes += u'; Priorytet: ' + kw['priority'] + ';'
                     pcompound = DBSession.query(PCompound).get(scompound.pid)
                     if pcompound:
                         pcompound.priority = int(kw['priority'])
                         phistory = PHistory()
                         phistory.project = pname
                         phistory.date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                         phistory.user = userid
                         phistory.status = 'Priorytet'
                         phistory.changes = u'Priority: ' + kw['priority']
                         pcompound.history += [phistory]
                         DBSession.add(phistory)
                 if tagi and scompound.mol.tags != tagi:
                     scompound.mol.tags = tagi
                     shistory.changes += u' Tags: '
                     for tag in tagi:
                         shistory.changes += str(tag.name) + ';'
                 if notes and notes != scompound.notes:
                     scompound.notes = notes
                     shistory.changes += u' Notes: ' + notes
                 scompound.history += [shistory]
                 DBSession.add(shistory)
                 DBSession.flush()
                 #transaction.commit()
             if kw.has_key('come_from'):
                 come_from = kw['come_from']
             else:
                 come_from = request.headers['Referer']
             flash(l_(u'Task completed successfully'))
             redirect(come_from)
             
     return dict(alltags=alltags, args=args, users=principals.users, owners=owners.users, come_from=come_from, page='kierownik', pname=pname)
Ejemplo n.º 3
0
    def put(self, *args, **kw):
        pname = request.environ['PATH_INFO'].split('/')[1]
        sid = int(args[0])
        userid = request.identity['repoze.who.userid']
        scompound = DBSession.query(SCompound).get(sid)
        shistory = SHistory()
        shistory.gid = scompound.mol.gid
        shistory.user = userid
        shistory.status = u'Edycja'
        schanges = u''
        try:
            reason = kw['reason']
        except Exception:
            reason = None
            pass
        if reason and reason != u'':
            schanges += u'UWAGA! niestandardowa zmiana z powodu:' + reason
            etap = int(kw['etap'])
            etap_max = int(kw['etap_max'])
            if etap < etap_max:
                scompound.effort[-1].etap = etap
                scompound.effort[-1].etap_max = etap_max
                scompound.status = DBSession.query(SStatus).get(2)
                schanges += u'; Bieżący etap: ' + str(etap)
                schanges += u'; Liczba etapow: ' + str(etap_max)
            else:
                flash(
                    l_(u'Completed step must be smaller by 2 than the number of stages'
                       ), 'error')
                redirect(request.headers['Referer'])
#        scompound.status_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

        if kw.has_key('lso') and kw['lso'] != scompound.lso:
            scompound.lso = kw['lso']
            schanges += u'; LSO: ' + kw['lso']
        if kw.has_key('notes') and kw['notes'] != scompound.notes:
            scompound.notes = kw['notes']
            schanges += u';Notes: ' + kw['notes']
        try:
            filename = kw['loadfile'].filename
            import os
            filename = os.path.basename(filename)
        except Exception as msg:
            filename = None
            pass
        try:
            reaction_file = kw['reaction'].filename
            import os
            reaction_file = os.path.basename(reaction_file)
        except Exception as msg:
            reaction_file = None
            pass

        if kw['owner'] != scompound.owner:
            scompound.owner = kw['owner']
            schanges += u'; Wlasciciel:' + kw['owner']
        if kw['principal'] != scompound.principal:
            scompound.principal = kw['principal']
            schanges += u'; Odbiorca:' + kw['principal']
        if kw.has_key('priority') and kw['priority'] != u'':
            scompound.priority = int(kw['priority'])
            schanges += u'; Priorytet:' + kw['priority']
            pcompound = DBSession.query(PCompound).get(scompound.pid)
            if pcompound:
                pcompound.priority = int(kw['priority'])
                phistory = PHistory()
                phistory.project = pname
                phistory.date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                phistory.user = userid
                phistory.status = 'Priorytet'
                phistory.changes = u'Priority: ' + kw['priority']
                pcompound.history += [phistory]
                DBSession.add(phistory)

        if filename or reaction_file:
            if filename:
                number = DBSession.query(SFiles).count() + 1
                newfilename = str(number) + '_' + userid + '_' + str(
                    sid) + '_' + filename
                newfilename.replace(' ', '_')
                f_path = os.path.join(files_dir, newfilename)
                try:
                    f = file(f_path, "w")
                    f.write(kw['loadfile'].value)
                    f.close()
                except Exception as msg:
                    flash(l_(msg), 'error')
                    redirect(request.headers['Referer'])
                sfile = SFiles()
                sfile.name = filename
                sfile.filename = newfilename
                if kw['opis']:
                    sfile.description = kw['opis']
                schanges += u'; Plik: ' + filename + u' ( ' + newfilename + u' )'
                DBSession.add(sfile)
            if reaction_file:
                number2 = DBSession.query(SFiles).count() + 1
                newfilename2 = str(number2) + '_' + userid + '_' + str(
                    sid) + '_' + reaction_file
                newfilename2.replace(' ', '_')
                f_path2 = os.path.join(files_dir, newfilename2)
                try:
                    f2 = file(f_path2, "w")
                    f2.write(kw['reaction'].value)
                    f2.close()
                except Exception as msg:
                    flash(l_(msg), 'error')
                    redirect(request.headers['Referer'])
                reaction_sfile = SFiles()
                reaction_sfile.name = reaction_file
                reaction_sfile.filename = newfilename2
                schanges += u'; Sciezka reakcji: ' + reaction_file + u' ( ' + newfilename2 + u' )'
                DBSession.add(reaction_sfile)
            shistory.changes = schanges
            scompound.history += [shistory]

            DBSession.add(shistory)
            DBSession.flush()
            #transaction.commit()
            scompound2 = DBSession.query(SCompound).get(sid)
            if filename:
                sfile2 = [sfile]
                sfile2 += scompound2.filename
                scompound2.filename = sfile2
            if reaction_file:
                reaction_sfile = [reaction_sfile]
                #                reaction_sfile += scompound2.reaction
                scompound2.reaction = reaction_sfile
        else:
            shistory.changes = schanges
            scompound.history += [shistory]
            DBSession.add(shistory)
            DBSession.flush()

            flash(l_(u'Task completed successfully'))
        if kw and kw.has_key('come_from'):
            come_from = kw['come_from']
        else:
            come_from = request.headers['Referer']
        redirect(come_from)
Ejemplo n.º 4
0
    def put(self, *args, **kw):
        pname = request.environ['PATH_INFO'].split('/')[1]
        sid = int(args[0])
        userid = request.identity['repoze.who.userid']
        scompound = DBSession.query(SCompound).get(sid)
        shistory = SHistory()
        shistory.gid = scompound.mol.gid
        shistory.user = userid
        shistory.status = u'Edycja'
        schanges = u''
        try:
            reason = kw['reason']
        except Exception:
            reason = None
            pass
        if reason and reason != u'':
            schanges += u'UWAGA! niestandardowa zmiana z powodu:' + reason
            etap = int(kw['etap']) 
            etap_max = int(kw['etap_max'])
            if etap < etap_max:
                scompound.effort[-1].etap = etap
                scompound.effort[-1].etap_max = etap_max
                scompound.status = DBSession.query( SStatus ).get(2)
                schanges += u'; Bieżący etap: ' + str(etap)
                schanges += u'; Liczba etapow: ' + str(etap_max)
            else:
                flash(l_(u'Completed step must be smaller by 2 than the number of stages'), 'error')
                redirect(request.headers['Referer'])
#        scompound.status_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        
        if kw.has_key('lso') and kw['lso'] != scompound.lso:
            scompound.lso = kw['lso']
            schanges += u'; LSO: ' + kw['lso']
        if kw.has_key('notes') and kw['notes'] != scompound.notes:
            scompound.notes = kw['notes']
            schanges += u';Notes: ' + kw['notes']
        try:
            filename = kw['loadfile'].filename
            import os
            filename = os.path.basename(filename)
        except Exception as msg:
            filename = None
            pass
        try:
            reaction_file = kw['reaction'].filename
            import os
            reaction_file = os.path.basename(reaction_file)
        except Exception as msg:
            reaction_file = None
            pass
        
        if kw['owner'] != scompound.owner:
            scompound.owner = kw['owner']
            schanges += u'; Wlasciciel:' + kw['owner']
        if kw['principal'] != scompound.principal:
            scompound.principal = kw['principal']
            schanges += u'; Odbiorca:' + kw['principal']
        if kw.has_key('priority') and kw['priority'] != u'':
            scompound.priority = int(kw['priority'])
            schanges += u'; Priorytet:' + kw['priority']
            pcompound = DBSession.query(PCompound).get(scompound.pid)
            if pcompound:
                pcompound.priority = int(kw['priority'])
                phistory = PHistory()
                phistory.project = pname
                phistory.date = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
                phistory.user = userid
                phistory.status = 'Priorytet'
                phistory.changes = u'Priority: ' + kw['priority']
                pcompound.history += [phistory]
                DBSession.add(phistory)

        if filename or reaction_file:
            if filename:
                number = DBSession.query(SFiles).count() + 1
                newfilename = str(number) + '_' + userid + '_' + str(sid) + '_' + filename
                newfilename.replace(' ', '_')
                f_path = os.path.join(files_dir, newfilename)
                try:
                    f = file(f_path, "w")
                    f.write(kw['loadfile'].value)
                    f.close()
                except Exception as msg:
                    flash(l_(msg), 'error')
                    redirect(request.headers['Referer'])
                sfile = SFiles()
                sfile.name = filename
                sfile.filename = newfilename
                if kw['opis']:
                    sfile.description = kw['opis']
                schanges += u'; Plik: ' + filename + u' ( ' + newfilename + u' )'
                DBSession.add(sfile)
            if reaction_file:
                number2 = DBSession.query(SFiles).count() + 1
                newfilename2 = str(number2) + '_' + userid + '_' + str(sid) + '_' + reaction_file
                newfilename2.replace(' ', '_')
                f_path2 = os.path.join(files_dir, newfilename2)
                try:
                    f2 = file(f_path2, "w")
                    f2.write(kw['reaction'].value)
                    f2.close()
                except Exception as msg:
                    flash(l_(msg), 'error')
                    redirect(request.headers['Referer'])
                reaction_sfile = SFiles()
                reaction_sfile.name = reaction_file
                reaction_sfile.filename = newfilename2
                schanges += u'; Sciezka reakcji: ' + reaction_file + u' ( ' + newfilename2 + u' )'
                DBSession.add(reaction_sfile)
            shistory.changes = schanges
            scompound.history += [shistory]
    
            DBSession.add(shistory)
            DBSession.flush()
            #transaction.commit()
            scompound2 = DBSession.query(SCompound).get(sid)
            if filename:
                sfile2 = [sfile]
                sfile2 += scompound2.filename
                scompound2.filename = sfile2
            if reaction_file:
                reaction_sfile = [reaction_sfile]
#                reaction_sfile += scompound2.reaction
                scompound2.reaction = reaction_sfile
        else:
            shistory.changes = schanges
            scompound.history += [shistory]
            DBSession.add(shistory)
            DBSession.flush()
        
            flash(l_(u'Task completed successfully'))
        if kw and kw.has_key('come_from'):
            come_from = kw['come_from']
        else:
            come_from = request.headers['Referer']
        redirect(come_from)