Skip to content

Commit

Permalink
docs: add check points: add model guide
Browse files Browse the repository at this point in the history
fix: add filenames for the code snippets

docs: fix CONTRIBUTING-related issues

Fix: create card for new issue automation

A recent project board name change broke the automation. This commit updates it to the new project name.

Issue hackforla#63 Create Practice Area Model (hackforla#156)

* Issue 63 Create Practice Area Model

issue 43: Create Program Area model (hackforla#161)

* feat: add model: program_area | feat: register admin: program_area | feat: add endpoints: program_area

Update README.md (hackforla#171)

added skill model

fixed bug in serializer.py

Feature technology table (hackforla#175)

* feat: add model: technology

* feat: register admin: technology

* feat: add endpoints: technology

* Lint warnings and code clean up. Removed unnecessary migration files. Corrected admin name.

* "Lint and code cleanup. Removing previous technology migration. Admin.py name update."

* Modified migrations for technology table.

Removed requirements for python version in pre-commit

fix: lint script not fixing code formatting

swapped black and flake8 in lint.sh file

feat: add language model and api endpoints

feature branch rebase with squashed commits for language model

Update issue templates

Add Permission-type tables
Squash all previous minor commits

Update existing Django model by deleting URL fileds

removed language table models and tests

Updated CONTRIBUTING.md file

Create pull_request_template.md

Add pr template from website team to this repo

Rename recurring_event to event

Set up django-linear-migrations

script: update superuser script to take no input

script: update scripts to take extra commandline args

config: show missing lines in coverage report

tests: add test for ProgramArea model

tests: program_area list

docs: move convenience scripts descriptions to a file

docs: update scripts descriptions for script fixes

squashed 28 commits

rebase origin main to update local main branch
  • Loading branch information
fyliu authored and AzaniaBG committed Mar 17, 2024
1 parent 1df267f commit 7206374
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 30 deletions.
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/emergent-request.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ assignees: ''

### Date discovered

### Did you have to do something temporarily

### Did you have to do something temporarily
- [ ] YES
- [ ] NO

### Who was involved

@

### What happens if this is not addressed
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

temp/
.DS_Store
temp

### django ###
*.sqlite3
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
default_install_hook_types: [pre-commit, pre-push]
default_stages: [commit, push]
fail_fast: true
minimum_pre_commit_version: "2.18"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
2 changes: 1 addition & 1 deletion app/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@ class StackElementType(admin.ModelAdmin):

@admin.register(Sdg)
class SdgAdmin(admin.ModelAdmin):
list_display = ("name", "description", "image")
list_display = ("name", "description", "image")
2 changes: 1 addition & 1 deletion app/core/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,4 @@ class Meta:
"uuid",
"created_at",
"updated_at",
)
)
2 changes: 1 addition & 1 deletion app/core/migrations/max_migration.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0021_sdg
0021_sdg
2 changes: 1 addition & 1 deletion app/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,4 @@ class Sdg(AbstractBaseModel):
# PK of this model is the ForeignKey for sdg_target_indicator

def __str__(self):
return f"{self.name}"
return f"{self.name}"
2 changes: 1 addition & 1 deletion app/core/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ def stack_element_type():

@pytest.fixture
def sdg():
return Sdg.objects.create(name="Test SDG name")
return Sdg.objects.create(name="Test SDG name")
2 changes: 1 addition & 1 deletion app/core/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,4 @@ def test_create_sdg(auth_client):
}
res = auth_client.post(SDG_URL, payload)
assert res.status_code == status.HTTP_201_CREATED
assert res.data["name"] == payload["name"]
assert res.data["name"] == payload["name"]
2 changes: 1 addition & 1 deletion app/core/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ def test_stack_element_type(stack_element_type):


def test_sdg(sdg):
assert str(sdg) == "Test SDG name"
assert str(sdg) == "Test SDG name"
62 changes: 41 additions & 21 deletions docs/how-to/add-model-and-api-endpoints.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ Since we overrode the `__str__` function, we need to write a test for it.

Here's a basic test to see that the model stores its name.

Add the following to app/core/tests/test_models.py
Add the following to app/core/tests/test_models.py

```python
def test_recurring_event(recurring_event):
assert str(recurring_event) == "Test Recurring Event"
```

```python
def test_recurring_event(recurring_event):
Expand All @@ -108,9 +113,7 @@ Since we overrode the `__str__` function, we need to write a test for it.

[link to code](https://github.com/hackforla/peopledepot/blob/aad76446fc9ce3942d4f6290322ca1f73279703e/app/core/tests/test_models.py#L17-L18)

1. Pass in our fixture so that the model object is created for us.
1. The `__str__` method should be tested since it's an override of the default Django method.
1. Write assertion(s) to check that what's passed into the model is what it contains. The simplest thing to check is the `__str__` method.
1. Run the test script to show it passing

1. Run the test script to show it passing

Expand All @@ -135,6 +138,23 @@ This is a good place to pause, check, and commit progress.
git commit -m "feat: add model: recurring_event"
```

### Check point 1

This is a good place to pause, check, and commit progress.

1. Run pre-commit checks

```bash
./scripts/precommit-check.sh
```

1. Add and commit changes

```bash
git add -A
git commit -m "feat: add model: recurring_event"
```

## The admin site

Django comes with an admin site interface that allows admin users to view and change the data in the models. It's essentially a database viewer.
Expand Down Expand Up @@ -194,16 +214,16 @@ This is a good place to pause, check, and commit progress.

1. Run pre-commit checks

```bash
./scripts/precommit-check.sh
```
```bash
./scripts/precommit-check.sh
```

1. Add and commit changes

```bash
git add -A
git commit -m "feat: register admin: recurring_event"
```
```bash
git add -A
git commit -m "feat: register admin: recurring_event"
```

## The API

Expand Down Expand Up @@ -461,26 +481,26 @@ For the CRUD operations, since we're using `ModelViewSet` where all the actions
1. Run the test script to show it passing
```bash
./scripts/test.sh
```
```bash
./scripts/test.sh
```
### Check point 3
This is a good place to pause, check, and commit progress.
1. Run pre-commit checks
```bash
./scripts/precommit-check.sh
```
```bash
./scripts/precommit-check.sh
```
1. Add and commit changes
```bash
git add -A
git commit -m "feat: add endpoints: recurring_event"
```
```bash
git add -A
git commit -m "feat: add endpoints: recurring_event"
```
### Push the code and start a PR
Expand Down

0 comments on commit 7206374

Please sign in to comment.