2 Commits b844ecf48b ... 327f7b053e

Author SHA1 Message Date
  Iuri Guilherme 327f7b053e RGSoC 2020 4 years ago
  Iuri Guilherme f88d6480b0 Consertando links para empresa 4 years ago

+ 91 - 153
README.md

@@ -1,7 +1,7 @@
-goworking-mesas
+goworking-map
 ===
 
-Sistema para controle das mesas do Go Working da Fábrica do Futuro.  
+System to aid control of desks at Fábrica do Futuo's Go Working.  
 
 Copyright (C) 2019-2020 Fábrica do Futuro  
 
@@ -18,163 +18,101 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License  
 along with this program.  If not, see <http://www.gnu.org/licenses/>.  
 
-Releases
+i18n
 ---
 
-### v 0.1
+* [English](./README.md)  
+* [Português Brasileiro](./README.pt.md)  
 
-Data de entrega: Sexta Feira, 06 de dezembro de 2019  
-
-#### Escopo
-
-* Ethiele deve conseguir visualizar as mesas do goworking;  
-* Ethiele deve conseguir visualizar quais cadeiras estão ocupadas, por
-  quem, de que empresa;  
-* Ethiele deve conseguir editar informações sobre cadeiras, pessoas,
-  empresas;  
-
-### v 0.2
-
-Data de entrega: Sexta Feira, 12 de dezembro de 2019  
-
-* Todos cadastros funcionando (habitantes e empresas, além de espaços,
-  mesas e cadeiras);  
-* Atualizar dados não está funcionando corretamente. Para alterar
-  informações é necessário recadastrar;  
-
-### v 0.3
-
-Data de entrega: Quarta Feira, 25 de dezembro de 2019  
-
-* Editar habitantes e empresas está funcionando corretamente;  
-* Somente funções pertinentes aparecem pra a Ethiele;  
-* Alterações de UX específicas para a Ethiele:  
-  * Ao clicar em uma cadeira vazia, é exibido um botão de adicionar novo
-    habitante com formulário específico para este fim;  
-
-### v 0.4
-
-Data de entrega: Sexta feira, 10 de janeiro de 2020  
-
-* Correta exibição e gravação de CPF e CNPJ;  
-
-Roadmap
 ---
 
-TODO:
-
-- [ ] Documentar como usar com pipenv  
-- [ ] Aumentar de 4 para 5 colunas o esqueleto, acrescentar as cabines  
-- [ ] Ampliar o escopo do sistema com novas blueprints para contemplar
-  outras funcionalidades  
-- [ ] Migrar login para fora da blueprint do goworking  
-- [ ] Alterar nomes dos arquivos para por exemplo view_habitante.py,
-  model_habitante.py, etc.  
-
-Instruções
+RGSoC 2020
 ---
 
-Na eventualidade de algum dia alguém ler as instruções de instalação.  
-
-### git
-
-Clonar o repositório com o código fonte.  
-
-    git clone https://notabug.org/fabricadofuturo/goworking-mesas.git
-
-### Preparar Python e Flask
-
-Eu uso *pipenv*. Como instalar pipenv está fora do escopo deste guia.  
-
-    mkdir instance
-    cp default_config.py instance/config.py
-    cp default_env .env
-
-Editar os arquivos `.env` e `instance/config.py` com os dados de configuração
-do Flask, do SQLAlchemy, do WTForms, etc.  
-
-O mínimo necessário é definir os dados do banco de dados. Por exemplo, no 
-arquivo *.env*:  
-
-    DATABASE_URL=mysql+pymysql://usuario:senha@localhost/goworking
+This project is part of Rails of Girls Summer of Code 2020. The offical 
+page for this project is at the 
+[RGSoC Teams App](https://teams.railsgirlssummerofcode.org/projects/366-improve-the-desks-control-system-for-the-coworking).  
+
+### Description
+
+The "Go Working Map" started as a web form to aid the control of the 
+desks at 
+[Fábrica do Futuro's Go Working](https://fabricadofuturo.com/en/#terreo). 
+Then it evolved to a system where all inhabitants of 
+[Fábrica do Futuro](https://fabricadofuturo/en/) could find information 
+on each other's startup and business, effectively providing a virtual 
+place as a means for exchanges.  
+
+Because the project wasn't meant for this purpose, the code - 
+originally a simple collection of Flask-WTF html forms - needs 
+refactoring. The current code base is not suited for the stakeholder's 
+demands on the project.  
+
+Ideally the website should be able to include more information about 
+[Fábrica do Futuro](https://fabricadofuturo.com/en/)'s inhabitants. 
+People should be able to update their own information and share it with 
+others, pretty much like a regular social network. End users should be 
+able to request additional functionality and the scope of the project 
+shall be easily expanded on demand.  
+
+Since this is a Libre Software project, the team shall bear in mind 
+that contributions to this project could and ideally would improve 
+other co-workings worldwide. So that should be taken into account in 
+the development process.  
+
+[Fábrica do Futuro](https://fabricadofuturo.com/en/) has infrastructure 
+at Porto Alegre - Brasil to house the team working on the project so 
+the team will be directly affected by this project, at least 
+temporarily - but you're welcome to stay here after the SoC! ;) - and 
+we would expect from the team much feedback on the system and that you 
+participate on defining it's scope and suggest new functionalities, 
+even if they will have to be implemented by others.  
+
+Team will have full access to the 
+[Fábrica do Futuro's Go Working](https://fabricadofuturo.com/en/#terreo) 
+as if they were inhabitants. This includes but is not limited to 
+electrical and caffeine power, access to high speed wireless internet 
+(and by July gigabit ethernet on all desks), bathrooms, showers, 
+meditation room, call booths, meeting rooms, living spaces, a retro 
+games emulator and happy smiles everywhere.  
+
+### Tasks and features
+
+Things that should be done:  
+
+* The project needs someone  who can research and implement a proper 
+[ACL](https://en.wikipedia.org/wiki/Access-control_list) which will be 
+responsible to enforce the business rules to display information to 
+logged in users;  
+* Personal information of companies and individuals should be stored 
+and used respecting the Brazilian pertinent legislation the 
+[LGPD](http://www.planalto.gov.br/ccivil_03/_ato2015-2018/2018/lei/L13709.htm). 
+We have mentoring on that, you don't need to do legal research;  
+* We currently only have a web interface built on Flask itself. It 
+would be nice to have an Android/iOS application that we could provide 
+to people who prefer that interface, but that's not the main goal;  
+* Users requested some sort of job board so startups could advertise to 
+each other (or maybe externally?) with what and how they need help. 
+Perhaps you could help to make the very code that will help you find 
+your next contractor or business partner ;)  
+
+Don't worry about taking care of all these tasks. You may freely select 
+which ones you feel more comfortable working on. You may even propose 
+other tasks and if they make sense, we can change the scope of the 
+project accordingly.  
+
+### Requirements
+
+The programming language of the project is Python since it's already 
+written using the [Flask](https://flask.palletsproject.com) framework.  
+
+For the optional Android/iOS app, you are free to choose the technology 
+used.  
+
+### Tags
+
+Python, Flask, LGPD, Jinja, Bootstrap, MySQL, SQLAlchemy  
 
-    user@server:goworking-mesas$ pipenv install
-
-### Banco de dados
-
-É possível usar qualquer tipo de sistema gerenciador de banco de dados que 
-funcione com o Flask SQL Alchemy. Estas instruções são para usar MariaDB:  
-
-#### Instalar MariaDB Server
-
-MariaDB é a versão GPL do MySQL.  
-No debian: `sudo apt install mariadb-server`;  
-
-#### Alterar usuário e senha
-
-Alterar o arquivo de criação do banco de dados localizado em *doc/mysql.sql*:
-
-    CREATE DATABASE goworking DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;
-    GRANT ALL PRIVILEGES ON goworking.* to usuario@'localhost' IDENTIFIED BY 'senha';
-
-Mudar "usuario" para algum nome de usuário e "senha" para alguma senha.
-
-#### Rodar script de criação
-
-Acessar o mariadb-client, copiar e colar os comandos ou rodar o script.
-
-No debian: `sudo mysql`
-
-    MariaDB [(none)]> SOURCE doc/mysql.sql;
-    Query OK, 1 row affected (0.001 sec)
-    
-    Query OK, 0 rows affected (0.001 sec)
-    
-    MariaDB [(none)]> SHOW DATABASES;
-    +--------------------+
-    | Database           |
-    +--------------------+
-    | goworking          |
-    | information_schema |
-    | mysql              |
-    | performance_schema |
-    +--------------------+
-    4 rows in set (0.001 sec)
-
-Se o que tiver disponível for um PHPMyAdmin ou coisa parecida, descobrir como é 
-o jeito difícil de colar estes comandos simples nesse sistema complicado.  
-
-#### flask-migrate
-
-    user@server:goworking-mesas$ pipenv run flask db init
-    Loading .env environment variables...
-    user@server:goworking-mesas$ pipenv run flask db upgrade
-    Loading .env environment variables...
-    INFO  [alembic.runtime.migration] Context impl MySQLImpl.
-    INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
-    INFO  [alembic.runtime.migration] Running upgrade  -> fead50b08d21, empty message
-    INFO  [alembic.runtime.migration] Running upgrade fead50b08d21 -> dc7d560eee94, empty message
-
-### gunicorn
-
-Eu uso systemd.  
-
-Tem um arquivo do systemd de exemplo em *doc/gunicorn-goworking.service*.  
-
-    user@server:goworking-mesas$ sudo cp gunicorn-goworking.service /lib/systemd/system/
-    user@server:goworking-mesas$ sudo systemctl enable gunicorn-goworking.service
-    user@server:goworking-mesas$ sudo systemctl start gunicorn-goworking.service
-
-### Nginx
-
-Arquivo de exemplo em *doc/goworking.conf*.  
-
-    user@server:goworking-mesas$ sudo cp doc/goworking.conf /etc/nginx/sites-available/
-    user@server:goworking-mesas$ pushd /etc/nginx/sites-enabled
-    user@server:/etc/nginx/sites-enabled$ sudo ln -s ../sites-available/goworking.conf
-    user@server:/etc/nginx/sites-enabled$ popd
-    user@server:goworking-mesas$ sudo nginx -t
-    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
-    nginx: configuration file /etc/nginx/nginx.conf test is successful
-    user@server:goworking-mesas$ sudo systemctl -l reload nginx.service
+---
 
+TODO: Translate to english the rest of the README  

+ 196 - 0
README.pt.md

@@ -0,0 +1,196 @@
+goworking-map
+===
+
+Sistema para controle das mesas do Go Working da Fábrica do Futuro.  
+
+Copyright (C) 2019-2020 Fábrica do Futuro  
+
+This program is free software: you can redistribute it and/or modify  
+it under the terms of the GNU General Public License as published by  
+the Free Software Foundation, either version 3 of the License, or  
+(at your option) any later version.  
+
+This program is distributed in the hope that it will be useful,  
+but WITHOUT ANY WARRANTY; without even the implied warranty of  
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
+GNU General Public License for more details.  
+
+You should have received a copy of the GNU General Public License  
+along with this program.  If not, see <http://www.gnu.org/licenses/>.  
+
+i18n
+---
+
+* [English](./README.md)  
+* [Português Brasileiro](./README.pt.md)  
+
+---
+
+RGSoC 2020
+---
+
+**(Somente em inglês)**  
+
+This project is part of Rails of Girls Summer of Code 2020. The offical 
+page for this project is at the 
+[RGSoC Teams App](https://teams.railsgirlssummerofcode.org/projects/366-improve-the-desks-control-system-for-the-coworking).  
+
+Releases
+---
+
+### v 0.1
+
+Data de entrega: Sexta Feira, 06 de dezembro de 2019  
+
+#### Escopo
+
+* Ethiele deve conseguir visualizar as mesas do goworking;  
+* Ethiele deve conseguir visualizar quais cadeiras estão ocupadas, por
+  quem, de que empresa;  
+* Ethiele deve conseguir editar informações sobre cadeiras, pessoas,
+  empresas;  
+
+### v 0.2
+
+Data de entrega: Sexta Feira, 12 de dezembro de 2019  
+
+* Todos cadastros funcionando (habitantes e empresas, além de espaços,
+  mesas e cadeiras);  
+* Atualizar dados não está funcionando corretamente. Para alterar
+  informações é necessário recadastrar;  
+
+### v 0.3
+
+Data de entrega: Quarta Feira, 25 de dezembro de 2019  
+
+* Editar habitantes e empresas está funcionando corretamente;  
+* Somente funções pertinentes aparecem pra a Ethiele;  
+* Alterações de UX específicas para a Ethiele:  
+  * Ao clicar em uma cadeira vazia, é exibido um botão de adicionar novo
+    habitante com formulário específico para este fim;  
+
+### v 0.4
+
+Data de entrega: Sexta feira, 10 de janeiro de 2020  
+
+* Correta exibição e gravação de CPF e CNPJ;  
+
+Roadmap
+---
+
+TODO:
+
+- [ ] Documentar como usar com pipenv  
+- [ ] Aumentar de 4 para 5 colunas o esqueleto, acrescentar as cabines  
+- [ ] Ampliar o escopo do sistema com novas blueprints para contemplar
+  outras funcionalidades  
+- [ ] Migrar login para fora da blueprint do goworking  
+- [ ] Alterar nomes dos arquivos para por exemplo view_habitante.py,
+  model_habitante.py, etc.  
+
+Instruções
+---
+
+Na eventualidade de algum dia alguém ler as instruções de instalação.  
+
+### git
+
+Clonar o repositório com o código fonte.  
+
+    git clone https://notabug.org/fabricadofuturo/goworking-mesas.git
+
+### Preparar Python e Flask
+
+Eu uso *pipenv*. Como instalar pipenv está fora do escopo deste guia.  
+
+    mkdir instance
+    cp default_config.py instance/config.py
+    cp default_env .env
+
+Editar os arquivos `.env` e `instance/config.py` com os dados de configuração
+do Flask, do SQLAlchemy, do WTForms, etc.  
+
+O mínimo necessário é definir os dados do banco de dados. Por exemplo, no 
+arquivo *.env*:  
+
+    DATABASE_URL=mysql+pymysql://usuario:senha@localhost/goworking
+
+    user@server:goworking-mesas$ pipenv install
+
+### Banco de dados
+
+É possível usar qualquer tipo de sistema gerenciador de banco de dados que 
+funcione com o Flask SQL Alchemy. Estas instruções são para usar MariaDB:  
+
+#### Instalar MariaDB Server
+
+MariaDB é a versão GPL do MySQL.  
+No debian: `sudo apt install mariadb-server`;  
+
+#### Alterar usuário e senha
+
+Alterar o arquivo de criação do banco de dados localizado em *doc/mysql.sql*:
+
+    CREATE DATABASE goworking DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_bin;
+    GRANT ALL PRIVILEGES ON goworking.* to usuario@'localhost' IDENTIFIED BY 'senha';
+
+Mudar "usuario" para algum nome de usuário e "senha" para alguma senha.
+
+#### Rodar script de criação
+
+Acessar o mariadb-client, copiar e colar os comandos ou rodar o script.
+
+No debian: `sudo mysql`
+
+    MariaDB [(none)]> SOURCE doc/mysql.sql;
+    Query OK, 1 row affected (0.001 sec)
+    
+    Query OK, 0 rows affected (0.001 sec)
+    
+    MariaDB [(none)]> SHOW DATABASES;
+    +--------------------+
+    | Database           |
+    +--------------------+
+    | goworking          |
+    | information_schema |
+    | mysql              |
+    | performance_schema |
+    +--------------------+
+    4 rows in set (0.001 sec)
+
+Se o que tiver disponível for um PHPMyAdmin ou coisa parecida, descobrir como é 
+o jeito difícil de colar estes comandos simples nesse sistema complicado.  
+
+#### flask-migrate
+
+    user@server:goworking-mesas$ pipenv run flask db init
+    Loading .env environment variables...
+    user@server:goworking-mesas$ pipenv run flask db upgrade
+    Loading .env environment variables...
+    INFO  [alembic.runtime.migration] Context impl MySQLImpl.
+    INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
+    INFO  [alembic.runtime.migration] Running upgrade  -> fead50b08d21, empty message
+    INFO  [alembic.runtime.migration] Running upgrade fead50b08d21 -> dc7d560eee94, empty message
+
+### gunicorn
+
+Eu uso systemd.  
+
+Tem um arquivo do systemd de exemplo em *doc/gunicorn-goworking.service*.  
+
+    user@server:goworking-mesas$ sudo cp gunicorn-goworking.service /lib/systemd/system/
+    user@server:goworking-mesas$ sudo systemctl enable gunicorn-goworking.service
+    user@server:goworking-mesas$ sudo systemctl start gunicorn-goworking.service
+
+### Nginx
+
+Arquivo de exemplo em *doc/goworking.conf*.  
+
+    user@server:goworking-mesas$ sudo cp doc/goworking.conf /etc/nginx/sites-available/
+    user@server:goworking-mesas$ pushd /etc/nginx/sites-enabled
+    user@server:/etc/nginx/sites-enabled$ sudo ln -s ../sites-available/goworking.conf
+    user@server:/etc/nginx/sites-enabled$ popd
+    user@server:goworking-mesas$ sudo nginx -t
+    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
+    nginx: configuration file /etc/nginx/nginx.conf test is successful
+    user@server:goworking-mesas$ sudo systemctl -l reload nginx.service

+ 1 - 1
blueprints/goworking/templates/habitante.html

@@ -146,7 +146,7 @@
             <td>{{ habitante.nome }}</td>
             <td>{{ habitante.cpf|cpf }}</td>
             <td>{{ habitante.desc }}</td>
-            <td><a href="{{ url_for('goworking.empresa', empresa = habitante.id_empresa) }}" target="_self">{{ habitante.empresa.nome }}</a></td>
+            <td><a href="{{ url_for('goworking.empresa_editar', id = habitante.empresa.id) }}" target="_self">{{ habitante.empresa.nome }}</a></td>
             <td>{{ habitante.cadeira.numero }}</td>
             <td>{% if habitante.cadeira.mesa %}{{ habitante.cadeira.mesa.numero }}{% endif %}</td>
             <td>{{ habitante.data_entrada|data }}</td>

+ 3 - 3
blueprints/goworking/templates/index.html

@@ -334,7 +334,7 @@
           class="btn btn-info"
           href="{{
             url_for(
-              'goworking.empresa',
+              'goworking.empresa_editar',
               id = empresa.id,
             )
           }}"
@@ -404,8 +404,8 @@
           class="btn btn-info"
           href="{{
             url_for(
-              'goworking.cadeira',
-              cadeira_id = cadeira.id,
+              'goworking.cadeira_editar',
+              id = cadeira.id,
             )
           }}"
         >Editar informa&ccedil;&otilde;es da cadeira</a>

+ 0 - 1
blueprints/goworking/views/__init__.py

@@ -70,4 +70,3 @@ from blueprints.goworking.views import (
   empresa,
   habitante,
 )
-

+ 4 - 2
blueprints/goworking/views/habitante.py

@@ -161,7 +161,7 @@ def habitante():
     abort(500, str(e))
   abort(500)
 
-@bp.route('/habitante/<string:id_cadeira>', methods=['GET', 'POST'])
+@bp.route('/habitante/cadeira/<string:id_cadeira>', methods=['GET', 'POST'])
 @login_required
 def habitante_cadeira(id_cadeira = custom_uuid.nil_uuid):
   try:
@@ -235,7 +235,7 @@ def habitante_cadeira(id_cadeira = custom_uuid.nil_uuid):
         mensagem = u"Cadeira já está ocupada, escolha outra!"
         flash(mensagem, 'danger')
         return redirect(url_for(
-          'goworking.habitante',
+          'goworking.habitante_cadeira',
           nome = form.nome.data,
           cpf = form.cpf.data,
           desc = form.desc.data,
@@ -392,6 +392,8 @@ def habitante_editar(id = custom_uuid.nil_uuid):
     abort(500, str(e))
   abort(500)
 
+## TODO Confirmar antes de apagar. Atualmente é muito fácil apagar sem 
+## querer.
 @bp.route(
   '/habitante/apagar/<string:id>',
   methods=['GET', 'POST', 'DELETE'],