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

Docker and overall update #198

Open
wants to merge 129 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
96ab607
merge pulls requests
ClemsP May 10, 2021
9816d4d
Update dependencies OpenRepairPlatform
LucienD May 10, 2021
f7238c9
add id in stock create success message
ClemsP May 11, 2021
1afb51e
add immited fiels in reccurent events form
ClemsP May 11, 2021
0a7811b
flake8 and black project
LucienD May 11, 2021
b5198a8
fix datetime form error
ClemsP May 11, 2021
aff5f0a
add publish infos on event template
ClemsP May 11, 2021
1441c9e
Merge remote-tracking branch 'origin/fix/duplicate_user' into dev_branch
ClemsP May 11, 2021
e926c3b
WIP: repare test
LucienD May 12, 2021
4c9bf42
Fixed current test
LucienD May 17, 2021
b5527cc
display publish date
ClemsP May 17, 2021
7fd5d80
Clean assets
ClemsP May 21, 2021
c1367b8
clean assets
ClemsP May 21, 2021
8eab285
delete useless templates
ClemsP May 21, 2021
5dc46fb
clean assets, ass bootstrap 5 and arrange events_list template
ClemsP May 25, 2021
7c7ac2a
Update event usage
LucienD May 25, 2021
c1c4f84
bootstrap changes
ClemsP May 25, 2021
94f26db
add migrations
LucienD May 25, 2021
d579996
coverage tests - fix js autocomplete user
LucienD May 26, 2021
7621719
Generic method to send mail - Add DJANGO_FROM_EMAIL global variable i…
LucienD May 27, 2021
fb0cb62
Add command to remove inactive user two weeks after - Add this comman…
LucienD May 27, 2021
b55a093
Add ical view to get file ics with events sorted by organization
LucienD May 27, 2021
5d86a9c
Templating
ClemsP May 28, 2021
4cd8faf
Merge branch 'update_app_dependencies' of https://github.com/AtelierS…
ClemsP May 28, 2021
9115aa3
Add ics detail event
LucienD May 28, 2021
64d49f0
Add event admin view
LucienD May 28, 2021
c7edf0a
Merge remote-tracking branch 'origin/update_app_dependencies' into de…
ClemsP May 28, 2021
10e5126
delete feed.html
ClemsP May 28, 2021
1aa87e1
Merge remote-tracking branch 'origin/event_to_ical_by_orga' into dev_…
ClemsP May 28, 2021
5be497f
Merge remote-tracking branch 'origin/cron_command_delete_inactive_use…
ClemsP May 28, 2021
01df7b9
Merge remote-tracking branch 'origin/generic_send_mail' into dev_branch
ClemsP May 28, 2021
2a546df
merge fix
ClemsP May 28, 2021
1b672f9
clean
ClemsP May 28, 2021
16e987a
Fix merge - Add view to send invitation
LucienD May 28, 2021
482317b
sass changes
ClemsP Jun 6, 2021
3fd4ea9
templating event app
ClemsP Jun 19, 2021
0d26376
templating
ClemsP Jun 20, 2021
a40869e
change python docker version
ClemsP Jun 29, 2021
db64aa0
Merge branch 'dev_branch' of https://github.com/AtelierSoude/OpenRepa…
ClemsP Jun 29, 2021
9e48323
settings
ClemsP Jun 29, 2021
8f8c9fe
fix django assets version
ClemsP Jul 2, 2021
9bb92b7
Optimisation debug template and prefetch
LucienD Jul 5, 2021
f1343da
limit queries
ClemsP Jul 13, 2021
84f8bb0
debugs
ClemsP Sep 8, 2021
286265a
Merge remote-tracking branch 'origin/fix_publish' into prod_debug
ClemsP Sep 8, 2021
33d9801
fix
ClemsP Sep 8, 2021
0857747
fixes
ClemsP Sep 8, 2021
955e08f
Merge remote-tracking branch 'origin/fix_publish' into prod_debug
ClemsP Sep 8, 2021
a5da82f
fix event publish
ClemsP Sep 8, 2021
92e4cec
add migration
ClemsP Sep 8, 2021
07cf087
Merge remote-tracking branch 'origin/fix_publish' into prod_debug
ClemsP Sep 8, 2021
481edef
fix merge
ClemsP Sep 8, 2021
5dc706e
fix publication
ClemsP Sep 8, 2021
a28aff7
comment cron
ClemsP Dec 7, 2021
d2734cb
undo .env
ClemsP Dec 7, 2021
fb7e85b
change gitignore
ClemsP Dec 7, 2021
eef07cb
delete .env
ClemsP Dec 7, 2021
0610075
Fix bug membership on fees :
LucienD Dec 10, 2021
538093a
Fix open API to users
LucienD Dec 11, 2021
dedf620
Fix timezone on ical views and fix test events
LucienD Dec 12, 2021
29c7072
correct reference fee template
ClemsP Dec 12, 2021
ee3a2bc
fix computed payment
LucienD Dec 12, 2021
f65827c
Merge pull request #135 from AtelierSoude/feature/membership_no_updat…
ClemsP Dec 12, 2021
bd6d029
Merge pull request #137 from AtelierSoude/fix/timezone_ical
ClemsP Dec 12, 2021
5fc9c11
Merge branch 'dev_branch' of https://github.com/AtelierSoude/OpenRepa…
ClemsP Dec 12, 2021
b0e331b
Change permissions to All manager orga
LucienD Dec 12, 2021
67d6c2e
Merge pull request #136 from AtelierSoude/fix/api_user
ClemsP Dec 12, 2021
298b662
fix events templates
ClemsP Dec 12, 2021
8be76ca
correct copytoclipboard event ical
ClemsP Dec 12, 2021
27c5986
use Membership insteed of CustomUser in MemberTable view
ClemsP Dec 12, 2021
6692269
template event list
ClemsP Dec 12, 2021
42f5334
Merge pull request #138 from AtelierSoude/fix/templates
ClemsP Dec 12, 2021
188e791
Fix bug fees and add script to fix old data
LucienD Dec 15, 2021
a77c787
Fix templatetags Fees on user
LucienD Dec 15, 2021
dda301d
Fix bug fee linked to user and add button fee in user detail view
LucienD Dec 17, 2021
ef6bcb0
Merge pull request #140 from AtelierSoude/feature/add_fee_member_page
LucienD Dec 17, 2021
bc7929b
Update Dockerfile
LucienD Dec 17, 2021
19480d2
Fix sass
LucienD Dec 17, 2021
8bb8f08
fix sass
LucienD Dec 17, 2021
933a5bf
fix sass
LucienD Dec 17, 2021
bbbdf06
fix scss
LucienD Dec 19, 2021
9a57eff
update bootstrap add delete bootstrapcustom assets
ClemsP Jan 7, 2022
8fb6d93
Add location in Open repair platform
LucienD Jan 7, 2022
c916462
add jquery npm
ClemsP Jan 7, 2022
1884d54
update dockerfile
ClemsP Jan 7, 2022
5afb46e
Merge branch 'fix/css' into dev_branch
ClemsP Jan 7, 2022
8a19d3e
spelling mistake
ClemsP Jan 7, 2022
93a8199
add docker without let's encrypt
ClemsP Jan 15, 2022
29bfc46
Merge branch 'dev_branch' into feature/location
ClemsP Jan 15, 2022
ee9e14e
Merge pull request #141 from AtelierSoude/feature/location
ClemsP Jan 15, 2022
3d91a9b
Add app vuejs to create and update event - WIP : Add api views and se…
LucienD Jan 15, 2022
f3f86b3
merge localization
ClemsP Jan 15, 2022
30ca273
add nginx no certificat
ClemsP Jan 15, 2022
b0b6127
add postgis docker support
ClemsP Jan 15, 2022
ce65b10
change gonnette to monnaie locale
ClemsP Jan 15, 2022
00f826f
css updates
ClemsP Jan 17, 2022
4964c9e
css change
ClemsP Jan 17, 2022
efc7d09
create docker letsencrypt
ClemsP Jan 23, 2022
7a3e86c
update settings
ClemsP Jan 23, 2022
7c89a09
comment ssl params
ClemsP Jan 23, 2022
b0a4bcf
update letsencrpyt docker
ClemsP Jan 23, 2022
e196e44
letsencrypt automation OK
ClemsP Jan 23, 2022
7d34be0
Merge pull request #153 from AtelierSoude/update_docker
ClemsP Jan 23, 2022
ef83daf
update css
ClemsP Jan 23, 2022
52d2017
update branch with dev_branch updates
ClemsP Jan 23, 2022
7e5f832
update organization menu html
ClemsP Jan 23, 2022
c07c709
Merge branch 'dev_fr_suisse' into dev_branch
ClemsP Jan 23, 2022
0fc93b8
display organizers in event cards
ClemsP Jan 23, 2022
2a937e5
merge dev_branch
LucienD Jan 15, 2022
3b03480
re-add reccurent event button
ClemsP Jan 23, 2022
6c7adfd
Merge branch 'dev_fr_suisse' into dev_branch
ClemsP Jan 23, 2022
3093858
add ommitted email_from variable
ClemsP Feb 3, 2022
9dde627
merge dev_branch
LucienD Feb 13, 2022
769c674
Location managing in settings file with variable env
LucienD Feb 13, 2022
632fe58
css updates
ClemsP Feb 13, 2022
5c0acc8
$merge
ClemsP Feb 13, 2022
a299dd6
Merge branch 'dev_branch' into HEAD
ClemsP Feb 13, 2022
843a1d2
merge
ClemsP Feb 13, 2022
a56ff6a
Merge remote-tracking branch 'origin/dev_fr_suisse' into HEAD
ClemsP Feb 13, 2022
b75beeb
debugg deployment issues
ClemsP Feb 14, 2022
eaffcfb
.env
ClemsP Feb 14, 2022
555c093
Changed plural from Activitys to Activities
Skrattoune Mar 9, 2022
0c0ca4b
Merge pull request #161 from Skrattoune/patch-5
ClemsP Mar 11, 2022
e9a7613
loading images from atelier-soude in https
Skrattoune Mar 19, 2022
cef03e0
add abbility to import/export inventory tables in json format
ClemsP Mar 25, 2022
9fca7c8
Merge pull request #163 from Skrattoune/patch-6
ClemsP Mar 25, 2022
e0a4600
Merge pull request #164 from AtelierSoude/add/import-export
ClemsP Mar 25, 2022
aac3692
Docker and overall update (#197)
gdnthomas Mar 4, 2024
9d472e1
try repair modal
ClemsP Apr 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 12 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
Expand Down Expand Up @@ -81,16 +80,10 @@ celerybeat-schedule
*.sage.py

# dotenv
deployment/django/django.env
openrepairplatform/.env
deployment/postgres/postgres.env
deployment/nginx/nginx.env
.env
.env.prod

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
Expand Down Expand Up @@ -150,7 +143,7 @@ media
tmp
*.min.js
*.min.css
openrepairplatform/static/css
openrepairplatform/static/css/*.css
openrepairplatform_static/
!openrepairplatform_static/img/*
openrepairplatform_media/
Expand All @@ -173,3 +166,13 @@ openrepairplatform/static/node_modules/
openrepairplatform/static/js/vue/app.js
openrepairplatform/static/css/vue-app.css

openrepairplatform/static/js/vue.apps.bundle.js
openrepairplatform/static/js/vue.apps.bundle.css


# Dumps de bases
*dump_*.sql
*dump_*.sql.gzip
*dump_*.sql.zip
*dump_*.sql.gz
deployment/nginx/shared/*
20 changes: 4 additions & 16 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
// Pointez pour afficher la description des attributs existants.
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
"configurations": [
{
"name": "Debug Django app",
"type": "python",
Expand All @@ -16,17 +16,5 @@
}],
//"preLaunchTask": "Docker Restart",
},
{
"name": "Debug integration tests",
"type": "python",
"request": "attach",
"port": 5679,
"host": "localhost",
"pathMappings": [{
"localRoot": "${workspaceFolder}/openrepairplatform/integration_tests",
"remoteRoot": "/tests"
}],
// "preLaunchTask": "runtests"
}
]
}
11 changes: 9 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{
"restructuredtext.confPath": "",
"python.pythonPath": "/Users/clementpoudret/env/ateliersoude/bin/python"
}
"python.pythonPath": "/usr/lib/python3.10",
"git.ignoreLimitWarning": true,
"html.format.enable": true,
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8"
},
"python.formatting.provider": "none",

}
216 changes: 198 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ Ce projet cherche à faciliter l’accessibilité de la réparation par le plus
OpenRepairPlateform est une application basée sur Django, pensée pour organiser les structures de réparations participatives.
Elle intègre principalement des fonctionnalités de gestion d'organisation, de membres, de comptabilité, la publication d'événements, d'inventaire et de suivi/partage de réparations.

Cette application est développée et notamment utilisée par [l'Atelier Soudé](https://atelier-soude.fr) pour la plateforme [Réparons](https://dev.atelier-soude.fr).

Toute la documentation d'installation et d'utilisation est disposible [ici](https://openrepairplatform.readthedocs.io/en/latest/).
Cette application est développée et notamment utilisée par [l'Atelier Soudé](https://atelier-soude.fr).

----- ENG -----

This application is still in developpment.
Any contributes are welcome. Please contact us if you want to contribute and we tell you how to.

# Atelier Soudé

OpenRepairPlatform is a Django based application designed to organize collaborative repair structures, features provides organization managment, event publishing, community members managment, repair tracking and sharing.

The plateform is created by Atelier Soudé, an organization which repair everyday's people electric and electronic objects in Lyon, France.
Expand All @@ -25,18 +21,207 @@ Full installation and user documentation are avalaible [here](https://openrepair

For basic develop installation, follow those steps:

## Run the application (in Develop mode only)
## Run the application in production mode

1 - set up the environment

```bash
git clone https://github.com/AtelierSoude/OpenRepairPlatform.git
cd OpenRepairPlatform
touch .env
```

2 - Populate the envfile with the following content. Make sure to change the vars.

```bash
#default content of the configuration .env file
# Activate the location search on home page
LOCATION=1

#DJANGO settings for configuration dev or production
DJANGO_SETTINGS_MODULE=openrepairplatform.settings.dev
SECRET_KEY=CHANGE_ME

# To activate the debug mode, set the environment variable to True
DEBUG=true
PREPROD=True # !!! to keep robots from indexing preprod pages. Change to False on Production server

#Emailing settings only used in production mode
EMAIL_PASSWORD=CHANGE_ME
EMAIL_HOST_USER=CHANGE_ME
EMAIL_HOST=CHANGE_ME
DEFAULT_FROM_EMAIL=no-reply@reparons.org

#Let's encrypt and nginx settings
#The principal domain that django will use
DOMAINDNS=dev.reparons.org
#Some autorised hosts and vars are added for docker implementation
DOMAINS=localhost 127.0.0.1 [::1]
EMAIL=contact@atelier-soude.fr
SERVER_CONTAINER=openrepairplatform_nginx


# POSTGRES settings
POSTGRES_USER=openrepairplatform
POSTGRES_DBNAME=openrepairplatform
POSTGRES_PASSWORD=mangerdespommes
```

1.Set django, postgres and nginx/domain variables in `openrepairplatform/.env`
3 - launch the application in production mode

2.Run the following command:
This script will stop all previous openrepairplatform services and start the application.
1 - obtaining the certificate for the domain by using certbot/nginx
2 - building the application
3 - starting the application
4 - running all the migrations
5 - starting the application

```bash
sh ./install.prod.sh
```

## Run the application (in Develop mode only)

1.Set django, postgres and nginx/domain variables in `openrepairplatform/.env`

```bash
#default content of the configuration .env file
# Activate the location search on home page
LOCATION=1

#DJANGO settings for configuration dev or production
DJANGO_SETTINGS_MODULE=openrepairplatform.settings.dev
SECRET_KEY=CHANGE_ME

# To activate the debug mode, set the environment variable to True
DEBUG=true
PREPROD=False # !!! to keep robots from indexing preprod pages. Change to False on Production server

#Emailing settings only used in production mode
EMAIL_PASSWORD=CHANGE_ME
EMAIL_HOST_USER=CHANGE_ME
EMAIL_HOST=CHANGE_ME
DEFAULT_FROM_EMAIL=no-reply@reparons.org

#Let's encrypt and nginx settings
#The principal domain that django will use
DOMAINDNS=dev.reparons.org
#Some autorised hosts and vars are added for docker implementation
DOMAINS=localhost 127.0.0.1 [::1]
EMAIL=contact@atelier-soude.fr
SERVER_CONTAINER=openrepairplatform_nginx


# POSTGRES settings
POSTGRES_USER=openrepairplatform
POSTGRES_DBNAME=openrepairplatform
POSTGRES_PASSWORD=mangerdespommes
# For PG admin loggin
PGADMIN_DEFAULT_EMAIL=admin@admin.com
PGADMIN_DEFAULT_PASSWORD=root
```

2.Add the DOMAINDNS value to your host configuration

3.Run the following command:

```bash
cd [git checkout directory]/
docker-compose up
```
You can then access `http://127.0.0.1:8000/` and log with the admin user `admin@example.com` // `adminpass`

3.Create an organization within the `http://127.0.0.1:8000/organizations` path and you can start everythings else (further documentation will come)
The website is now deployed and accessible on http://[DOMAINDNS]

Then in the docker terminal, run the following command for livereload.

By default the dev app will start with a livereload server, the auto watch for django files, and the automatic compilation of vue.js files.


3 - Create an organization within the `http://localhost:8000/admin` path and you can start everythings else (further documentation will come).

## Build the application from a branch to a docker image

### build dev app from github branch

You can directly build an image by running the following command. This command will build the image from the selected branch localy. That way you will not have to clone the project localy and just use the image builded from github.

```bash
# Replace the BRANCHNAME with the branch name you want to build
docker build --file /django/Dockerfile https://github.com/AtelierSoude/OpenRepairPlatform.git\#BRANCHNAME:deployment
```

### build from local repository

1 - First you have to clone the project inyour directory using the following commands depending on your configuration.

```bash
git clone https://github.com/AtelierSoude/OpenRepairPlatform.git

#OR if you have a ssh key on github.com

git clone git@github.com:AtelierSoude/OpenRepairPlatform.git

```

2 - You can now build your image using the following command

```bash
# enter your cloned directory
cd OpenRepairPlatform

# Build the image
# The -t option allows you to specify the name of the container it has to match the name in your docker-compose file for production
docker build --file deployment/django/Dockerfile -t openrepairplateform-prod .
```

### Acces to Database administration
The dev env provide a postgresqlAdmin interface which allows you to connect to the database.

You can access it from the following url :
http://localhost:5050/

With the identity in the .env file


### Dump the database & restore on local environment

After being connected to your server, you can dump the database with the following command

```bash
# This guide shows you how to use gzip when pulling down a production database to your local environment
#
# A production database dump can be very large, like 1.5GB
# But database dumps contains a lot of empty space
# Gzipping the database can take the size from 1.5GB down to as low as 50MB
# But you are left zipping and unzipping all the time
#
# Follow these steps to avoid ever creating a large .sql file in the first place
# exporting and importing directly with the gzipped version
# For this example, the production server is named "production"

# On the production server:
# Navigate to your home directory.
# If this next command fails, it is because you don't have permission to switch to the postgres user
# If so, you will need to login as root before you can run this next command
docker exec -ti postgres pg_dump -U ateliersoude ateliersoude | gzip -9 > dump_reparons.sql.gz

# Log out of the production server and go back to your local machine
# Use scp to download (-C uses compression for faster downloads)
scp -C user@IP:./deployement/saves-bdd/dump_reparons.sql.gz ./deployment/saves-bdd/

# If you already have a local database, the .sql file might complain if you try to import it.
# This can be due to duplicate keys, or if the SQL import attempts to create the table that already exists, etc.
# Only delete the database i f you are sure, but I do this all the time
# On OSX, run these commands
docker exec -t postgres dropdb -U openrepairplatform openrepairplatform
docker exec -t postgres createdb -U openrepairplatform openrepairplatform

# Now re-import the database directly from the gzipped file:
#loggin into the container
docker exec -ti postgres /bin/bash
#in container run
gunzip < /srv/saves-bdd/dump_reparons.sql.gz | psql -U openrepairplatform openrepairplatform
```

### Debug with Visual Studio Code

Expand All @@ -45,7 +230,7 @@ If you open the main folder with vs code, you will be able to use the configurat
This will allow you to connect to the container in debug mode and to stop at breakpoints in the code, which is quite confortable to inspect the variables and test new code in the required state of the program (typically before a failure).
Before starting, you may have to install the Python extension.

For this, just click on `Debug`, and `Start Debugging`: you will run the `Debug Django app` configuration.
For this, just click on `Debug`, and `Start Debugging`: you will run the `Debug Django app` configuration.
A small additional bar will appear with useful commands for the debug: go to next breakpoint, stop debugging, etc
More information on debugging with vs code: `https://code.visualstudio.com/Docs/editor/debugging`

Expand All @@ -57,14 +242,10 @@ In the lower part of vs code, in the `DEBUG CONSOLE`, you can test code.
In the debug section, in the left vertical bar, you can see all the breakpoints, all the variables and their content, and the call stack.
You can click on any step of the call stack, and browser the variables, test some code, etc, at this step.

### Coding "live"

The local code is mounted in a Docker volume, so if you change the code locally and refresh your browser, you will immediatly see the changes.

### Run unit tests

First, start the containers with `docker-compose up`
Then, run the tests with `docker exec openrepairplatform_django_1 pytest --disable-pytest-warnings --cov=openrepairplatform --cov-report term-missing`
Then, run the tests with `docker exec openrepairplatform pytest --disable-pytest-warnings --cov=openrepairplatform --cov-report term-missing`


### Run integration tests
Expand Down Expand Up @@ -93,8 +274,7 @@ First, start the Docker containers with `docker-compose up`, and then:

If you uncomment the following lines, it will wait for a debugger to connect before running the tests

```
```bash
ptvsd.enable_attach()
ptvsd.wait_for_attach()
```

Loading