Пример #1
0
    def add(self):
        form = ServiceSettingsForm(obj=ServiceSettings())
        if request.method == 'POST' and form.validate_on_submit():
            new_entry = form.make_entry()
            admin = ProviderPair(user=current_user.id, role=ProviderPair.Roles.ADMIN)
            new_entry.add_provider(admin)
            new_entry.save()

            current_user.add_server(new_entry)
            current_user.save()
            return jsonify(status='ok'), 200

        return render_template('service/add.html', form=form)
Пример #2
0
    def provider_add(self, sid):
        form = ServerProviderForm()
        if request.method == 'POST' and form.validate_on_submit():
            email = form.email.data.lower()
            provider = ProviderUser.get_by_email(email)
            server = ServiceSettings.get_by_id(ObjectId(sid))
            if server and provider:
                admin = ProviderPair(provider.id, form.role.data)
                server.add_provider(admin)
                server.save()

                provider.add_server(server)
                provider.save()
                return jsonify(status='ok'), 200

        return render_template('service/provider/add.html', form=form)
Пример #3
0
def import_resellers_to_server(db, server: ServiceSettings):
    cursor = db.cursor(dictionary=True)
    sql = 'SELECT username,email,password from reg_users'
    cursor.execute(sql)
    sql_providers = cursor.fetchall()

    for sql_entry in sql_providers:
        email = sql_entry['email']
        password = sql_entry['email']
        new_user = ProviderUser.make_provider(email=email, first_name='Xtream', last_name='Codes', password=password,
                                              country='US', language='en')
        new_user.status = ProviderUser.Status.ACTIVE
        new_user.save()

        admin = ProviderPair(new_user.id, ProviderPair.Roles.ADMIN)
        server.add_provider(admin)
        new_user.add_server(server)

    cursor.close()