Exemplo n.º 1
0
def single_account_index(account_id):
    account = Account.query.get(account_id)

    return render_template("auth/index.html",
        account = account, 
        accountform = AccountForm(),
        channels = Account.find_accounts_channels(account_id),
        my_channels=Channel.get_my_channels(account_id),
        all_channels=Channel.get_channels_where_not_in(account_id),
        public_channels=Channel.get_all_publics(),
        messages=Message.query.filter_by(account_id=account_id),
        comments=Comment.get_comment_message_and_channel_id(account_id))
Exemplo n.º 2
0
def accounts_update(account_id):

    accountform = AccountForm(request.form)

    # check if username is whitespaces only
    char1 = False
    email = False
    not_same = False

    messages = []
    messages.append("THESE ARE THE CONDITIONS YOU MUST PAST")
    messages.append("*username must be 2 character length")
    messages.append("*password must be 8 character length")
    messages.append("*motto must be 2 character length")
    messages.append("*email must be 6 character length and must be real email")

    # email check
    for c in accountform.email.data:
        if c == '@':
            char1 = True

        if char1 == True:
            if c == '.':
                email = True

    if not accountform.password.data == accountform.password2.data:
        messages.append("*password was not same")
        not_same = True

    if not accountform.validate() or email == False or accountform.username.data.isspace() or not_same == True:
        return render_template("auth/index.html",
                                accountform = AccountForm(),
                                errors = messages,
                                account=current_user,
                                my_channels=Channel.get_my_channels(current_user.id),
                                all_channels=Channel.get_channels_where_not_in(current_user.id),
                                channels=Account.find_accounts_channels(current_user.id),
                                public_channels=Channel.get_all_publics(),
                                messages=Message.query.filter_by(account_id=current_user.id),
                                comments=Comment.get_comment_message_and_channel_id(current_user.id))

    account = Account.query.get(account_id)

    account.username = accountform.username.data
    account.password = accountform.password.data
    account.motto = accountform.motto.data
    account.email = accountform.email.data

    db.session().commit()

    return redirect(url_for("single_account_index"))