Beispiel #1
0
def panel_services_add():
    form = ServiceForm()
    if form.validate_on_submit():
        shop_id = form.data['id']
        shop_name = form.data['name']

        query = ShopData.query.filter_by(id=shop_id, name=shop_name).first()
        if query is not None:
            flash('There is already a service with that ID or name!', 'danger')
            return render_template('views/panel.html', tab='service_add', admins=admins, form=form)

        shop_image = secure_filename(form.image.data.filename)
        shop_desc = form.data['description']
        shop_rewards = form.data['rewards']
        shop_number = form.data['sms_number']
        shop_commands = shop_rewards.replace('/', '')

        path = 'static/images/services/' + shop_image
        form.image.data.save(path)

        shop_data = ShopData(shop_id, shop_name, shop_desc, shop_commands)
        shop_data.sms = shop_number
        shop_data.image = path

        database.session.add(shop_data)
        database.session.commit()

        flash('Successfully added a new service!', 'success')
        return redirect(url_for('panel_services'))

    return render_template('views/panel.html', tab='service_add', admins=admins, form=form)
Beispiel #2
0
def add_service():
    """
    Used to register a new service
    """

    form = ServiceForm()

    if form.validate_on_submit():
        try:
            srv = Services()
            srv.populate_from_form(form)
            srv.authentication.value = {"db":request.form.get('authdb'),"user":request.form.get('authuser'),"pswd":request.form.get("authpass")}
            srv.save()
            flash('Datele au fost adaugate!', category='alert-success')
            return redirect(url_for('services.list_services'))
        except Exception as err:
            flash('Datele nu pot fi adaugate!', category='alert-danger')

    return render_template('services/settings/add.html', pagetitle='Adauga serviciu', form=form)
Beispiel #3
0
def edit_service(srvid):
    """
    Used to edit a registered service
    """
    class F(ServiceForm):
        pass
    
    srv = Services.get({"_id":srvid})
    form = ServiceForm()

    if form.validate_on_submit():
        try:
            srv.populate_from_form(form)
            print request.form
            srv.authentication.value = {"db":request.form.get('authdb'),"user":request.form.get('authuser'),"pswd":request.form.get("authpass")}
            srv.save()
            flash('Datele au fost modificate!', category='alert-success')
            return redirect(url_for('services.list_services'))
        except Exception as err:
            flash('Modificarile nu pot fi salvate!', category='alert-danger')


    if srv.authentication.value:
        if srv.authentication.value['db']:
            F.authdb = StringField(label="Db autentificare")
        if srv.authentication.value['user']:
            F.authuser = StringField(label="User")
        F.authpass = StringField(label="Parola")
        F.submit = SubmitField('Salveaza')
        
    form = srv.fill_form(_form=F())
    del form.authentication
    if srv.authentication.value:
        if srv.authentication.value['db']:
            form.authdb.data = srv.authentication.value['db']
        if srv.authentication.value['user']:
            form.authuser.data = srv.authentication.value['user']
        form.authpass.data = srv.authentication.value['pswd']
        

    return render_template('services/settings/edit.html', pagetitle='Detalii serviciu', form=form)
Beispiel #4
0
def process():
    form = ServiceForm()
    if form.validate_on_submit():
        currency = int(form.currency.data)
        if currency == 978:
            invoice = Invoice(form.description.data, form.amount.data,
                              currency, 'payeer_usd', 'invoice')
            invoice.save()
            data = invoice.get_invoice_form_params()
            return render_template('invoice.html', data=data, title='Invoice')

        if currency == 840:
            invoice = Invoice(form.description.data, form.amount.data,
                              currency, 'payeer_usd', 'tip')
            invoice.save()
            return render_template('tip.html',
                                   invoice=invoice,
                                   form_url=app.config['PS_TIP_URL'],
                                   shop_id=app.config['PS_SHOP_ID'],
                                   title='TIP')

    return redirect(url_for('index'))
Beispiel #5
0
def add_service():
    check_admin()
    add_service = True
    form = ServiceForm()
    if form.validate_on_submit():
        service = Service(
            name=form.name.data,
            description=form.description.data,
            mapping=form.mapping.data,
        )
        try:
            db.session.add(service)
            db.session.commit()
            flash('You have successfully added a new service.')
        except:
            flash('Error: service name already exists.')
        return redirect(url_for('admin.list_services'))
    return render_template('admin/services/service.html',
                           action="Add",
                           add_service=add_service,
                           form=form,
                           title="Add Service")