Skip to content

Commit 151aa04

Browse files
committed
Merge branch 'release/v0.1.0'
2 parents 41f0e0f + 72db650 commit 151aa04

21 files changed

+143
-97
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ db.sqlite3
44
__javascript__/
55
node_modules/
66
.pytest_cache/
7-
prod_secret.txt
7+
prod_secrets.json
88
server.egg-info/

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ python:
44
install:
55
- pip install -r requirements.txt
66
- pip install -e src
7-
- echo "travis" > src/server/prod_secret.txt
7+
- cp src/server/mock_secrets.json src/server/prod_secrets.json
88
script:
99
- pytest
10+
branches:
11+
only:
12+
- master
13+
- develop

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
[![Build Status](https://travis-ci.org/metamarcdw/python-fullstack-transcrypt.svg?branch=master)](https://travis-ci.org/metamarcdw/python-fullstack-transcrypt)
1+
[![Build Status](https://travis-ci.org/metamarcdw/python-fullstack-transcrypt.svg?branch=develop)](https://travis-ci.org/metamarcdw/python-fullstack-transcrypt)
22

33
## Example of React and Redux with Python using Transcrypt and Component.py
44
### Also uses Flask-RESTPlus backend with SQLAlchemy and JWT-Extended
55

66
First install Python>=3.6/pip, NodeJS/npm>=5.2, and Git:
77
`sudo pacman -S python-pip npm git`
88
Next, clone the repo
9-
`git clone https://github.com/metamarcdw/react-redux-transcrypt`
9+
`git clone https://github.com/metamarcdw/python-fullstack-transcrypt`
1010
Set up your React/Transcrypt environment:
1111
(Use of a virtual environment is recommended but not required)
1212
```
1313
mkvirtualenv transcrypt
1414
pip install git+https://github.com/qquick/transcrypt@master#egg=transcrypt
1515
pip install git+https://github.com/metamarcdw/Component.py@master#egg=Component_py
1616
17-
cd react-redux-transcrypt/
17+
cd python-fullstack-transcrypt/
1818
npm install
1919
npm install -g babel-cli # If running Windows
2020
```

dist/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "react-transcrypt",
3-
"version": "1.0.0",
2+
"name": "python-fullstack-transcrypt",
3+
"version": "v0.1.0",
44
"description": "",
55
"main": "src/__javascript__/bundle.js",
66
"scripts": {
@@ -12,6 +12,7 @@
1212

1313
"api": "FLASK_APP=server TODOS_FS_MODE=development flask run",
1414
"apiwin": "set FLASK_APP=server&& set TODOS_FS_MODE=development&& flask run",
15+
"apiinit": "pip install -r requirements.txt",
1516
"apiinstall": "pip install -e src",
1617
"apitest": "pytest"
1718
},

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ lazy-object-proxy==1.3.1
1818
MarkupSafe==1.0
1919
mccabe==0.6.1
2020
more-itertools==4.2.0
21+
mysqlclient==1.3.13
2122
pluggy==0.6.0
2223
py==1.5.3
2324
pycodestyle==2.4.0

src/components/App.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from containers.TodoListContainer import TodoListContainer
77

88
React = require("react")
9-
Row, Col, Jumbotron = destruct(
10-
require("reactstrap"), "Row", "Col", "Jumbotron")
9+
Form, Row, Col, Jumbotron = destruct(
10+
require("reactstrap"), "Form", "Row", "Col", "Jumbotron")
1111

1212

1313
def App(props):
@@ -19,12 +19,20 @@ def render_login_panel():
1919
</div>
2020
); """)
2121

22+
def on_submit(e):
23+
e.preventDefault()
24+
2225
def render_todo_panel():
2326
return __pragma__("xtrans", None, "{}", """ (
2427
<div>
2528
<TodoListContainer />
26-
<FormPanelContainer />
27-
<ButtonPanelContainer />
29+
<Form
30+
className="padding"
31+
onSubmit={on_submit}
32+
>
33+
<FormPanelContainer />
34+
<ButtonPanelContainer />
35+
</Form>
2836
</div>
2937
); """)
3038

src/components/ButtonPanel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def on_click_logout():
2727
className="fixed-height"
2828
onClick={on_click_add}
2929
color="success"
30+
type="submit"
3031
>Add Todo</Button>
3132
<Button
3233
className="fixed-height"

src/components/FormPanel.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22
from Component_py.component import destruct
33

44
React = require("react")
5-
Form, FormGroup, Label, Input = destruct(
6-
require("reactstrap"), "Form", "FormGroup", "Label", "Input")
5+
FormGroup, Label, Input = destruct(
6+
require("reactstrap"), "FormGroup", "Label", "Input")
77

88

99
def FormPanel(props):
1010
def on_text_change(e):
1111
props.form_panel_update(e.target.value)
1212

1313
return __pragma__("xtrans", None, "{}", """ (
14-
<Form className="padding">
15-
<FormGroup>
16-
<Label for="text_input">Enter new todo text:</Label>
17-
<Input
18-
onChange={on_text_change}
19-
value={props.form_panel.text}
20-
id="text_input"
21-
placeholder="What to do?" />
22-
</FormGroup>
23-
</Form>
14+
<FormGroup>
15+
<Label for="text_input">Enter new todo text:</Label>
16+
<Input
17+
onChange={on_text_change}
18+
value={props.form_panel.text}
19+
id="text_input"
20+
placeholder="What to do?" />
21+
</FormGroup>
2422
); """)

src/components/TodoList.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from Component_py.stubs import require, __pragma__ # __:skip
1+
from Component_py.stubs import require, __pragma__, window # __:skip
22
from Component_py.component import Component, destruct
33

44
React = require("react")
@@ -23,7 +23,14 @@ def closure():
2323

2424
def on_click_delete(self, todo):
2525
token = self.props.login_user["token"]
26-
return lambda: self.props.delete_todo(todo["id"], token)
26+
27+
def closure():
28+
should_delete = True
29+
if not todo["complete"] and not window.confirm("Delete incomplete Todo?"):
30+
should_delete = False
31+
if should_delete:
32+
self.props.delete_todo(todo["id"], token)
33+
return closure
2734

2835
def render_spinner(self):
2936
loading = True
@@ -61,6 +68,7 @@ def render_list_item(self, todo):
6168
className="fixed-height margin"
6269
color="primary"
6370
onClick={self.on_click_complete(todo)}
71+
disabled={todo.complete}
6472
>Complete</Button>
6573
<Button
6674
className="fixed-height"

0 commit comments

Comments
 (0)