Fix #33 bug, thinking all users are anon
Fix bug in vagrantfile Fix bug in db create/drop Fix typo in cli
This commit is contained in:
parent
c2404760b8
commit
863de00a14
2
Vagrantfile
vendored
2
Vagrantfile
vendored
|
@ -9,7 +9,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||
vb.cpus = 2
|
||||
end
|
||||
|
||||
config.vm.provision "shell", path: "install.sh", privileged: "false"
|
||||
config.vm.provision "shell", path: "install.sh", privileged: false
|
||||
end
|
||||
|
||||
Vagrant::Config.run do |config|
|
||||
|
|
|
@ -45,7 +45,6 @@ sudo npm install -g bower
|
|||
|
||||
cd /home/vagrant
|
||||
|
||||
|
||||
virtualenv .venv
|
||||
source .venv/bin/activate
|
||||
|
||||
|
|
|
@ -13,13 +13,14 @@ import click
|
|||
from flask import Flask, request, render_template, url_for, redirect, g
|
||||
from flask.ext.cache import Cache
|
||||
from flask.ext.login import LoginManager, current_user
|
||||
from flask.ext.sqlalchemy import SQLAlchemy, declarative_base, Model, _QueryProperty
|
||||
from flask.ext.sqlalchemy import SQLAlchemy
|
||||
from flask.ext.assets import Environment, Bundle
|
||||
from werkzeug.routing import BaseConverter
|
||||
from werkzeug.exceptions import HTTPException
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
from .lib.util import to_canonical, remove_ext, mkdir_safe, gravatar_url, to_dict
|
||||
from .lib.hook import HookModelMeta
|
||||
from .lib.hook import HookModelMeta, HookMixin
|
||||
from .lib.util import is_su, in_virtualenv
|
||||
from .version import __version__
|
||||
|
||||
|
@ -161,6 +162,8 @@ def create_app(config=None):
|
|||
cache.init_app(app)
|
||||
assets.init_app(app)
|
||||
|
||||
db.Model = declarative_base(metaclass=HookModelMeta, cls=HookMixin)
|
||||
|
||||
for status_code in httplib.responses:
|
||||
if status_code >= 400:
|
||||
app.register_error_handler(status_code, error_handler)
|
||||
|
@ -186,11 +189,10 @@ def create_app(config=None):
|
|||
|
||||
# This will be removed at some point
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
db.metadata.create_all(db.get_engine(app))
|
||||
|
||||
return app
|
||||
|
||||
|
||||
# Init plugins here if possible
|
||||
login_manager = LoginManager()
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
from realms import config, create_app, db, __version__, cli
|
||||
from realms.lib.util import is_su, random_string, in_virtualenv, green, yellow, red
|
||||
from realms.lib.util import random_string, in_virtualenv, green, yellow, red
|
||||
from subprocess import call, Popen
|
||||
from multiprocessing import cpu_count
|
||||
import click
|
||||
|
@ -108,7 +108,7 @@ def setup(ctx, **kw):
|
|||
green('Config saved to %s' % conf_path)
|
||||
|
||||
if not conf_path.startswith('/etc/realms-wiki'):
|
||||
yellow('Note: You can move file to /etc/realms-wiki/realms-wiki.conf')
|
||||
yellow('Note: You can move file to /etc/realms-wiki/realms-wiki.json')
|
||||
click.echo()
|
||||
|
||||
yellow('Type "realms-wiki start" to start server')
|
||||
|
@ -339,7 +339,8 @@ def create_db():
|
|||
"""
|
||||
green("Creating all tables")
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
green('DB_URI: %s' % app.config.get('DB_URI'))
|
||||
db.metadata.create_all(db.get_engine(app))
|
||||
|
||||
|
||||
@cli.command()
|
||||
|
@ -349,7 +350,7 @@ def drop_db():
|
|||
"""
|
||||
yellow("Dropping all tables")
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
db.metadata.drop_all(db.get_engine(app))
|
||||
|
||||
|
||||
@cli.command()
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
import json
|
||||
from sqlalchemy import not_, and_
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from datetime import datetime
|
||||
from realms import db
|
||||
from .hook import HookModelMeta, HookMixin
|
||||
|
||||
Base = declarative_base(metaclass=HookModelMeta, cls=HookMixin)
|
||||
|
||||
|
||||
class Model(Base):
|
||||
class Model(db.Model):
|
||||
"""Base SQLAlchemy Model for automatic serialization and
|
||||
deserialization of columns and nested relationships.
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ def revert():
|
|||
commit = request.form.get('commit')
|
||||
message = request.form.get('message', "Reverting %s" % cname)
|
||||
|
||||
if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous:
|
||||
if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous():
|
||||
return dict(error=True, message="Anonymous posting not allowed"), 403
|
||||
|
||||
if cname in current_app.config.get('WIKI_LOCKED_PAGES'):
|
||||
|
@ -107,7 +107,7 @@ def page_write(name):
|
|||
if not cname:
|
||||
return dict(error=True, message="Invalid name")
|
||||
|
||||
if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous:
|
||||
if not current_app.config.get('ALLOW_ANON') and current_user.is_anonymous():
|
||||
return dict(error=True, message="Anonymous posting not allowed"), 403
|
||||
|
||||
if request.method == 'POST':
|
||||
|
|
Loading…
Reference in a new issue