def add_new(self, font_id, tag):
        new_tag = FontType(font_id=font_id, tag=tag)

        db_session.add(new_tag)
        db_session.commit()

        return new_tag
    def add_new(self, tag_id, font_id, language):
        new_tag = Language(tag_id=tag_id, font_id=font_id, language=language)

        db_session.add(new_tag)
        db_session.commit()

        return new_tag
    def add_new(self, name, type):
        new_collection = Collection(name=name, type=type)

        db_session.add(new_collection)
        db_session.commit()

        return new_collection
Esempio n. 4
0
    def add_new(self,email, name, password, username):
        new_user = User(
            email=email, name=name, password=password, username=username
        )

        db_session.add(new_user)
        db_session.commit()
def create_charge():
    post_data = request.get_json()
    amount = round(float(post_data.get('total').strip("$")) * 100)

    current_cart = session.get("cart", {})
    products = db_session.query(RetailProduct).join(Product).filter(
        RetailProduct.id.in_(current_cart.keys()))

    id_to_prod = {}
    distributor_id = None
    for product in products:
        if not distributor_id:
            distributor_id = product.distributor_id
        id_to_prod[product.id] = product
    grand_total = 0

    for prod_id, qty in current_cart.items():
        retail_prod = id_to_prod[prod_id]
        price = retail_prod.price
        grand_total += price * qty

    if grand_total != amount:
        return {"something went wrong"}, 400

    stripe.api_key = 'sk_test_ZIhkqTdUPX3vIAjGbvgKSBj900rIS9blAJ'
    charge = stripe.Charge.create(amount=amount,
                                  currency='usd',
                                  card=post_data.get('token'),
                                  description="order")
    response_object = {'status': 'success', 'charge': charge}
    user = session["user"]
    if charge.status == 'succeeded':
        order = Order(distributor_id=distributor_id,
                      submitted_at=datetime.datetime.now(),
                      payed_at=datetime.datetime.now(),
                      name=user['fllname'],
                      email=user['email'],
                      zip=user['zipcode'],
                      address='1 main',
                      city='Spokane',
                      state='WA',
                      phone='44455566')

        db_session.add(order)
        db_session.commit()

        for prod_id, qty in current_cart.items():
            retail_prod = id_to_prod[prod_id]
            price = retail_prod.price
            oi = OrderItem(order_id=order.id,
                           purchase_price=price,
                           qty=qty,
                           retail_product_id=prod_id)
            db_session.add(oi)
        db_session.commit()

        session["cart"] = {}

    return jsonify(response_object), 200
    def add_new(self, collection_id, font_id):
        new_font_collection = FontCollection(collection_id=collection_id,
                                             font_id=font_id)

        db_session.add(new_font_collection)
        db_session.commit()

        return new_font_collection
Esempio n. 7
0
    def add_new(self, font_id, download_url, name, price, version):
        new_font = Font(font_id=font_id,
                        download_url=download_url,
                        name=name,
                        price=price,
                        version=version)

        db_session.add(new_font)
        db_session.commit()
    def add_new(self, font_id, fontface, resource_path):
        new_fontface = FontFace(font_id=font_id,
                                fontface=fontface,
                                resource_path=resource_path)

        db_session.add(new_fontface)
        db_session.commit()

        return new_fontface
    def add_new(self, role_id, entity_id, entity, role):
        new_role = Role(role_id=role_id,
                        entity_id=entity_id,
                        entity=entity,
                        role=role)

        db_session.add(new_role)
        db_session.commit()

        return new_role
Esempio n. 10
0
    def add_new(self, font_id, version):
        new_installed_font = InstalledFont(
            font_id=font_id,
            version=version
        )

        db_session.add(new_installed_font)
        db_session.commit()

        return new_installed_font
    def add_new(self, font_id, name):
        new_font = Font(font_id=font_id,
                        is_installed=False,
                        is_upgradable=False,
                        name=name)

        db_session.add(new_font)
        db_session.commit()

        return new_font
    def add_new(self, file_name, font_id):
        new_font_file = FontFile(
            file_name=file_name,
            font_id=font_id,
        )

        db_session.add(new_font_file)
        db_session.commit()

        return new_font_file
Esempio n. 13
0
    def add_new(self, current_revision, end_date, font_id, start_date, user_id):
        new_subscription = Subscription(
            current_revision=current_revision,
            end_date=end_date,
            font_id=font_id,
            start_date=start_date,
            user_id=user_id
        )

        db_session.add(new_subscription)
        db_session.commit()
    def add_new(self, metadata_id, font_id, default_fontface, download_url,
                license, version):
        new_metadata = Metadata(metadata_id=metadata_id,
                                font_id=font_id,
                                default_fontface=default_fontface,
                                download_url=download_url,
                                license=license,
                                version=version)

        db_session.add(new_metadata)
        db_session.commit()

        return new_metadata
Esempio n. 15
0
def feature():
    class_feature_form = ClassFeatureForm()
    if class_feature_form.validate_on_submit():
        # Empty instance
        feature_obj = base_classes["class_feature"]()
        # Set feature name
        feature_obj.name = class_feature_form.feature_name.data
        # Set respective city id
        feature_obj.resp_city= class_feature_form.respective_city.data.id
        db_session.add(feature_obj)
        db_session.commit()
        return redirect('/success')
    return render_template('classFeature/new.html', form=class_feature_form)
Esempio n. 16
0
def city():
    city_form = CityForm()
    if city_form.validate_on_submit():
        # Empty instance
        city_obj = base_classes["cities"]()
        # Set city full name
        city_obj.full_name = city_form.full_name.data
        # Set city footprint and projection
        city_obj.footprint_wkt_proj, city_obj.footprint = city_form.get_footprint_data(city_form.foot_print_file_location.data)
        db_session.add(city_obj)
        db_session.commit()
        return redirect('/success')
    return render_template('city/new.html', form=city_form)
    def add_new(self, user_id, email, name, password, token):
        new_profile = Profile(
            user_id=user_id,
            email=email,
            is_logged=True,
            name=name,
            password=password,
            token=token,
        )

        db_session.add(new_profile)
        db_session.commit()

        return new_profile
    def add_new(self, home_directory, font_directory, fontman_home, platform,
                refresh_rate, system_user, version):
        new_system = System(home_directory=home_directory,
                            font_directory=font_directory,
                            fontman_home=fontman_home,
                            platform=platform,
                            refresh_rate=refresh_rate,
                            system_user=system_user,
                            version=version)

        db_session.add(new_system)
        db_session.commit()

        return new_system
Esempio n. 19
0
def imageFile():
    image_file_form = ImageFileForm()    
    if image_file_form.validate_on_submit():
        print("*"*10)
        print(image_file_form.get_image_file_footprint_data())
        return redirect('/success')
        # Empty instance
        image_file_obj = base_classes["image_file"]()
        # Set city respective feature
        image_file_obj.resp_class_feature = image_file_form.respective_feature.data.id
        # Set image file type
        if (image_file_form.respective_feature.data.name == "raw"):
            image_file_obj.image_file_type = "raster"
        else:
            image_file_obj.image_file_type = "vector"
        # Set city footprint and projection
        image_file_obj.image_file_location= image_file_form.image_file_location.data
        # Set footprint
        image_file_obj.footprint, image_file_obj.footprint_wkt_proj = image_file_form.get_image_file_footprint_data()
        db_session.add(image_file_obj)
        db_session.commit()
        return redirect('/success')
    return render_template('imageFile/new.html', form=image_file_form)
Esempio n. 20
0
 def update_by_font_id(self, font_id, update_data):
     self.find_by_font_id(font_id).update(update_data)
     db_session.commit()
 def update_by_collection_id(self, collection_id, update_data):
     self.find_by_collection_id(collection_id).update(update_data)
     db_session.commit()
 def delete_by_collection_id(self, collection_id):
     self.find_by_collection_id(collection_id).delete()
     db_session.commit()
from session import db_session
from models import Zip

from pyzipcode import ZipCodeDatabase

zcdb = ZipCodeDatabase()

for z in zcdb.find_zip():
    zip = Zip(zip_code=z.zip)
    db_session.add(zip)

db_session.commit()
Esempio n. 24
0
 def update_subscription(self, font_id, user_id, update_data):
     self.find_subscription(font_id, user_id).update(update_data)
     db_session.commit()
Esempio n. 25
0
 def delete_by_user_id(self, user_id):
     self.find_by_user_id(user_id).delete()
     db_session.commit()
Esempio n. 26
0
 def delete_by_font_id(self, font_id):
     self.find_by_font_id(font_id).delete()
     db_session.commit()
Esempio n. 27
0
 def delete_by_id(self, id):
     self.find_by_id(id).delete()
     db_session.commit()
 def delete_all(self):
     self.find_all().delete()
     db_session.commit()
 def update_by_user_id(self, user_id, update_list):
     self.find_by_user_id(user_id).update(update_list)
     db_session.commit()
Esempio n. 30
0
 def delete_tag(self, font_id, tag):
     self.find_tag(font_id, tag).delete()
     db_session.commit()