Beispiel #1
0
    def insertExampleData(self):
        self.getSession()
        g1 = Group("Group 1")
        g2 = Group("Group 2")
        g2.fav = True

        t1 = Track("Bob", "Hello World!", False, 1)
        t2 = Track("Joe", "How are you doing?", True, 3)
        t3 = Track("Jim", "Can't stop dancing", False, 5)
        t4 = Track("Tom", "A simple melody", True, 9)

        gt1_1 = GroupTrack(1, 0, 100)
        gt1_1.track = t1
        gt1_2 = GroupTrack(2, 100, 200)
        gt1_2.track = t2
        g1.grouptracks.append(gt1_1)
        g1.grouptracks.append(gt1_2)

        gt2_2 = GroupTrack(1, 0, 200)
        gt2_2.track = t2
        gt2_3 = GroupTrack(2, 200, 150)
        gt2_3.track = t3
        g2.grouptracks.append(gt2_2)
        g2.grouptracks.append(gt2_3)

        self.session.add_all([g1, g2, t1, t2, t3, t4, gt1_1, gt1_2, gt2_2, gt2_3])
        self.session.commit()
Beispiel #2
0
    def newgroup(self, name):
        '''
        create a group and insert it to the list in the position
        '''
        self._checksession()

        g = Group(name)
        g.fav = True
        self.lst.append(g)
        self.session.add(g)
        self.session.commit()

        self.resort()

        return self.lst.index(g)
Beispiel #3
0
    def store(self, stats):
        '''
        store every item in the list according to the data in it
        this might create a group, grouptracks and tracks
        '''
        ss = self.model.getSession()

        gg = None
        if not self.name is None and self.name.strip() != "":
            gg = Group(self.name)
            gg.fav = self.fav
            ss.add(gg)
            ss.flush()
            ss.merge(gg) # merge the idno

        for ee in self.lst:
            tt = None
            if ee.track == True:
                tt = ee.createTrack()
                ss.add(tt)
                stats.inctotal()

            elif ee.track != None:
                ee.applyToTrack()
                tt = ee.track

            if tt != None and gg != None:
                gt = ee.createGroupTrack()
                ss.add(gt)
                gt.track = tt
                gg.grouptracks.append(gt)

        ss.commit()

        if gg:
            if ((gg.idno is None) or (gg.idno == 0) or (not isinstance(gg.idno, int))):
                raise Exception("IDNO == None or something else")
            return gg.idno
        return None