Beispiel #1
0
    def test_db(self):
        

        
        org = Organization(name='Employee owned dog library',)
        org.save()
        
        orgs = Organization.objects.all()
        #self.assertEqual(len(orgs), 1)
        #print orgs
        
        branch = Branch(organization=orgs[0], name='west branch',)
        branch.save()
        
        branches = Branch.objects.all()
        #self.assertEqual(len(branches), 1)
        #print branches
        
        item = Item(branch=branches[0], title="how to make pants", creator="mr dog", isbn="0224063782", inst_id="009094372", format="book")
        item.save()
        
        items = Item.objects.all()
        #self.assertEqual(len(items), 1)
        #print items
        
        checkin = Checkin(item=item)
        checkin.save()
        
        #checkins = Checkin.objects.all()
        #self.assertEqual(len(checkins), 1)
        #print checkins


        items = Item.objects.filter(branch=branches[0], ).order_by('checkin__checked_in_time')
        #print items.query
        
        print len(items)
        
        for item in items:
            print item
            #print item.checkin_set.all()
        
        #checkins = Checkin.objects.filter()
        
        #print len(checkins)
        
        #for checkin in checkins:
            #print checkin


        most_awesome_list = Item.objects.annotate(num_checkins=Count('checkin')).order_by('-num_checkins')[:5]
        
        for most_awesome in most_awesome_list:
            print most_awesome.title
            print most_awesome.num_checkins
Beispiel #2
0
    jsoned_response = json.loads(response)

    docs = jsoned_response["docs"][0]

    physical_format = "book"
    if "video" in docs["format"]:
        physical_format = "videofilm"
        cover_art = _get_rt_movie_poster(docs["title"])
    elif "sound" in docs["format"]:
        physical_format = "soundrecording"

    item = Item(
        branch=branch,
        title=_simple_massage_text(docs["title"]),
        creator=_simple_massage_text(docs["creator"][0]),
        unique_id=docs["id_inst"],
        catalog_id=docs["id_inst"],
        isbn=docs["id_isbn"][0],
        physical_format=docs["format"],
    )

    item.save()

    current = ThreadedTweet(item)
    current.start()

    return _simple_massage_text(docs["title"])


def _item_from_worldcat(barcode, branch):
    """Given a barcode, get metadata from worldcat"""
Beispiel #3
0
    
    docs = jsoned_response['docs'][0]
    
    physical_format = 'book'
    if 'video' in docs['format']:
        physical_format = 'videofilm'
        cover_art = _get_rt_movie_poster(docs['title'])
    elif 'sound' in docs['format']:
        physical_format = 'soundrecording'

    
    
    item = Item(branch=branch,
                title=_simple_massage_text(docs['title']),
                creator=_simple_massage_text(docs['creator'][0]),
                unique_id=docs['id_inst'],
                catalog_id=docs['id_inst'],
                isbn=docs['id_isbn'][0],
                physical_format=docs['format'],)
    
    item.save()
    
    current = ThreadedTweet(item)
    current.start()
    
    
    return _simple_massage_text(docs['title'])
    
def _item_from_worldcat(barcode, branch):
    """Given a barcode, get metadata from worldcat"""
    
Beispiel #4
0
    def test_db(self):

        org = Organization(name='Employee owned dog library', )
        org.save()

        orgs = Organization.objects.all()
        #self.assertEqual(len(orgs), 1)
        #print orgs

        branch = Branch(
            organization=orgs[0],
            name='west branch',
        )
        branch.save()

        branches = Branch.objects.all()
        #self.assertEqual(len(branches), 1)
        #print branches

        item = Item(branch=branches[0],
                    title="how to make pants",
                    creator="mr dog",
                    isbn="0224063782",
                    inst_id="009094372",
                    format="book")
        item.save()

        items = Item.objects.all()
        #self.assertEqual(len(items), 1)
        #print items

        checkin = Checkin(item=item)
        checkin.save()

        #checkins = Checkin.objects.all()
        #self.assertEqual(len(checkins), 1)
        #print checkins

        items = Item.objects.filter(
            branch=branches[0], ).order_by('checkin__checked_in_time')
        #print items.query

        print len(items)

        for item in items:
            print item
            #print item.checkin_set.all()

        #checkins = Checkin.objects.filter()

        #print len(checkins)

        #for checkin in checkins:
        #print checkin

        most_awesome_list = Item.objects.annotate(
            num_checkins=Count('checkin')).order_by('-num_checkins')[:5]

        for most_awesome in most_awesome_list:
            print most_awesome.title
            print most_awesome.num_checkins