Ejemplo n.º 1
0
def unsubscribe(category, emailAddress):
    key = '%s_%s' % (category, emailAddress)
    row = models.Subscriptions(key_name=key)
    row.category = category
    row.emailAddress = emailAddress
    row.subscribed = False
    row.put()
Ejemplo n.º 2
0
def addMobileNumber(emailAddress, mobileNumber):
    rows = models.Subscriptions().all().filter('emailAddress =', emailAddress)
    for row in rows:
        row.mobileNumber = mobileNumber
        row.put()
    q = models.Administrators().all().filter('emailAddress =', emailAddress)

    for value in q:
        value.mobileNumber = mobileNumber
        value.put()
Ejemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        log.debug(
            f'--------------------------- Starting {self.BOT_NAME} v{self.VERSION} --------------------------'
        )

        self.expander = TeamExpander()
        self.tower_data = TowerOfDoomData(self.my_emojis)
        self.prefix = models.Prefix(CONFIG.get('default_prefix'))
        self.language = models.Language(CONFIG.get('default_language'))
        self.subscriptions = models.Subscriptions()
        self.views = Views(emojis={})
Ejemplo n.º 4
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        log.debug(
            f'--------------------------- Starting {self.BOT_NAME} v{self.VERSION} --------------------------'
        )

        self.expander = TeamExpander()
        self.tower_data = TowerOfDoomData(self.my_emojis)
        self.prefix = models.Prefix(CONFIG.get('default_prefix'))
        self.language = models.Language(CONFIG.get('default_language'))
        self.subscriptions = models.Subscriptions()
        self.views = Views(emojis={})
        self.pet_rescues = []
        self.pet_rescue_config: PetRescueConfig = None
        token = CONFIG.get('dbl_token')
        self.dbl_client = None
        self.server_status_cache = {'last_updated': datetime.datetime.min}
        if token:
            self.dbl_client = dbl.DBLClient(self, token)
Ejemplo n.º 5
0
def getSubscribersEmails(category):
    q = models.Subscriptions().all().filter('category =', category)
    rows = q.fetch(10)
    return rows
Ejemplo n.º 6
0
def getSubscribedCategories(emailAddress):
    q = models.Subscriptions().all().filter('emailAddress =',
                                            emailAddress).filter(
                                                'subscribed =', True)
    rows = q.fetch(10)
    return rows
Ejemplo n.º 7
0
def settings():
    d = {'WMR': 'Webmoney RUB', 'QWRUB': 'Qiwi RUB', 'YAMRUB': 'Ynadex Money RUB', 'BTC': 'Bitcoin', 'SBERRUB': 'Sberbank RUB'}

    change_password_form = ChangePasswordForm()
    subscriptions = db.session.query(models.Subscriptions).filter_by(userId=current_user.id)

    anysubs = subscriptions.count()

    if subscriptions:
        subscriptions = subscriptions[::-1]

    if change_password_form.validate_on_submit():
        if check_password_hash(current_user.password, change_password_form.current_password.data) and (change_password_form.new_password.data == change_password_form.new_password_confirm.data):
            new_hashed_password = generate_password_hash(change_password_form.new_password.data, method='sha256')

            curr = db.session.query(models.User).filter_by(email=current_user.email).first()
            curr.password = new_hashed_password

            db.session.commit()
            flash('Successfully updated your password!')
            return redirect(url_for('settings'))
        elif check_password_hash(current_user.password, change_password_form.current_password.data) and (change_password_form.new_password.data != change_password_form.new_password_confirm.data):
            flash('Entered new passwords do not match')
            return redirect(url_for('settings'))
        else:
            flash('Current password is wrong!')
            return redirect(url_for('settings'))
    if request.method == 'POST':
        fCurr = request.form.get('first')
        sCurr = request.form.get('second')
        ratio = request.form.get('input')

        try:
            ratio = float(ratio)
            if ratio <= 0:
                flash('Ratio must be bigger than 0')
                return redirect(url_for('settings'))
            try:
                uri = '/data?in=' + fCurr + '&out=' + sCurr
                r = requests.get('http://' + request.host + uri)
                data = r.json()
                if int(data['ratio']) == -1:
                    flash('You can not subscribe on this kind of currency exchange')
                    return redirect(url_for('settings'))
                if ratio > data['ratio']:
                    flash('Your ratio can not be bigger than the current one')
                    return redirect(url_for('settings'))

                if db.session.query(models.Subscriptions).filter_by(userId=current_user.id).count() < 5:
                    t = fCurr + sCurr
                    sub = models.Subscriptions(type=t, giveCurr=d[fCurr], getCurr=d[sCurr], coef=ratio, userId=current_user.id)
                    db.session.add(sub)
                    db.session.commit()
                    flash('Successfully added new subscription!')
                    return redirect(url_for('settings'))
                else:
                    flash('You can not add more than 5 subscriptions')
                    return redirect(url_for('settings'))
            except Exception as e:
                flash('Some error occurred')
                return redirect(url_for('settings'))
        except Exception as e:
            flash('Ratio input format is wrong!')
            return redirect(url_for('settings'))
    return render_template('settings.html', change_password_form=change_password_form,
                           subscriptions=subscriptions, anysubs=anysubs)