示例#1
0
def edit_person(person_id):
    p = session.query(Person).get(person_id)
    img = (session.query(Image).from_statement(text('SELECT * '
                                                    'FROM image '
                                                    '   INNER JOIN images_people '
                                                    '    ON image.ImageId = images_people.ImageId '
                                                    '   INNER JOIN person ON images_people.PersonId = person.PersonId '
                                                    ' WHERE person.PersonId = {0}'
                                                    ' ORDER BY RANDOM()'.format(person_id))).first()).File_Path
    instagram_feed = get_instagram(p.InstagramUserName)
    if not instagram_feed:
        instagram_feed = []

    num_images = Stats.get_images_with_person(p.PersonId)
    percentage = Stats.get_images_with_person_percent(p.PersonId)
    ranking = Stats.get_person_ranking(p.PersonId)

    return render_template('people/editPerson.jade', title='Edit ' + p.Name,
                           person=p,
                           instagram=instagram_feed,
                           img=img,
                           images=num_images,
                           percentage=percentage,
                           ranking=ranking)
示例#2
0
 def test_get_images_with_people(self):
     result = Stats.get_images_with_people()
     self.assertIsNotNone(result)
     self.assertGreater(result, 0)
示例#3
0
 def test_get_total_images(self):
     result = Stats.get_total_images()
     self.assertIsNotNone(result)
     self.assertGreater(result, 0)
示例#4
0
 def test_get_total_people(self):
     result = Stats.get_total_people()
     self.assertIsNotNone(result)
     self.assertGreater(result, 0)
示例#5
0
 def test_get_stats_images_tags(self):
     result = Stats.get_stats_images_tags()
     self.assertIsNotNone(result)
示例#6
0
 def test_get_images_with_tag(self):
     tag = 1
     result = Stats.get_images_with_tag(tag)
     self.assertIsNotNone(result)
     self.assertGreater(result, 0)
示例#7
0
 def test_get_people_ranking(self):
     person = 1
     result = Stats.get_person_ranking(person)
     self.assertIsNotNone(result)
示例#8
0
 def test_get_stats_images_people(self):
     result = Stats.get_stats_images_people()
     self.assertIsNotNone(result)
示例#9
0
 def test_get_images_with_person_percent(self):
     person = 1
     result = Stats.get_images_with_person_percent(person)
     self.assertIsNotNone(result)
     self.assertGreater(result, 0)