File tree Expand file tree Collapse file tree 5 files changed +31
-13
lines changed
Expand file tree Collapse file tree 5 files changed +31
-13
lines changed Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ DB_PORT=5432
66USERNAME = " piccolo"
77PASSWORD = " piccolo123"
889+ TABLES_TO_SHOW = " "
Original file line number Diff line number Diff line change @@ -7,5 +7,3 @@ COPY ./requirements.txt /code/requirements.txt
77RUN pip install --no-cache-dir -r /code/requirements.txt
88
99COPY ./app /code/app
10-
11- CMD ["python" , "app/main.py" ]
Original file line number Diff line number Diff line change @@ -14,16 +14,16 @@ Creating an `.env` file.
1414cp .env.example .env && rm .env.example
1515```
1616
17- Creating a Docker image .
17+ Run the Docker container .
1818
1919``` bash
20- docker build -t piccolo_admin .
20+ docker-compose up -d
2121```
2222
23- Running a Docker image (use the ` --network=host ` flag for an existing database from the local machine) .
23+ After site is running log in as admin user on [ localhost:8000 ] ( http://localhost:8000 ) and use legacy database .
2424
25- ``` bash
26- docker run --env-file .env -d --network=host --name admin_container piccolo_admin
27- ```
25+ Stop the Docker container.
2826
29- After site is running log in as admin user on [ localhost:8000] ( http://localhost:8000/admin/ ) and use legacy database.
27+ ``` bash
28+ docker-compose down
29+ ```
Original file line number Diff line number Diff line change @@ -60,13 +60,23 @@ async def main():
6060 extensions = tuple (),
6161 )
6262
63+ tables_to_show = [
64+ table_to_show .lower ().strip ()
65+ for table_to_show in os .environ ["TABLES_TO_SHOW" ].split ("," )
66+ ]
67+
6368 storage = TableStorage (engine = db )
6469 await storage .reflect (schema_name = "public" )
6570
66- # This tuple IS unique
67- # however auto_include_related within
68- # create_admin makes it non unique TableConfigs
69- found_tables = storage .tables .values ()
71+ # tables to show in admin
72+ if len (tables_to_show ) == 1 :
73+ found_tables = storage .tables .values ()
74+ else :
75+ found_tables = [
76+ table
77+ for table in storage .tables .values ()
78+ if table ._meta .tablename in tables_to_show
79+ ]
7080
7181 for table_class in found_tables :
7282 table_class ._meta ._db = db
Original file line number Diff line number Diff line change 1+ services :
2+ web :
3+ build : .
4+ command : python app/main.py
5+ volumes :
6+ - .:/app
7+ env_file :
8+ - .env
9+ network_mode : " host"
You can’t perform that action at this time.
0 commit comments