Browse Source

Merge branch 'master' into 103-autorizacaov2

pull/505/head
Eduardo Calil 8 years ago
parent
commit
7e14e2534d
  1. 36
      .travis.yml
  2. 5
      README.rst
  3. 4
      requirements/requirements.txt
  4. 0
      sapl/.env_test
  5. 19
      sapl/crispy_layout_mixin.py
  6. 2
      sapl/static/styles/app.scss

36
.travis.yml

@ -1,45 +1,23 @@
language: python
sudo: required
python:
- "3.4.3"
- 3.4.3
services:
- postgresql
addons:
postgresql: "9.3"
install:
- sudo apt-get install git nginx python3-dev libpq-dev graphviz-dev graphviz pkg-config python-psycopg2 nodejs npm
- sudo ln -s /usr/bin/node
- pip install -r requirements/test-requirements.txt
- pip install --upgrade setuptools
# Line 24 to 35 is a hack found in this link below
# It was used to fix an error in database building
# https://dockyard.com/blog/ruby/2013/03/29/running-postgresql-9-2-on-travis-ci
before_script:
- sudo /etc/init.d/postgresql stop
- sudo cp /etc/postgresql/9.2/main/pg_hba.conf ./
- sudo apt-get remove postgresql postgresql-9.2 -qq --purge
- source /etc/lsb-release
- echo "deb http://apt.postgresql.org/pub/repos/apt/ $DISTRIB_CODENAME-pgdg main" > pgdg.list
- sudo mv pgdg.list /etc/apt/sources.list.d/
- wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
- sudo apt-get update
- sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install postgresql-9.3 postgresql-contrib-9.3 -qq
- sudo /etc/init.d/postgresql stop
- sudo cp ./pg_hba.conf /etc/postgresql/9.3/main
- sudo /etc/init.d/postgresql start
- npm install -g bower
- cp .env_dev .env
- sed -i -e 's/getpass.getuser()/"postgres"/g' sapl/settings.py
- psql -c 'create database sapl;' -U postgres
- cp sapl/.env_test sapl/.env
- psql -c "CREATE USER sapl WITH PASSWORD 'sapl'" -U postgres;
- psql -c "CREATE DATABASE sapl OWNER sapl;" -U postgres
script:
- ./manage.py migrate
- ./manage.py bower install
- pip freeze
- ./test_and_check_qa.sh
- py.test
# - ./test_and_check_qa.sh

5
README.rst

@ -1,6 +1,5 @@
.. image:: https://badge.waffle.io/interlegis/sapl.png?label=ready&title=Ready
:target: https://waffle.io/interlegis/sapl
:alt: 'Stories in Ready'
.. image:: https://travis-ci.org/interlegis/sapl.svg?branch=master
:target: https://travis-ci.org/interlegis/sapl
***********************************************
SAPL - Sistema de Apoio ao Processo Legislativo

4
requirements/requirements.txt

@ -1,4 +1,5 @@
dj-database-url==0.4.1
django==1.9.7
django-admin-bootstrapped==2.5.7
django-bootstrap3==7.0.1
django-bower==5.1.0
@ -10,8 +11,7 @@ django-extra-views==0.8.0
django-filter==0.13.0
django-floppyforms==1.6.2
django-model-utils==2.5
django-sass-processor==0.4.0
django==1.9.7
django-sass-processor==0.4.6
djangorestframework
easy-thumbnails==2.3
git+git://github.com/interlegis/trml2pdf.git

0
.env_dev → sapl/.env_test

19
sapl/crispy_layout_mixin.py

@ -1,12 +1,12 @@
from math import ceil
import rtyaml
from crispy_forms.bootstrap import FormActions
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Div, Fieldset, Layout, Submit
from django import template
from django.utils import formats
from django.utils.translation import ugettext as _
import rtyaml
def heads_and_tails(list_of_lists):
@ -50,8 +50,9 @@ class SaplFormLayout(Layout):
def get_field_display(obj, fieldname):
field = obj._meta.get_field(fieldname)
verbose_name = str(field.verbose_name)
if field.choices:
verbose_name = str(field.verbose_name)\
if hasattr(field, 'verbose_name') else ''
if hasattr(field, 'choices') and field.choices:
value = getattr(obj, 'get_%s_display' % fieldname)()
else:
value = getattr(obj, fieldname)
@ -74,6 +75,14 @@ def get_field_display(obj, fieldname):
value.name.split('/')[-1:][0])
else:
display = ''
elif 'ManyRelatedManager' in str(type(value))\
or 'RelatedManager' in str(type(value)):
display = '<ul>'
for v in value.all():
display += '<li>%s</li>' % str(v)
display += '</ul>'
if not verbose_name:
verbose_name = str(field.related_model._meta.verbose_name_plural)
else:
display = str(value)
return verbose_name, display
@ -147,7 +156,9 @@ class CrispyLayoutFormMixin:
def read_yaml_from_file(yaml_layout):
# TODO cache this at application level
t = template.loader.get_template(yaml_layout)
rendered = t.render()
# aqui é importante converter para str pois, dependendo do ambiente,
# o rtyaml pode usar yaml.CSafeLoader, que exige str ou stream
rendered = str(t.render())
return rtyaml.load(rendered)

2
sapl/static/styles/app.scss

@ -131,9 +131,7 @@ body {
}
}
fieldset {
fieldset {
font-size: 95%;
legend {

Loading…
Cancel
Save