Example #1
0
 def test_delete_by_admin(self):
     url = self.random()
     Venue(name = self.random(), url = url, city = self.chennai, location = db.GeoPt(lat = 0, lon = 0)).put()
     self.assertTrue(Venue.get_by_url(url))
     venue_data = dict(action ='delete')
     self.admin_app.post(self.venue_route+url, venue_data)
     self.assertFalse(Venue.get_by_url(url))
Example #2
0
    def post(self, *args, **kwargs):
        venue_list = self.get_angular_argument('venue_list')

        if not venue_list:
            return

        Venue.update_position(venue_list)
Example #3
0
class ExtendedTestCase(unittest.TestCase): 
    public_app = TestApp(public_main.createApp())
    admin_app = TestApp(admin_main.createApp())
    _login_stubs = StubOutForTesting()
    stubs = StubOutForTesting()
    
    def random(self):
        import hashlib, time
        return hashlib.md5((time.clock()*random.random()).__str__()).hexdigest()
    
    def setUp(self):
        self.make_test_data()
        self.login()
        self.mox = Mox()
      
    def tearDown(self):
        self.logout()
        self.stubs.UnsetAll()
        for model in [City, Company, Performance, Show, Venue]:
            for datum in model.all():
                datum.delete()

    def login(self, user="******", admin=True):
        self._login_stubs.Set(users, 'get_current_user', lambda user = user : users.User(user))
        self._login_stubs.Set(users, 'is_current_user_admin', lambda admin = admin : admin)

    def logout(self):
        self._login_stubs.UnsetAll()

    def make_test_data(self):
        now = datetime.datetime.now()
        self.now = datetime.datetime(year = now.date().year, month = now.date().month, day = now.date().day, hour = now.time().hour, minute = now.time().minute)
        self.one_day_later = self.now + datetime.timedelta(days=1)
        self.two_days_later = self.now + datetime.timedelta(days=2)
        self.three_days_later = self.now + datetime.timedelta(days=3)
        
        self.evam = Company(name='Evam Theatre Company', url='evam')
        self.evam.put()
        self.hamlet = Show(name='Hamlet', url='hamlet', company=self.evam)
        self.hamlet.put()
        self.chennai = City(name='Chennai', url='chennai')
        self.chennai.put()
        self.bangalore = City(name='Bangalore', url='bangalore')
        self.bangalore.put()
        self.lady_andal = Venue(name='Lady Andal', url='lady_andal', city=self.chennai)
        self.lady_andal.put()
        
    def make_performance(self, show, venue, dt):
        perf = Performance(show=show, venue=venue, utc_date_time=dt)
        perf.put()
        return perf
Example #4
0
def create_venue_submission():
    genres = request.form.getlist("genres")
    data = request.form.to_dict()
    data["genres"] = genres
    data["seeking_talent"] = (True if data.get("seeking_talent", False) is "y"
                              else False)
    venue = Venue(**data)
    result = venue.save_to_db()
    if result["error"]:
        flash("An error occurred. Venue " + data["name"] +
              " could not be listed.")
        abort(500)
    flash("Venue " + data["name"] + " was successfully listed!")
    return render_template("pages/home.html")
Example #5
0
 def create_venue(self, *args, **kwargs):
     """Create venue for Organizer"""
     args[0]["organizer_id"] = self.id
     venue = Venue()
     for key, value in args[0].items():
         setattr(venue, key, value)
     try:
         venue.save()
         return venue
     except exc.IntegrityError as e:
         print("venue")
         errorInfo = e.orig.args
         print(errorInfo[0])  # This will give you error code
         print(errorInfo[1])  # This will give you error message
Example #6
0
def create_venue():
    validate_coordinates(request.json.get('latitude', None), request.json.get('longitude', None))
    venue = Venue(from_dict=request.json)
    venue.departementCode = 'XX'  # avoid triggerring check on this
    siret = request.json.get('siret')
    if not siret:
        venue.generate_validation_token()
    save_venue(venue)

    if not venue.isValidated:
        try:
            send_venue_validation_email(venue, send_raw_email)
        except MailServiceException as e:
            app.logger.error('Mail service failure', e)

    return jsonify(as_dict(venue, includes=VENUE_INCLUDES)), 201
Example #7
0
def card_payment_performing(payment_json, amount, order, put_order=True):
    binding_id = payment_json.get('binding_id')
    client_id = payment_json.get('client_id')
    return_url = payment_json.get('return_url')
    if not binding_id or not client_id or not return_url:
        return False, u'Карта не найдена'

    legal = Venue.get(order.venue_id).legal.get()

    try:
        success, result = alfa_bank.create_simple(legal.alfa_login, legal.alfa_password, amount, order.key.id(), return_url,
                                                  client_id)
    except Exception as e:
        send_error("Alfa error", "Alfa failure", str(e))
        success, result = False, u'Не удалось произвести оплату'

    if not success:
        return success, result

    order.payment_id = result
    if put_order:
        order.put()
    success, error = alfa_bank.hold_and_check(legal.alfa_login, legal.alfa_password, order.payment_id, binding_id)
    if not success:
        error = u"Не удалось произвести оплату. %s" % error
    return success, error
Example #8
0
def search_venues():
    search_term = request.form.get("search_term", "")
    results = Venue.search(search_term)
    return render_template(
        "pages/search_venues.html",
        results=results,
        search_term=search_term,
    )
Example #9
0
 def update(self, venue_url = None):
     venue = Venue.get_by_url(venue_url)
     if not venue: raise Exception("That venue doesn't exist")
     venue.name=self.read('name')
     venue.url=self.read('url')
     venue.city=self.check_city()
     venue.location=db.GeoPt(lat=self.read('lat'), lon = self.read('lon'))
     venue.put()
     self.redirect('/_admin/venue/')
Example #10
0
def delete_venue(venue_id):
    venue = Venue.get_by_id(venue_id)
    venue_name = venue.name
    result = venue.delete_from_db()
    if result["error"]:
        flash("An error occurred. Venue " + venue_name +
              " could not be deleted.")
        abort(500)
    flash("Venue " + venue_name + " was successfully deleted!")
    return render_template("pages/home.html")
Example #11
0
def get_company_cities():
    companies = AutomationCompany.query(AutomationCompany.status == STATUS_AVAILABLE).fetch()
    if companies:
        return [city.dict() for city in ProxyCity.query(ProxyCity.status == STATUS_AVAILABLE).fetch()]
    else:
        found = False
        for venue in Venue.query(Venue.active == True).fetch():
            if MenuItem.query(MenuItem.restrictions.IN((venue.key,))).get():
                found = True
        if not found:
            return []
        cities = Venue.get_cities()
        if len(cities) > 1:
            return [{
                'city': city,
                'id': base64.b64encode(city.encode('utf-8'))
            } for city in cities]
        else:
            return []
Example #12
0
def done_order(order, namespace, with_push=True):
    total_cash_back = 0
    point_sum = 0
    if config.WALLET_ENABLED:
        total_cash_back = order.activate_cash_back()
    if config.GIFT_ENABLED:
        point_sum = order.activate_gift_points()

    for share_gift in order.shared_gift_details:
        share_gift.gift.get().deactivate()

    for performing in order.promo_code_performings:
        performing = performing.get()
        promo_code = performing.promo_code.get()
        if not promo_code.persist:
            performing.close()

    if order.subscription_details:
        subscription = order.subscription_details.subscription.get()
        subscription.finalize_payment_if_needed()

    order.status = READY_ORDER
    order.email_key_done = None
    order.email_key_cancel = None
    order.email_key_postpone = None
    order.email_key_confirm = None
    order.actual_delivery_time = datetime.utcnow()

    client_key = Client.get(order.client_id).key
    shared_promo = SharedPromo.query(
        SharedPromo.recipient == client_key,
        SharedPromo.status == SharedPromo.READY).get()
    if shared_promo:
        shared_promo.deactivate(namespace_manager.get_namespace())

    if order.has_card_payment:
        legal = Venue.get(order.venue_id).legal.get()
        alfa_bank.deposit(legal.alfa_login, legal.alfa_password,
                          order.payment_id, 0)  # TODO check success
    elif order.has_paypal_payment:
        paypal.capture(order.payment_id,
                       order.total_sum - order.wallet_payment)

    order.put()

    if with_push:
        text = u"Заказ №%s выдан." % order.number
        if point_sum:
            text += u" Начислены баллы в размере %s." % point_sum
        if total_cash_back:
            text += u" Начислены бонусы на Ваш счет в размере %s." % (
                total_cash_back / 100.0)
        OrderPush(text, order, namespace).send(silent=True)
        if order.version >= 4:
            send_review_push(order)
Example #13
0
def create_venue_submission():
    error = False
    venue_name = request.get_json()['name']
    try:
        body = {}
        venue = Venue(name=venue_name)
        city_name = request.get_json()['city']
        state_id = request.get_json()['state']
        genres = request.get_json()['genres']
        city = City.query.filter(City.name == city_name).first()

        if city == None:
            city = City(name=city_name)
            city.state_id = state_id

        venue.city = city
        venue.phone = request.get_json()['phone']
        venue.facebook_link = request.get_json()['facebook_link']

        for genre_id in genres:
            genre = Genre.query.get(genre_id)
            venue.genres.append(genre)
        db.session.add(venue)
        db.session.commit()
        body['id'] = venue.id
        body['name'] = venue.name

    except:
        print("Oops!", sys.exc_info(), "occured.")
        error = True
        db.session.rollback()

    finally:
        db.session.close()

    if error:
        flash('venue ' + venue_name + ' could not be listed.')
        abort(400)
    else:
        flash('venue ' + venue_name + ' was successfully listed!')

    return jsonify(body)
Example #14
0
    def post(self, order_id):
        order = self.user.order_by_id(int(order_id))
        if order.status != NEW_ORDER:
            self.abort(400)

        new_venue_id = self.request.get_range('venue_id')
        new_venue = Venue.get_by_id(new_venue_id)
        if not new_venue:
            self.abort(400)

        move_order(order, new_venue)

        self.render_json({})
Example #15
0
def edit_venue_submission(venue_id):
    genres = request.form.getlist("genres")
    data = request.form.to_dict()
    data["genres"] = genres
    data["seeking_talent"] = (True if data.get("seeking_talent", False) is "y"
                              else False)
    result = Venue.update(venue_id, data)
    if result["error"]:
        flash("An error occurred. Venue " + data["name"] +
              " could not be updated.")
        abort(500)
    flash("Venue " + data["name"] + " was successfully updated!")
    return redirect(url_for("venues.show_venue", venue_id=venue_id))
Example #16
0
 def test_venue_creation_by_admin(self):
     name = self.random()
     url = self.random()
     lat = 4
     lon = 5
     venue_data = dict(name = name, url = url, lat = lat, lon = lon, action='create', city = self.chennai.url)
     self.admin_app.post(self.venue_route, venue_data)
     venue = Venue.get_by_url(url)
     self.assertTrue(venue)
     self.assertEqual(name,venue.name)
     self.assertEqual(lat,venue.location.lat)
     self.assertEqual(lon,venue.location.lon)
     self.assertEqual(self.chennai.url,venue.city.url)
Example #17
0
def _get_delivery_types(venue):
    if venue:
        deliveries = [
            dt.delivery_type for dt in venue.delivery_types
            if dt.status == STATUS_AVAILABLE
        ]
    else:
        deliveries = [
            venue_delivery.delivery_type for venue in Venue.fetch_venues()
            if venue.active for venue_delivery in venue.delivery_types
            if venue_delivery.status == STATUS_AVAILABLE
        ]
        deliveries = list(set(deliveries))
    return deliveries
def _handle_auto(order):
    info = [
        ("id", order.key.id()),
        ("payment type", order.payment_type_id),
        ("payment id", order.payment_id)
    ]
    to_delete = False
    if order.has_card_payment:
        try:
            # check payment status
            legal = Venue.get_by_id(int(order.venue_id)).legal.get()
            status = alfa_bank.check_extended_status(legal.alfa_login, legal.alfa_password,
                                                     order.payment_id)["alfa_response"]
            info.append(("status check result", status))

            # if status check was successful:
            if str(status.get("errorCode", '0')) == '0':
                # money already deposited -- do not delete
                if status['orderStatus'] == 2:
                    info.append(("ERROR", "deposited"))
                # money approved -- reverse
                elif status['orderStatus'] == 1:
                    reverse_result = alfa_bank.reverse(legal.alfa_login, legal.alfa_password,
                                                       order.payment_id)
                    info.append(("reverse result", reverse_result))
                    if str(reverse_result.get('errorCode', '0')) == '0':
                        to_delete = True
                # any other status is OK to delete
                else:
                    to_delete = True
        except Exception as e:
            info.append(("exception", repr(e)))
    elif order.has_paypal_payment:
        try:
            # authorization exists (we have payment_id) and should be non-void
            void_success, void_error = paypal.void(order.payment_id)
            info.append(("void successful?", void_success))
            if void_success:
                to_delete = True
            else:
                info.append(("void error", void_error))
        except Exception as e:
            info.append(("exception", repr(e)))
    else:
        to_delete = True
    if to_delete:
        order.key.delete()
        info.append(("deleted", True))
    return info
Example #19
0
    def post(self, *args, **kwargs):
        """新建"""
        venue_name = self.get_angular_argument('name')

        if not venue_name:
            self.on_error(**ErrorCodeMessage.venue_name_illegal)
            return

        venue = Venue.add(venue_name)

        if not venue:
            self.on_error(**ErrorCodeMessage.database_error)
            return

        self.on_success(venue.to_dict())
Example #20
0
 def test_venue_edit_by_admin(self):
     name = self.random()
     url = self.random()
     lat = 4
     lon = 5
     Venue(name = self.random(), url = url, city = self.chennai, location = db.GeoPt(lat = 0, lon = 0)).put()
     new_url = self.random()
     venue_data = dict(name = name, url = new_url, lat = lat, lon = lon, action='update', city = self.bangalore.url)
     self.admin_app.post(self.venue_route+url, venue_data)
     venue = Venue.get_by_url(new_url)
     self.assertTrue(venue)
     self.assertEqual(name,venue.name)
     self.assertEqual(lat,venue.location.lat)
     self.assertEqual(lon,venue.location.lon)
     self.assertEqual(self.bangalore.url,venue.city.url)
Example #21
0
def _get_config(admin):
    venue = admin.venue.get() if admin.venue else None
    active_venues = Venue.query(Venue.active == True).fetch()
    return {
        'venue': venue.dict() if venue else None,
        'login': admin.login,
        'app_name': config.APP_NAME,
        'app_kind': config.APP_KIND,
        'delivery_types': _get_delivery_types(venue),
        'venues': [v.dict() for v in active_venues],
        'venue_id': admin.venue.id() if admin.venue else None,
        'google_analytics_api_key_ios': config.GOOGLE_ANALYTICS_API_KEY_IOS,
        'google_analytics_api_key_android':
        config.GOOGLE_ANALYTICS_API_KEY_ANDROID
    }
Example #22
0
 def create(self, performance=None):
   show = Show.get(self.read('show_key'))
   if not show: raise Exception("That show doesn't exist.")
   venue = Venue.get(self.read('venue_key'))
   if not venue: raise Exception("That venue doesn't exist.")
   year = int(self.read('year'))
   month = int(self.read('month'))
   day = int(self.read('day'))
   hour = int(self.read('hour'))
   minute = int(self.read('minute'))
   Performance(show = show,
               venue = venue,
               utc_date_time = datetime.datetime(year, month, day, hour, minute) - venue.city.get_timedelta()
               ).put()
   self.get()
Example #23
0
def create_venue_submission():
    try:
        venue = Venue()
        fill_venue_data(venue)
        db.session.add(venue)
        db.session.commit()

        flash('Venue ' + request.form['name'] + ' was successfully listed!')
    except:
        print(sys.exc_info())
        db.session.rollback()
        flash('An error occurred. Venue could not be created.')
    finally:
        db.session.close()

    return render_template('pages/home.html')
Example #24
0
    def delete(self, venue_id, *args, **kwargs):
        """删除"""
        if not venue_id:
            self.on_error(**ErrorCodeMessage.venue_not_exists)
            return

        venue = Venue.init_from_venue_id(venue_id)

        if not venue:
            self.on_error(**ErrorCodeMessage.venue_not_exists)
            return

        if venue.delete():
            self.on_success()
        else:
            self.on_error(**ErrorCodeMessage.database_error)
Example #25
0
    def history_dict(self):
        dct = self.status_dict()
        if self.delivery_slot_id > 0:
            delivery_slot = DeliverySlot.get_by_id(self.delivery_slot_id)
        else:
            delivery_slot = None
        gifts = self.grouped_item_dict(self.gift_details, gift=True)
        gifts.extend(self.grouped_item_dict(self.order_gift_details))

        venue = Venue.get(self.venue_id)

        dct.update({
            "delivery_type":
            self.delivery_type,
            "address":
            self.address.dict() if self.address else None,
            "delivery_time":
            timestamp(self.delivery_time) if self.delivery_time else 0,
            "delivery_time_str":
            self.delivery_time_str,
            "delivery_slot":
            delivery_slot.dict() if delivery_slot else None,
            "delivery_slot_str":
            delivery_slot.name if delivery_slot
            and delivery_slot.slot_type == DeliverySlot.STRINGS else None,
            "payment_type_id":
            self.payment_type_id,
            "total":
            self.total_sum,
            "menu_sum":
            sum([
                item_detail.price / 100.0 for item_detail in self.item_details
            ]),
            "wallet_payment":
            self.wallet_payment,
            "delivery_sum":
            self.delivery_sum,
            "venue_id":
            str(self.venue_id),
            "venue":
            None if not venue else venue.admin_dict(),
            "items":
            self.grouped_item_dict(self.item_details),
            "gifts":
            gifts
        })
        return dct
Example #26
0
 def make_test_data(self):
     now = datetime.datetime.now()
     self.now = datetime.datetime(year = now.date().year, month = now.date().month, day = now.date().day, hour = now.time().hour, minute = now.time().minute)
     self.one_day_later = self.now + datetime.timedelta(days=1)
     self.two_days_later = self.now + datetime.timedelta(days=2)
     self.three_days_later = self.now + datetime.timedelta(days=3)
     
     self.evam = Company(name='Evam Theatre Company', url='evam')
     self.evam.put()
     self.hamlet = Show(name='Hamlet', url='hamlet', company=self.evam)
     self.hamlet.put()
     self.chennai = City(name='Chennai', url='chennai')
     self.chennai.put()
     self.bangalore = City(name='Bangalore', url='bangalore')
     self.bangalore.put()
     self.lady_andal = Venue(name='Lady Andal', url='lady_andal', city=self.chennai)
     self.lady_andal.put()
Example #27
0
    def post(self, *args, **kwargs):
        venue_id = self.get_angular_argument('id')

        if not venue_id:
            self.on_error(**ErrorCodeMessage.venue_not_exists)
            return

        venue = Venue.init_from_venue_id(venue_id)

        if not venue:
            self.on_error(**ErrorCodeMessage.venue_not_exists)
            return

        if venue.recover():
            self.on_success()
        else:
            self.on_error(**ErrorCodeMessage.database_error)
Example #28
0
def populate_db():
    if app.config["POPULATE_DB"]:
        for artist in ARTISTS:
            db.session.add(Artist(**artist))

        for show in SHOWS:
            db.session.add(Show(**show))

        for venue in VENUES:
            db.session.add(Venue(**venue))

        try:
            db.session.commit()
        except exc.SQLAlchemyError:
            db.session.rollback()
            print(sys.exc_info())
        finally:
            db.session.close()
Example #29
0
 def get(self, namespace, order_id):
     order_id = int(order_id)
     order = Order.get_by_id(order_id)
     if not order:
         self.abort(404)
     venue = Venue.get(order.venue_id)
     order_created_local = order.date_created + timedelta(hours=venue.timezone_offset)
     xml = E.order(
         self._personal_data(order),
         E.order_details(
             E.is_delivery_asap('0'),
             E.delivery_time(order.delivery_time_str)
         ),
         self._cart(order),
         date_n_time=order_created_local.strftime("%Y-%m-%d %H:%M:%S"),
         total="%.2f" % order.total_sum,
         id="%s/%s" % (namespace, order_id),
     )
     self.response.content_type = 'application/xml;charset=utf-8'
     self.response.write(etree.tostring(xml))
Example #30
0
    def put(self, *args, **kwargs):
        """改名"""
        venue_name = self.get_angular_argument('name')
        venue_id = self.get_angular_argument('id')

        if not venue_id:
            self.on_error(**ErrorCodeMessage.venue_not_exists)
            return

        venue = Venue.init_from_venue_id(venue_id)

        if not venue:
            self.on_error(**ErrorCodeMessage.venue_not_exists)
            return

        if not venue_name:
            self.on_error(**ErrorCodeMessage.venue_name_illegal)
            return

        if venue.edit_name(venue_name):
            self.on_success()
        else:
            self.on_error(**ErrorCodeMessage.database_error)
Example #31
0
 def test_cascading_delete(self):
     venue_url = self.lady_andal.url
     
     self.chennai.delete()
     self.assertFalse(Venue.get_by_url(venue_url))
Example #32
0
 def test_get_venue_by_url(self):
     venue = Venue(city=self.chennai, name=self.random(), url=self.random())
     venue.put()
     self.assertEqual(venue.name, self.chennai.get_venue_by_url(venue.url).name)
     
     self.assertEqual(None, self.chennai.get_venue_by_url(self.random()))
Example #33
0
 def get(self, venue_url = None):
     self.render('admin/venue.html', dict(cities=City.all(), current_venue = Venue.get_by_url(venue_url)))
Example #34
0
def seed_db():
    genre_objs = [Genre(name=genre) for genre in genres]
    artist_objs = [Artist(**artist) for artist in artists]
    venue_objs = [Venue(**venue) for venue in venues]

    try:
        db.session.add_all(genre_objs)
        db.session.add_all(artist_objs)
        db.session.add_all(venue_objs)
        db.session.commit()

        # genre ids
        genre_ids = {}
        for genre in genre_objs:
            genre_ids.update({genre.name: genre.id})

        # artist ids
        artist1_id = artist_objs[0].id
        artist2_id = artist_objs[1].id
        artist3_id = artist_objs[2].id

        # venue ids
        venue1_id = venue_objs[0].id
        venue2_id = venue_objs[1].id
        venue3_id = venue_objs[2].id

        # add artist genres
        artists_genres = [
            ArtistGenre(artist_id=artist1_id, genre_id=genre_ids["Rock n Roll"]),
            ArtistGenre(artist_id=artist2_id, genre_id=genre_ids["Jazz"]),
            ArtistGenre(artist_id=artist3_id, genre_id=genre_ids["Jazz"]),
            ArtistGenre(artist_id=artist3_id, genre_id=genre_ids["Classical"])
        ]
        db.session.add_all(artists_genres)

        # add venue genres
        venues_genres = [
            VenueGenre(venue_id=venue1_id, genre_id=genre_ids["Jazz"]),
            VenueGenre(venue_id=venue1_id, genre_id=genre_ids["Reggae"]),
            VenueGenre(venue_id=venue1_id, genre_id=genre_ids["Swing"]),
            VenueGenre(venue_id=venue1_id, genre_id=genre_ids["Classical"]),
            VenueGenre(venue_id=venue1_id, genre_id=genre_ids["Folk"]),

            VenueGenre(venue_id=venue2_id, genre_id=genre_ids["Classical"]),
            VenueGenre(venue_id=venue2_id, genre_id=genre_ids["R&B"]),
            VenueGenre(venue_id=venue2_id, genre_id=genre_ids["Hip-Hop"]),

            VenueGenre(venue_id=venue3_id, genre_id=genre_ids["Rock n Roll"]),
            VenueGenre(venue_id=venue3_id, genre_id=genre_ids["Jazz"]),
            VenueGenre(venue_id=venue3_id, genre_id=genre_ids["Classical"]),
            VenueGenre(venue_id=venue3_id, genre_id=genre_ids["Folk"]),
        ]
        db.session.add_all(venues_genres)

        # add shows

        shows = [
            {'artist_id': artist1_id, 'venue_id': venue3_id,
             'start_time': '2019-06-15T23:00:00.000Z'},
            {'artist_id': artist3_id, 'venue_id': venue3_id,
             'start_time': '2035-04-01T20:00:00.000Z'},
            {'artist_id': artist3_id, 'venue_id': venue3_id,
             'start_time': '2035-04-08T20:00:00.000Z'},
            {'artist_id': artist3_id, 'venue_id': venue3_id,
             'start_time': '2035-04-15T20:00:00.000Z'},
            {'venue_id': venue1_id, 'artist_id': artist1_id,
             'start_time': '2019-05-21T21:30:00.000Z'},
            {'venue_id': venue3_id, 'artist_id': artist2_id,
             'start_time': '2019-06-15T23:00:00.000Z'},
            {'venue_id': venue3_id, 'artist_id': artist3_id,
             'start_time': '2035-04-01T20:00:00.000Z'},
            {'venue_id': venue3_id, 'artist_id': artist3_id,
             'start_time': '2035-04-08T20:00:00.000Z'},
            {'venue_id': venue3_id, 'artist_id': artist3_id,
             'start_time': '2035-04-15T20:00:00.000Z'},
        ]
        show_objs = [Show(**show) for show in shows]
        db.session.add_all(show_objs)
        db.session.commit()

    except:
        db.session.rollback()
        print(sys.exc_info())
    finally:
        db.session.close()
Example #35
0
my_hs_garage_band = Band(name="My Band From High School")

phish.shows.extend([phish_12_31_95, phish_11_28_03])
dead.shows.extend([dead_5_8_77, dead_venetta, dead_1_7_79])
person1.shows.extend([dead_5_8_77, phish_12_31_95, phish_11_28_03])
person2.shows.extend([dead_venetta, dead_5_8_77])
person3.shows.append(dead_venetta)

# Cities
uniondale = City(name="Uniondale, NY")
veneta = City(name="Veneta, OR")
nyc = City(name="New York, NY")
ithaca = City(name="Ithaca, NY")

# Venues
nassau_coliseum = Venue(name='Nassau Veterans Memorial Coliseum',
                        capacity=17686)
springfield_creamery = Venue(name='Springfield Creamery', capacity=30000)
msg = Venue(name="Madison Square Garden", capacity=20789)
barton_hall = Venue(name="Barton Hall", capacity=5000)
brooklyn_bowl = Venue(name="Brooklyn Bowl", capacity=600)

nassau_coliseum.city = uniondale
springfield_creamery.city = veneta
msg.city = nyc
barton_hall.city = ithaca
brooklyn_bowl.city = nyc

phish_11_28_03.venue = nassau_coliseum
phish_12_31_95.venue = msg
dead_5_8_77.venue = barton_hall
dead_venetta.venue = springfield_creamery
Example #36
0
def venues():
    data = Venue.get_venues_by_location()
    return render_template("pages/venues.html", areas=data)
Example #37
0
 def venue_entity(self):
     if self.venue:
         return Venue.get(self.venue.id())
     return None
Example #38
0
def show_venue(venue_id):
    venue = Venue.get_venue(venue_id)
    if not venue:
        return render_template("pages/home.html")
    return render_template("pages/show_venue.html", venue=venue)
Example #39
0
 def test_get_route(self):
     url = self.random();
     venue = Venue(name=self.random(), url=url, city=self.chennai)
     self.assertEqual('/'+self.chennai.url+'/venues/'+venue.url,venue.get_route())
Example #40
0
 def test_venue_creation_with_duplicate_url(self):
     url = self.random();
     venue = Venue(name=self.random(), url=url, city=self.chennai)
     venue.put()
     venue_with_duplicate_url = Venue(city=self.chennai, name=self.random(), url=url)
     self.assertRaises(ValueError, venue_with_duplicate_url.put)    
Example #41
0
 def delete(self, venue_url= None):
     venue = Venue.get_by_url(venue_url)
     if venue : venue.delete()
     self.get()
Example #42
0
def edit_venue(venue_id):
    venue = Venue.get_by_id(venue_id)
    form = VenueForm(request.form, obj=venue)
    form.genres.process_data(venue.genres)
    form.seeking_talent.process_data(venue.seeking_talent)
    return render_template("forms/edit_venue.html", form=form, venue=venue)
Example #43
0
from models import storage
from models.city import City
from models.venue import Venue
from models.show import Show
from models.artist import Artist
from models.organizer import Organizer
#Create city
organizer = Organizer
city = City(city_name='Cali', country_name="Colombia")
city.save()

#create venue
venue = Venue(city_id=city.id,
              venue_name="Asilo",
              email="*****@*****.**",
              address="Calle del cartucho",
              capacity=150)
venue.save()
#create show
show = Show(venue_id=venue.id, price_tikets=25000)
#Create artist
artist = Artist(artist_name="Ponkeys",
                genre_artist="Funk",
                email="*****@*****.**")
artist.save()
print(venue)
print(show)
print(artist)
print(show.org_id)
Example #44
0
 def get(self, url = None):
   self.render('admin/performance.html', dict(performances=Performance.all(), shows=Show.all(), venues=Venue.all()))
Example #45
0
 def get(self, *args, **kwargs):
     venue_instance_list = Venue.get_all_venue()
     self.on_success([i.to_dict() for i in venue_instance_list])
Example #46
0
def index():
    artists = Artist.get_recent()
    venues = Venue.get_recent()
    return render_template("pages/home.html", artists=artists, venues=venues)