def delete(service_id): service = Service.objects().with_id(service_id) if service is None: return "Not Found" else: service.delete() return redirect(url_for('admin'))
def new_service(): if request.method == 'GET': return render_template('new_service.html') elif request.method == 'POST': form = request.form account = form['account'] password = form['password'] game = form['game'] price = form['price'] contact = form['contact'] new_service = Service(account=account, password=password, game=game, price=price, contact=contact, occupied=False) new_service.save() flash("Service successfully created!") return redirect(url_for('new_service'))
def info(service_id): info_service = Service.objects().with_id(service_id) info_game_pic = info_service.game + '.jpg' info_account = info_service.account info_password = info_service.password info_game = info_service.game info_price = info_service.price info_contact = info_service.contact return render_template('info.html', info_game_pic = info_game_pic, info_account = info_account, info_password = info_password, info_game = info_game, info_price = info_price, info_contact = info_contact)
def edit(service_id): if request.method == 'GET': service = Service.objects().with_id(service_id) return render_template('edit.html', service=service) elif request.method == 'POST': form = request.form account = form['account'] password = form['password'] game = form['game'] price = form['price'] contact = form['contact'] occupied = form['occupied'] service = Service.objects().with_id(service_id) service.update(set__account=account) service.update(set__password=password) service.update(set__game=game) service.update(set__price=price) service.update(set__contact=contact) service.update(set__occupied=bool(occupied)) service.reload() flash("Service successfully edited!") return render_template('edit.html', service=service)
def search(game): filtered_services = Service.objects(game = game, occupied = False) return render_template('search.html', all_services = filtered_services)
from mlab import mlab_connect from class_service.service import Service from faker import Faker from random import randint, choice service_faker = Faker('en_US') mlab_connect() Service.drop_collection() for _ in range(100): service = Service(account=service_faker.name(), password=randint(100000000, 999999999), game=choice(["lol", "csgo", "pubg"]), price=choice(["1000/h", "1500/h", "2000/h"]), contact=0 + randint(100000000, 999999999), occupied=choice([True, False])) service.save()
def info(service_id): info_service = Service.objects().with_id(service_id) info_game_pic = info_service.game + '.jpg' return render_template('info.html', info_game_pic=info_game_pic, info_service=info_service)