def post(self): form = CreatePackageForm() packages = Package.query.order_by(Package.id.desc()).all() if form.validate_on_submit(): try: # Create database entry p = Package() p.name = form.name.data or None p.description = form.description.data or None p.price = form.price.data or None p.slots = form.slots.data or None p.duration = form.duration.data or None p.order = form.order.data or 0 p.active = False db.session.add(p) db.session.commit() return redirect('/admin/packages/') except: import traceback db.session.rollback() traceback.print_exc() return redirect('/admin/packages/') return render_template('admin/packages.html', form=form, packages=packages)
def create_package(cls, price=1000, available_packages=10): """Return an instance of the Package class.""" package = Package( name="Social Media Package", price=price, audience="50-100", available_packages=available_packages, package_type="Cash", ) return package
def package(): form = ShippingForm() if form.validate_on_submit(): package = Package() form.populate_obj(package) package.location = package.origin package.save() Package.advance_all_locations() return redirect(url_for('.index')) return render_template('shipping_request.html', form=form)
def new_package(): form = ShippingForm() if request.method == 'POST': package = Package(sender=form.sender.data, recipient=form.recipient.data, origin=form.origin.data, destination=form.destination.data, express_shipping=form.express_shipping.data) db.session.add(package) db.session.commit() return redirect(url_for('.root_endpoint')) return render_template('shipping_request.html', form=form)
def package(): form = ShipForm() if form.validate_on_submit(): data = form.data new_package = Package(sender=data["name"], recipient=data["recipient"], origin=data["origin"], destination=data["destination"], location=data["origin"]) db.session.add(new_package) db.session.commit() return redirect("/") return render_template("shipping_request.html", form=form)
def new_package(): form = ShippingForm() if form.validate_on_submit(): data = form.data new_package = Package(name=data["name_sender"], recipient=data["name_recipient"], origin=data["origin"], destination=data["destination"], location=data["origin"]) db.session.add(new_package) db.session.commit() Package.advance_all_locations() return redirect("/") return render_template('shipping_request.html', form=form)
def new_package(): form = Shipping_Form() if (form.validate_on_submit()): data = form.data new_package = Package(sender=data["sender"], recipient=data['recipient'], origin=data['origin'], destination=data['destination'], location=data['origin']) db.session.add(new_package) db.session.commit() Package.advance_all_locations() return redirect('/') return render_template('shipping_request.html', form=form)
def shipping_request(): form = ShippingForm() if form.validate_on_submit(): data = form.data new_package = Package(sender=data["sender_name"], recipient=data["recipient_name"], origin=data["origin"], destination=data["destination"], location=data["origin"]) db.session.add(new_package) db.session.commit() Package.advance_all_locations() return redirect(url_for('.index')) return render_template("shipping_request.html", form=form)
def newPackage(): form = PackageForm() if form.validate_on_submit(): pkg = Package( title=form.title.data, price=form.content.data, ) db.session.add(pkg) db.session.commit() flash('Package created!', 'success') return redirect(url_for('adminPackages')) return render_template('admin/createPackage.html', title='New Package', form=form, legend='New Package')
def form(): form = ShippingForm() if form.validate_on_submit(): data = form.data new_package = Package(sender=data["sender_name"], recipient=data["recipient_name"], origin=data["origin"], destination=data["destination"], location=data["origin"]) db.session.add(new_package) db.session.commit() # DEBUG: Advance Time Package.advance_all_locations() return redirect('/') return render_template('shipping_request.html', form=form)
def new_package(): form = ShippingForm() form.origin.choices = [(key, key) for key in map] form.destination.choices = [(key, key) for key in map] if form.validate_on_submit(): print(form.data) data = form.data new_package = Package(sender=data["sender_name"], recipient=data["recipient_name"], origin=data["origin"], destination=data["destination"], location=data["origin"]) db.session.add(new_package) db.session.commit() return redirect('/') return render_template('shipping_request.html', form=form)
def new_package(): form = ShippingForm() form.origin.choices = [(city, city) for city in map.keys()] form.destination.choices = [(city, city) for city in map.keys()] if form.validate_on_submit(): Package.advance_all_locations() print(form.data) data = form.data new_package = Package( sender=data["sender_name"], recipient=data["recipient_name"], origin=data["origin"], destination=data["destination"], location=data["origin"] ) db.session.add(new_package) db.session.commit() return redirect(url_for(".index")) return render_template('shipping_request.html', form=form)
def put(self): data = api.payload if data: updatePackage = Package(destination=data['destination'], price=data['price'], days=data['days'], intenerary=data['itenerary'], inclusions=data['inclusions'], remainingSlots=data['remainingSlots'], expirationDate=data['expirationDate'], note=data['note'], hotel=data['hotel'], flight=data['flight'], isExpired=data['isExpired'] ) db.session.update(updatePackage) db.session.commit() return {'result': 'Package has been updated'}, 200 return {'error': {'statusCode': 400, 'errorCode': 'E2000', 'message': 'Please fill up the form'}}, 400
def make_package(name: str, versions: List[Tuple[Optional[str], Optional[str]]]) -> List[int]: license = License.query.filter_by(name="MIT").first() author = User.query.first() mod = Package() mod.state = PackageState.APPROVED mod.name = name.lower() mod.title = name mod.license = license mod.media_license = license mod.type = PackageType.MOD mod.author = author mod.short_desc = "The content library should not be used yet as it is still in alpha" mod.desc = "This is the long desc" db.session.add(mod) rels = [] for (minv, maxv) in versions: rel = PackageRelease() rel.package = mod rel.title = "test" rel.url = "https://github.com/ezhh/handholds/archive/master.zip" if minv: rel.min_rel = MinetestRelease.query.filter_by(name=minv).first() assert rel.min_rel if maxv: rel.max_rel = MinetestRelease.query.filter_by(name=maxv).first() assert rel.max_rel rel.approved = True db.session.add(rel) rels.append(rel) db.session.flush() return [rel.id for rel in rels]
def add_packages(self): """Add fake package data to the database.""" print("Adding packages...") event_count = Event.query.count() for count in range(1, event_count + 1): event = Event.query.get(count) for num in range(self.packages_per_event): package = Package( name=self.faker.color_name() + " Package", price=self.faker.pydecimal(left_digits=5, right_digits=2, positive=True, min_value=1.0), audience=random.choice(PEOPLE_RANGES[1:])[1], description=self.faker.text(), available_packages=self.faker.pyint(min_value=1, max_value=20, step=1), package_type=random.choice(["Cash", "In-Kind"]), event=event, ) db.session.add(package) db.session.commit()
def CreatePackage(): form = forms.RegisterPackage() availableHotel = (Hotel.query.filter(Hotel.isExpired.is_(False)).filter( Hotel.isPackaged.is_(True)).all()) hotelList = [(h.id, (h.name + ' - ' + h.roomType)) for h in availableHotel] form.hotels.choices = hotelList availableTicket = (Ticket.query.filter(Ticket.isExpired.is_(False)).filter( Ticket.isPackaged.is_(True)).all()) ticketList = [(t.id, (t.flightNo + (' (' + t.origin + ' - ' + t.arrival + ')'))) for t in availableTicket] form.tickets.choices = ticketList if form.validate_on_submit(): newPackage = Package(destination=form.destination.data, days=form.days.data, expirationDate=form.expirationDate.data, remainingSlots=form.remainingSlots.data, intenerary=form.intenerary.data, inclusions=form.inclusions.data, price=form.price.data, hotel=form.hotels.data, flight=form.tickets.data) db.session.add(newPackage) user = current_user fullName = user.firstName + ' ' + user.lastName if user.role == "AD": role = "Admin" elif user.role == "RO": role = "Reservation Officer" else: role = "Financial Officer" event = (fullName + ' (' + role + ') created ' + form.destination.data) newLogTrail = LogTrail(event=event) db.session.add(newLogTrail) db.session.commit() return redirect(url_for('main.UserHomeRO')) return render_template('employee/packages/addPackage.html', form=form)