Skip to content

Commit

Permalink
Some changes for Project model needed for project search results
Browse files Browse the repository at this point in the history
  • Loading branch information
JWCook committed Dec 12, 2023
1 parent 0dda6df commit 9e3cd01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
16 changes: 10 additions & 6 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ Add support for searching observations by observation fields, using a new `obser
* `get_observation_species_counts()`

### Models
**Taxon:**
* Add `make_tree()` function to build a tree from `Taxon` objects or a `LifeList`
* Add `pprint_tree()` function to print a taxon tree on the console
* Add `Taxon.flatten()` method to return a taxon and its descendants as a flat list
* Fix initialization of `ListedTaxon.place`

**Observation:**
* Add `Observation.ident_taxon_ids` dynamic property to get all identification taxon IDs (with ancestors)
* Add `Observation.cumulative_ids` dynamic property to calculate agreements/total community identifications
Expand All @@ -32,6 +26,16 @@ Add support for searching observations by observation fields, using a new `obser
* Add `Sound` model for `Observation.sounds`
* Add `Vote` model for `Observation.votes`

**Project:**
* Add `Project.last_post_at` datetime attribute
* Add `Project.observation_requirements_updated_at` datetime attribute

**Taxon:**
* Add `make_tree()` function to build a tree from `Taxon` objects or a `LifeList`
* Add `pprint_tree()` function to print a taxon tree on the console
* Add `Taxon.flatten()` method to return a taxon and its descendants as a flat list
* Fix initialization of `ListedTaxon.place`

### Other changes
* Added support for python 3.12

Expand Down
10 changes: 8 additions & 2 deletions pyinaturalist/models/project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Dict, List
from typing import Dict, List, Optional

from pyinaturalist.constants import (
INAT_BASE_URL,
Expand Down Expand Up @@ -72,7 +72,7 @@ class ProjectUser(User):
@classmethod
def from_json(cls, value: JsonResponse, **kwargs) -> 'ProjectUser':
"""Flatten out nested values"""
user = value['user']
user = value.get('user', {})
user['project_id'] = value['project_id']
user['project_user_id'] = value['id']
user['role'] = value['role']
Expand All @@ -99,7 +99,13 @@ class Project(BaseModel):
default=None,
doc='Indicates if this is an umbrella project (containing observations from other projects)',
)
last_post_at: Optional[datetime] = datetime_field(
doc='Date and time of the last project journal post'
)
location: Coordinates = coordinate_pair()
observation_requirements_updated_at: Optional[datetime] = datetime_field(
doc='Date and time of last update for observation requirements'
)
place_id: int = field(default=None, doc='Project place ID')
prefers_user_trust: bool = field(
default=None,
Expand Down

0 comments on commit 9e3cd01

Please sign in to comment.