Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
BissonnetteVincent committed Mar 23, 2024
2 parents 75a9d77 + a437fb6 commit 371b5aa
Show file tree
Hide file tree
Showing 37 changed files with 3,295 additions and 2,414 deletions.
1 change: 1 addition & 0 deletions .github/workflows/canopeum_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ jobs:
- uses: jakebailey/pyright-action@v2
with:
python-version: "3.12"
working-directory: canopeum_backend
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"davidanson.vscode-markdownlint",
"dbaeumer.vscode-eslint",
"dprint.dprint",
"dotenv.dotenv-vscode",
"eamodio.gitlens",
"github.vscode-github-actions",
"meganrogge.template-string-converter",
Expand All @@ -29,6 +30,8 @@
"coenraads.bracket-pair-colorizer",
"coenraads.bracket-pair-colorizer-2",
"shardulm94.trailing-spaces",
// Use the official plugin instead
"mikestead.dotenv",
// Lots of conflicts
"esbenp.prettier-vscode",
"rvest.vs-code-prettier-eslint",
Expand Down
42 changes: 21 additions & 21 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
// 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
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: runserver",
"type": "debugpy",
"request": "launch",
"program": "canopeum_backend/manage.py",
"args": ["runserver"],
"console": "integratedTerminal"
},
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
// 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
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: runserver",
"type": "debugpy",
"request": "launch",
"program": "canopeum_backend/manage.py",
"args": ["runserver"],
"console": "integratedTerminal"
},
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
43 changes: 38 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
72
]
},
"[markdown]": {
"files.trimTrailingWhitespace": false
},
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
Expand Down Expand Up @@ -52,7 +49,18 @@
* CSS-specific settings
*/
// TODO: Configure stylelint or dprint-prettier so I can recommend it
"[css][scss][postcss][less]": {
// NOTE: due to a bug in VSCode, we have to specify these individually to ensure it overrides user settings
// Please upvote: https://github.com/microsoft/vscode/issues/168411
"[css]": {
"editor.defaultFormatter": "vscode.css-language-features"
},
"[scss]": {
"editor.defaultFormatter": "vscode.css-language-features"
},
"[postcss]": {
"editor.defaultFormatter": "vscode.css-language-features"
},
"[less]": {
"editor.defaultFormatter": "vscode.css-language-features"
},
"less.format.spaceAroundSelectorSeparator": true,
Expand All @@ -62,9 +70,34 @@
* JavasScript-specific settings
*/
// Set the default formatter to help avoid Prettier
"[json][jsonc][javascript][javascriptreact][typescript][typescriptreact][markdown][dockerfile]": {
// NOTE: due to a bug in VSCode, we have to specify these individually to ensure it overrides user settings
// Please upvote: https://github.com/microsoft/vscode/issues/168411
"[json]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[jsonc]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[javascript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[javascriptreact]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[typescript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[typescriptreact]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[markdown]": {
"files.trimTrailingWhitespace": false,
"editor.defaultFormatter": "dprint.dprint"
},
"[dockerfile]": {
"editor.defaultFormatter": "dprint.dprint"
},
"dprint.path": "canopeum_frontend/node_modules/dprint/dprint.exe",
"typescript.tsdk": "canopeum_frontend/node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"js/ts.implicitProjectConfig.checkJs": true,
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ For backend
cd releaf-canopeum
```

3. Set up a Python 3.12 virtual environment
3. Install recommended Editor Extensions (for VSCode):\
When you first open the project in VSCode, you'll get a notification like this.\
![Recommended Popup](/docs/Recommended_Popup.png)

If you've already dismissed this notification, you can search for `@recommended` in your Extensions tab.
Install everything under "**WORKSPACE RECOMMENDATIONS**", you can ignore "other recommendations":\
![Recommended Extensions](/docs/Recommended_Extensions.png)

4. Set up a Python 3.12 virtual environment

```shell
cd canopeum_backend
Expand Down Expand Up @@ -64,7 +72,7 @@ For backend
`CTRL+Shift+P` (Open Command Palette) > `Python: Select Interpreter`
![VSCode_select_venv](/docs/VSCode_select_venv.png)

4. Set up Django backend and Database: (Skip this section for Frontend only)
5. Set up Django backend and Database: (Skip this section for Frontend only)

```shell
docker compose up
Expand All @@ -74,7 +82,7 @@ For backend
python manage.py runserver
```

5. Set up React frontend:
6. Set up React frontend:

```shell
cd canopeum_frontend
Expand Down
35 changes: 27 additions & 8 deletions canopeum_backend/canopeum_backend/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SiteTypeSerializer(serializers.ModelSerializer):

class Meta:
model = Sitetype
fields = ["id", "en", "fr"]
fields = ("id", "en", "fr")

def get_en(self, obj):
return InternationalizationSerializer(obj.name).data.get("en", None)
Expand All @@ -74,7 +74,7 @@ class TreeTypeSerializer(serializers.ModelSerializer):

class Meta:
model = Treetype
fields = ["en", "fr"]
fields = ("en", "fr")

def get_en(self, obj):
return InternationalizationSerializer(obj.name).data.get("en", None)
Expand Down Expand Up @@ -149,7 +149,7 @@ class BatchfertilizerSerializer(serializers.ModelSerializer):

class Meta:
model = Batchfertilizer
fields = ["id", "en", "fr"]
fields = ("id", "en", "fr")

def get_en(self, obj):
return InternationalizationSerializer(obj.fertilizer_type).data.get("en", None)
Expand All @@ -164,7 +164,7 @@ class BatchMulchLayerSerializer(serializers.ModelSerializer):

class Meta:
model = Mulchlayertype
fields = ["id", "en", "fr"]
fields = ("id", "en", "fr")

def get_en(self, obj):
return InternationalizationSerializer(obj.mulch_layer_type).data.get("en", None)
Expand All @@ -179,7 +179,7 @@ class BatchSupportedSpeciesSerializer(serializers.ModelSerializer):

class Meta:
model = BatchSupportedSpecies
fields = ["en", "fr"]
fields = ("en", "fr")

def get_en(self, obj):
return InternationalizationSerializer(obj.tree_type).data.get("en", None)
Expand All @@ -194,7 +194,7 @@ class BatchSeedSerializer(serializers.ModelSerializer):

class Meta:
model = BatchSeed
fields = ["quantity", "en", "fr"]
fields = ("quantity", "en", "fr")

def get_en(self, obj):
return InternationalizationSerializer(obj.tree_type).data.get("en", None)
Expand All @@ -209,7 +209,7 @@ class BatchSpeciesSerializer(serializers.ModelSerializer):

class Meta:
model = BatchSpecies
fields = ["quantity", "en", "fr"]
fields = ("quantity", "en", "fr")

def get_en(self, obj):
return InternationalizationSerializer(obj.tree_type).data.get("en", None)
Expand Down Expand Up @@ -318,12 +318,31 @@ def get_sponsor(self, obj):
return BatchSerializer(obj).data.get("sponsor", None)


class CoordinatesMapSerializer(serializers.ModelSerializer):
latitude = serializers.SerializerMethodField()
longitude = serializers.SerializerMethodField()

class Meta:
model = Coordinate
fields = ("latitude", "longitude", "address")

def get_latitude(self, obj):
return obj.dd_latitude

def get_longitude(self, obj):
return obj.dd_longitude


class SiteMapSerializer(serializers.ModelSerializer):
site_type = SiteTypeSerializer()
coordinates = serializers.SerializerMethodField()

class Meta:
model = Site
fields = ("id", "name", "site_type", "coordinate", "image")
fields = ("id", "name", "site_type", "coordinates", "image")

def get_coordinates(self, obj):
return CoordinatesMapSerializer(obj.coordinate).data


class SiteOverviewSerializer(serializers.ModelSerializer):
Expand Down
5 changes: 5 additions & 0 deletions canopeum_backend/canopeum_backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@
"COMPONENT_NO_READ_ONLY_REQUIRED": False,
# Create separate components for PATCH endpoints (without required list)
"COMPONENT_SPLIT_PATCH": True,
"CAMELIZE_NAMES": True,
"POSTPROCESSING_HOOKS": [
"drf_spectacular.contrib.djangorestframework_camel_case.camelize_serializer_fields",
"drf_spectacular.hooks.postprocess_schema_enums",
],
}


Expand Down
2 changes: 1 addition & 1 deletion canopeum_backend/canopeum_backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Like
path("social/posts/<int:postId>/likes/", views.LikeListAPIView.as_view(), name="like-list"),
# Site
path("social/sites/", views.SiteSocialDetailAPIView.as_view(), name="site-list"),
path("social/sites/", views.SiteSocialListAPIView.as_view(), name="site-list"),
path("social/sites/<int:siteId>/", views.SiteSocialDetailAPIView.as_view(), name="site-detail"),
# Announcement
path(
Expand Down
Loading

0 comments on commit 371b5aa

Please sign in to comment.