Ejemplo n.º 1
0
def edit_venue(venue_id: int) -> str:
    form = VenueForm()
    venue_data = Venue.query.filter_by(id=venue_id).one()
    venue_dict = model_to_dict(venue_data)
    return render_template("forms/edit_venue.html",
                           form=form,
                           venue=venue_dict)
Ejemplo n.º 2
0
def edit_artist(artist_id: int) -> str:
    form = ArtistForm()
    artist_data = Artist.query.filter_by(id=artist_id).one()
    artist_dict = model_to_dict(artist_data)
    return render_template("forms/edit_artist.html",
                           form=form,
                           artist=artist_dict)
Ejemplo n.º 3
0
def one_hundred_report(regn):
    """
    Get data about organization one_hundred_report through it REGN
    """
    app.logger.debug('GET REGN: {}'.format(regn))
    resp = [model_to_dict(inst) for inst in \
        app.db.query(OneHundredReport).filter(OneHundredReport.REGN == regn)]
    return jsonify(resp)
Ejemplo n.º 4
0
def show_venue(venue_id: int) -> str:
    venue_data = Venue.query.filter_by(id=venue_id).one()
    venue_dict = model_to_dict(venue_data)
    venue_shows = venue_data.shows

    shows_dict = compose_show_attributes(venue_shows)
    venue_dict.update(shows_dict)
    # FIXME: fix GET /venues/None HTTP/1.0" 405
    return render_template("pages/show_venue.html", venue=venue_dict)
Ejemplo n.º 5
0
def show_artist(artist_id: int) -> str:
    artist_data = Artist.query.filter_by(id=artist_id).one()
    artist_dict = model_to_dict(artist_data)
    artist_shows = artist_data.shows

    shows_dict = compose_show_attributes(artist_shows)
    artist_dict.update(shows_dict)

    return render_template("pages/show_artist.html", artist=artist_dict)
Ejemplo n.º 6
0
 def test_a_models_and_utils(self):
     """
     test OneHundredReport model
     """
     logging.info('\nStart model test..')
     inst = OneHundredReport(**self._data)
     DB.add(inst)
     res = DB.query(OneHundredReport).all()
     model = res.pop()
     self.assertEqual(str(model), '1_1_2010-05-01')
     self.assertDictEqual(model_to_dict(model), \
         {'REGN': 1, 'PLAN': 'А', 'NUM_SC': '10207', 'A_P': '2', 'VR': 23064358, 'VV':\
         0, 'VITG': 23064358.0, 'ORA': 0, 'OVA': 0, 'OITGA': 0.0, 'ORP': 0, 'OVP': 0,\
         'OITGP': 0.0, 'IR': 23064358, 'IV': 0, 'IITG': 23064358.0, 'DT':\
         '2010-05-01', 'PRIZ': 1, 'P_K':1})
Ejemplo n.º 7
0
 def send_model_response(self, instance_or_query, follow=False):
     """use this for returning model response"""
     uri_kwargs = {
         'resource_name': self.resource_name
     }
     models_dict = model_to_dict(
         instance_or_query,
         self.model_response_uris,
         uri_kwargs,
         follow=follow
     )
     self.set_status(200)
     self.set_header("Content-Type", "application/json")
     self.write(json.dumps(models_dict, cls=TornadoJSONEncoder))
     self.finish()
Ejemplo n.º 8
0
def venues() -> str:
    groups = (Venue.query.with_entities(Venue.city, Venue.state,
                                        func.array_agg(Venue.id)).group_by(
                                            Venue.city, Venue.state).all())

    data = []
    for group in groups:
        venues = []
        for venue_id in group[2]:
            venue_data = Venue.query.filter_by(id=venue_id).one()
            venue_dict = model_to_dict(venue_data)
            venue_dict = filter_dict_by_keys(venue_dict, ["id", "name"])

            venue_shows = venue_data.shows
            shows_dict = compose_show_attributes(venue_shows)
            shows_dict = {
                "num_upcoming_shows": shows_dict["upcoming_shows_count"]
            }

            venue_dict.update(shows_dict)
            venues.append(venue_dict)
        data.append({"city": group[0], "state": group[1], "venues": venues})

    return render_template("pages/venues.html", areas=data)
Ejemplo n.º 9
0
 def as_dict(self):
     """Return variables ready made for a URL callback"""
     return model_to_dict(self)
Ejemplo n.º 10
0
def shows() -> str:
    shows_data = Show.query.all()
    shows_dict = [model_to_dict(show) for show in shows_data]
    return render_template("pages/shows.html", shows=shows_dict)