Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newlayout #1

Open
wants to merge 13 commits into
base: bug_fix
Choose a base branch
from
4 changes: 0 additions & 4 deletions all_models.py

This file was deleted.

10 changes: 0 additions & 10 deletions db_create_all.py

This file was deleted.

10 changes: 0 additions & 10 deletions db_drop_all.py

This file was deleted.

37 changes: 36 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,40 @@ apt-get install postgresql-9.4" sudo deb

function menu_deb {
conf_comm "apt-get update
apt-get install libpq-dev python-dev libapache2-mod-wsgi-py3 libjpeg-dev memcached" sudo hosts
apt-get install libpq-dev python-dev libapache2-mod-wsgi-py3 libjpeg-dev memcached" sudo npm
}

function menu_npm {
conf_comm "apt-get install nodejs
apt-get install npm
ln -s /usr/bin/nodejs /usr/bin/node
npm install -g bower
npm install -g gulp" sudo bower
}

function menu_bower {
conf_comm "cd ./profapp/static
bower install" nosudo menu_bower_dev
}

function menu_bower_dev {
conf_comm "cd ./profapp/static/bower_components_dev
mkdir ./angular-db-filemanager
cd ./angular-db-filemanager
git clone [email protected]:kakabomba/angular-server-driven-filemanager.git .
cd ..
mkdir ./angular-crop
cd ./angular-crop
git clone [email protected]:kakabomba/ng-crop.git .
" nosudo hosts
}

function menu_gulp {
conf_comm "cd ./profapp/static
npm install gulp del gulp-less-sourcemap gulp-watch run-sequence gulp-task-listing
gulp" nosudo hosts
}

function menu_hosts {
conf_comm "sed -i '/\(db\|web\|mail\|memcached\|elastic\).profi/d' /etc/hosts
sed -i '/profireader.com/d' /etc/hosts
Expand Down Expand Up @@ -383,6 +414,10 @@ dialog --title "profireader" --nocancel --default-item $next --menu "Choose an o
"origin" "change git origin and add new remote repo" \
"postgres_9_4" "install postgres 9.4" \
"deb" "install deb packages" \
"npm" "install nodejs, npm, bower and gulp globally" \
"bower" "download bower components in ./profapp/static/bower_components" \
"bower_dev" "download bower development components in ./profapp/static/bower_components_dev" \
"gulp" "install gulp in ./profapp/static" \
"hosts" "create virtual domain zone in /etc/hosts" \
"haproxy_compile" "compile and install haproxy" \
"haproxy_config" "copy haproxy config to /etc/haproxy" \
Expand Down
46 changes: 25 additions & 21 deletions profapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def filter_json(json, *args, NoneTo='', ExceptionOnNotPresent=False, prefix=''):
if column_name not in req_relationships:
req_relationships[column_name] = []
req_relationships[column_name].append(
'.'.join(columnsdevided))
'.'.join(columnsdevided))

for col in json:
if col in req_columns or '*' in req_columns:
Expand All @@ -80,8 +80,8 @@ def filter_json(json, *args, NoneTo='', ExceptionOnNotPresent=False, prefix=''):
if len(columns_not_in_relations) > 0:
if ExceptionOnNotPresent:
raise ValueError(
"you requested not existing json value(s) `%s%s`" % (
prefix, '`, `'.join(columns_not_in_relations),))
"you requested not existing json value(s) `%s%s`" % (
prefix, '`, `'.join(columns_not_in_relations),))
else:
for notpresent in columns_not_in_relations:
ret[notpresent] = NoneTo
Expand All @@ -91,7 +91,7 @@ def filter_json(json, *args, NoneTo='', ExceptionOnNotPresent=False, prefix=''):
"relationships found `%s%s`" % (
prefix, '`, `'.join(set(json.keys()).
intersection(
req_columns.keys())),))
req_columns.keys())),))

for relationname, relation in json.items():
if relationname in req_relationships or '*' in req_relationships:
Expand All @@ -115,16 +115,16 @@ def filter_json(json, *args, NoneTo='', ExceptionOnNotPresent=False, prefix=''):

if len(req_relationships) > 0:
relations_not_in_columns = list(set(
req_relationships.keys()) - set(json))
req_relationships.keys()) - set(json))
if len(relations_not_in_columns) > 0:
raise ValueError(
"you requested not existing json(s) `%s%s`" % (
prefix, '`, `'.join(relations_not_in_columns),))
"you requested not existing json(s) `%s%s`" % (
prefix, '`, `'.join(relations_not_in_columns),))
else:
raise ValueError("you requested for json deeper than json is(s) but "
"column(s) found `%s%s`" % (
prefix, '`, `'.join(set(json).intersection(
req_relationships)),))
req_relationships)),))

return ret

Expand Down Expand Up @@ -200,12 +200,15 @@ def load_user(apptype):
else:
current_app.config[var_id] = '%s' % (variable.value,)


def prImage(id, if_no_image=None):
file = utils.fileUrl(id, False, if_no_image if if_no_image else "//static.profireader.com/static/images/no_image.png")
def prImageUrl(url):
return Markup(
' src="//static.profireader.com/static/images/0.gif" style="background-position: center; background-size: contain; background-repeat: no-repeat; background-image: url(\'%s\')" ' % (
file,))
' src="//static.profireader.com/static/images/0.gif" style="background-position: center; background-size: contain; background-repeat: no-repeat; background-image: url(\'%s\')" ' % (
url,))


def prImage(id=None, if_no_image=None):
noimage_url = if_no_image if if_no_image else "//static.profireader.com/static/images/no_image.png"
return prImageUrl((utils.fileUrl(id, False, noimage_url)) if id else noimage_url)


def translates(template):
Expand Down Expand Up @@ -254,12 +257,12 @@ def translate_html(context, phrase, dictionary=None):
def pr_help_tooltip(context, phrase, placement='bottom', trigger='mouseenter',
classes='glyphicon glyphicon-question-sign'):
return Markup(
'<span popover-placement="' + placement + '" popover-trigger="' + trigger + '" class="' + classes +
'" uib-popover-html="\'' + HtmlHelper.quoteattr(
translate_phrase_or_html(context, 'help tooltip ' + phrase, None, '*')) + '\'"></span>')
'<span popover-placement="' + placement + '" popover-trigger="' + trigger + '" class="' + classes +
'" uib-popover-html="\'' + HtmlHelper.quoteattr(
translate_phrase_or_html(context, 'help tooltip ' + phrase, None, '*')) + '\'"></span>')


def moment(value, out_format = None):
def moment(value, out_format=None):
if isinstance(value, datetime.datetime):
print(out_format)
value = value.isoformat(' ') + ' GMT'
Expand Down Expand Up @@ -305,7 +308,7 @@ def config_variables():
else:
ret[var_id] = '\'' + variable.value + '\''
return "<script>\nConfig = {};\n" + ''.join(
[("Config['%s']=%s;\n" % (var_id, ret[var_id])) for var_id in ret]) + '</script>'
[("Config['%s']=%s;\n" % (var_id, ret[var_id])) for var_id in ret]) + '</script>'


def config_variables():
Expand All @@ -325,7 +328,7 @@ def config_variables():
ret[var_id] = '\'' + variable.value.replace('\\', '\\\\').replace('\n', '\\n').replace('\'', '\\\'') + '\''

return "<script>\n_LANG = '" + g.lang + "'; \nConfig = {};\n" + ''.join(
[("Config['%s']=%s;\n" % (var_id, ret[var_id])) for var_id in ret]) + '</script>'
[("Config['%s']=%s;\n" % (var_id, ret[var_id])) for var_id in ret]) + '</script>'


def get_url_adapter():
Expand Down Expand Up @@ -424,9 +427,9 @@ def gravatar(self, size=100, default='identicon', rating='g'):
# email = self.profireader_email

hash = hashlib.md5(
email.encode('utf-8')).hexdigest()
email.encode('utf-8')).hexdigest()
return '{url}/{hash}?s={size}&d={default}&r={rating}'.format(
url=url, hash=hash, size=size, default=default, rating=rating)
url=url, hash=hash, size=size, default=default, rating=rating)

def __repr__(self):
return "<User(id = %r)>" % self.id
Expand Down Expand Up @@ -517,6 +520,7 @@ def load_user_manager(user_id):
app.jinja_env.globals.update(translates=translates)
app.jinja_env.globals.update(fileUrl=utils.fileUrl)
app.jinja_env.globals.update(prImage=prImage)
app.jinja_env.globals.update(prImageUrl=prImageUrl)
# app.jinja_env.globals.update(url_page=url_page)
app.jinja_env.globals.update(config_variables=config_variables)
app.jinja_env.globals.update(_=translate_phrase)
Expand Down
4 changes: 4 additions & 0 deletions profapp/constants/FILES_FOLDERS.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
class FOLDER_AND_FILE:

@staticmethod
def no_image():
return '00000000-0000-4001-0000-000000000000'

@staticmethod
def no_company_logo():
return '00000000-0000-4001-921c-fa081eb54733'
Expand Down
4 changes: 2 additions & 2 deletions profapp/controllers/blueprints_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def decorator(f):
index = options['methods'].index('OK')
options['methods'][index] = 'POST'
ret = ok(f)
ret = function_profiler(ret)
# ret = function_profiler(ret)
self.bluprints[self.name] = {}
self.bluprints[self.name][ret.__name__] = ret
else:
ret = function_profiler(ret)
# ret = function_profiler(ret)
self.bluprints[self.name] = {}
self.bluprints[self.name][ret.__name__] = ret
endpoint = options.pop("endpoint", ret.__name__)
Expand Down
Loading