Ejemplo n.º 1
0
 def exchange():
     countries = CountryRepository.get_all()
     methods = PaymentMethodRepository.get_all()
     return render_template('exchange.html',
                            title='Exchange',
                            countries=countries,
                            methods=methods)
Ejemplo n.º 2
0
 def buy_btc(self, params):
     exchangeService = ExchangeService()
     country = CountryRepository()
     methods = PaymentMethodRepository()
     currency = CurrencyRepository()
     countries = country.get_all()
     payment_methods = methods.get_all()
     currencies = currency.get_fiat_currencies()
     count = None
     country_id = country_id_cash = method_id = currency_id = city = None
     h = []
     values = []
     refferals = []
     if params is not None:
         values = params.split('-')
     if values and values[0] == 'online':
         country_id = request.form.get('country_id')
         method_id = request.form.get('payment_method_id')
         currency_id = request.form.get('currency_id')
         if country_id is not None or method_id is not None or currency_id is not None:
             count = self.get_sellers(country_id, method_id, currency_id)
             refferals = exchangeService.get_refferals('online')
     if values and values[0] == 'cash':
         country_id_cash = request.form.get('country_id_cash')
         country_find = Countries.query.filter(
             Countries.id == country_id_cash).first()
         cities_find = Cities.query.filter(
             Cities.country_code == country_find.name_alpha2).order_by(
                 Cities.city_name).all()
         for city in cities_find:
             h.append({'city_id': city.id, 'city_name': city.city_name})
         city = request.form.get('city_id')
         if city is not None:
             count = self.get_sellers_cash(city)
             refferals = exchangeService.get_refferals('cash')
     if values and values[0] == 'country':
         values.remove('country')
         country_find = Countries.query.filter(
             Countries.description == '-'.join(values)).first()
         country_id_one = country_find.id
         count = self.get_sellers(country_id_one, None, None)
     if values and values[0] == 'payment':
         values.remove('payment')
         values.remove('method')
         method_find = PaymentMethods.query.filter(
             PaymentMethods.slug == '-'.join(values)).first()
         method_id_one = method_find.id
         count = self.get_sellers(None, method_id_one, None)
     if values and values[0] == 'currency':
         values.remove('currency')
         currency_find = Currencies.query.filter(
             Currencies.slug == '-'.join(values)).first()
         currency_id_one = currency_find.id
         count = self.get_sellers(None, None, currency_id_one)
     select = {
         'country': country_id,
         'method': method_id,
         'currency': currency_id,
         'country_cash': country_id_cash,
         'city': city,
         'cities': h
     }
     return render_template("buy_currency.html",
                            title='Buy Bitcoins',
                            data=countries,
                            methods=payment_methods,
                            currencies=currencies,
                            count=count,
                            select=select,
                            refferals=refferals)