ebird-api-data 0.1.1__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ebird_api_data-0.2.1/PKG-INFO +179 -0
- ebird_api_data-0.2.1/README.md +149 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/pyproject.toml +10 -10
- ebird_api_data-0.2.1/src/ebird/api/data/__init__.py +1 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/loaders.py +22 -10
- ebird_api_data-0.2.1/src/ebird/api/data/migrations/0002_convert_foreign_keys_to_integers.py +103 -0
- ebird_api_data-0.2.1/src/ebird/api/data/migrations/0003_make_codes_and_identifiers_primary_keys.py +93 -0
- ebird_api_data-0.2.1/src/ebird/api/data/migrations/0004_rename_foreign_keys.py +103 -0
- ebird_api_data-0.2.1/src/ebird/api/data/migrations/0005_add_new_foreign_keys.py +104 -0
- ebird_api_data-0.2.1/src/ebird/api/data/migrations/0006_set_new_foreign_keys.py +266 -0
- ebird_api_data-0.2.1/src/ebird/api/data/migrations/0007_remove_old_fields_and_ids.py +188 -0
- ebird_api_data-0.2.1/src/ebird/api/data/migrations/0008_rename_created_checklist_added.py +23 -0
- ebird_api_data-0.2.1/src/ebird/api/data/migrations/0009_add_created_timestamps.py +58 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/models/checklist.py +9 -4
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/models/country.py +5 -1
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/models/county.py +5 -1
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/models/filter.py +4 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/models/location.py +7 -2
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/models/observation.py +7 -2
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/models/observer.py +7 -1
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/models/species.py +7 -2
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/models/state.py +6 -2
- ebird_api_data-0.1.1/PKG-INFO +0 -185
- ebird_api_data-0.1.1/README.rst +0 -155
- ebird_api_data-0.1.1/src/ebird/api/data/__init__.py +0 -1
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/.gitignore +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/LICENSE +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/admin.py +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/apps.py +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/fields.py +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/locale/en/LC_MESSAGES/django.mo +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/locale/en/LC_MESSAGES/django.po +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/management/__init__.py +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/management/commands/__init__.py +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/management/commands/add_checklists.py +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/migrations/0001_initial.py +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/migrations/__init__.py +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/models/__init__.py +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/templates/admin/data/species/change_list_object_tools.html +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/templates/admin/data/species/fetch_species.html +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/templates/data/widgets/translation_field.html +0 -0
- {ebird_api_data-0.1.1 → ebird_api_data-0.2.1}/src/ebird/api/data/widgets.py +0 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ebird-api-data
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: eBird API Data is a reusable Django app for loading data from eBird into a database.
|
|
5
|
+
Author-email: Stuart MacKay <smackay@flagstonesoftware.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: Django,checklists,eBird,models,observations,species
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Framework :: Django
|
|
11
|
+
Classifier: Framework :: Django :: 4.2
|
|
12
|
+
Classifier: Framework :: Django :: 5.0
|
|
13
|
+
Classifier: Framework :: Django :: 5.1
|
|
14
|
+
Classifier: Framework :: Django :: 5.2
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: Natural Language :: English
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: beautifulsoup4>=4.13.3
|
|
25
|
+
Requires-Dist: django>=4.2
|
|
26
|
+
Requires-Dist: ebird-api-requests>=4.0.1
|
|
27
|
+
Requires-Dist: ebird-codes>=0.0.2
|
|
28
|
+
Requires-Dist: lxml>=6.0.0
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# eBird API Data
|
|
32
|
+
|
|
33
|
+
eBird API Data is a reusable Django app for loading data from eBird into a database.
|
|
34
|
+
|
|
35
|
+
## Overview
|
|
36
|
+
|
|
37
|
+
The Cornell Laboratory of Ornithology in Ithaca, New York runs the eBird database
|
|
38
|
+
which collects observations of birds from all over the world. All the observations
|
|
39
|
+
are published on [eBird.org](https://ebird.org), and they also make them available
|
|
40
|
+
via an [API](https://documenter.getpostman.com/view/664302/S1ENwy59). This project
|
|
41
|
+
contains a loader and models to take data from the API and load it into a database.
|
|
42
|
+
From there you can analyse the data with python, jupyter notebooks, or build a web
|
|
43
|
+
site.
|
|
44
|
+
|
|
45
|
+
To get started, you will need to
|
|
46
|
+
[sign up](https://secure.birds.cornell.edu/identity/account/create)
|
|
47
|
+
for an eBird account, if you don't already have one and
|
|
48
|
+
[register](https://ebird.org/data/download)
|
|
49
|
+
to get an API key. Make sure you read and understand the
|
|
50
|
+
[Terms of use](https://www.birds.cornell.edu/home/ebird-api-terms-of-use/),
|
|
51
|
+
and remember bandwidth and servers cost money, so don't abuse the service. If you
|
|
52
|
+
need large numbers of observations, then sign up to receive the
|
|
53
|
+
[eBird Basic Dataset](https://science.ebird.org/en/use-ebird-data/download-ebird-data-products).
|
|
54
|
+
|
|
55
|
+
## Install
|
|
56
|
+
|
|
57
|
+
You can use either [pip](https://pip.pypa.io/en/stable/) or [uv](https://docs.astral.sh/uv/)
|
|
58
|
+
to download the [package](https://pypi.org/project/ebird-api-data/) from PyPI and
|
|
59
|
+
install it into a virtualenv:
|
|
60
|
+
|
|
61
|
+
```shell
|
|
62
|
+
pip install ebird-api-data
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
or:
|
|
66
|
+
|
|
67
|
+
```shell
|
|
68
|
+
uv add ebird-api-data
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Update `INSTALLED_APPS` in your Django setting:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
INSTALLED_APPS = [
|
|
75
|
+
...
|
|
76
|
+
ebird.api.data
|
|
77
|
+
]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Finally, run the migrations to create the tables:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
python manage.py migrate
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Demo
|
|
87
|
+
|
|
88
|
+
If you check out the code from the repository there is a fully functioning
|
|
89
|
+
Django site. It contains pages for checklists, observations and species,
|
|
90
|
+
where you can browse the records or search by location, observer. date. etc.
|
|
91
|
+
The Django Admin lets you browse and edit the records in the database.
|
|
92
|
+
|
|
93
|
+
```shell
|
|
94
|
+
git clone git@github.com:StuartMacKay/ebird-api-data.git
|
|
95
|
+
cd ebird-api-data
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Create the virtual environment:
|
|
99
|
+
```shell
|
|
100
|
+
uv venv
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Activate it:
|
|
104
|
+
```shell
|
|
105
|
+
source .venv/bin/activate
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Install the requirements:
|
|
109
|
+
```shell
|
|
110
|
+
uv sync
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Create a copy of the .env.example file and add your API key:
|
|
114
|
+
```shell
|
|
115
|
+
cp .env.example .env
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
For example:
|
|
119
|
+
```shell
|
|
120
|
+
EBIRD_API_KEY=<my api key>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Run the database migrations:
|
|
124
|
+
```shell
|
|
125
|
+
python manage.py migrate
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Create a user:
|
|
129
|
+
```shell
|
|
130
|
+
python manage.py createsuperuser
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Create a copy of the .env.example file and add your API key:
|
|
134
|
+
```shell
|
|
135
|
+
cp .env.example .env
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```shell
|
|
139
|
+
EBIRD_API_KEY=<my api key>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Now, download data from the API:
|
|
143
|
+
|
|
144
|
+
```shell
|
|
145
|
+
python manage.py add_checklists --days 2 US-NY-109
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
This loads all the checklists, submitted in the past two days by birders in
|
|
149
|
+
Tompkins County, New York, where the Cornell Lab is based. You can use any
|
|
150
|
+
location code used by eBird, whether it's for a country, state/region, or
|
|
151
|
+
county. Remember, read the terms of use.
|
|
152
|
+
|
|
153
|
+
Run the demo:
|
|
154
|
+
|
|
155
|
+
```shell
|
|
156
|
+
python manage.py runserver
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Now, either visit the site, http:localhost:8000/, or log into the Django Admin,
|
|
160
|
+
http:localhost:8000/admin to browse the tables.
|
|
161
|
+
|
|
162
|
+
## Project Information
|
|
163
|
+
|
|
164
|
+
* Documentation: https://ebird-api-data.readthedocs.io/en/latest/
|
|
165
|
+
* Issues: https://todo.sr.ht/~smackay/ebird-api-data
|
|
166
|
+
* Repository: https://git.sr.ht/~smackay/ebird-api-data
|
|
167
|
+
* Announcements: https://lists.sr.ht/~smackay/ebirders-announce
|
|
168
|
+
* Discussions: https://lists.sr.ht/~smackay/ebirders-discuss
|
|
169
|
+
* Development: https://lists.sr.ht/~smackay/ebirders-develop
|
|
170
|
+
|
|
171
|
+
The repository is also mirrored on Github:
|
|
172
|
+
|
|
173
|
+
* Repository: https://github.com/StuartMacKay/ebird-api-data
|
|
174
|
+
|
|
175
|
+
The app is tested on Python 3.10+, and officially supports Django 4.2, 5.0 and 5.1.
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
eBird API Data is released under the terms of the [MIT](https://opensource.org/licenses/MIT) license.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# eBird API Data
|
|
2
|
+
|
|
3
|
+
eBird API Data is a reusable Django app for loading data from eBird into a database.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Cornell Laboratory of Ornithology in Ithaca, New York runs the eBird database
|
|
8
|
+
which collects observations of birds from all over the world. All the observations
|
|
9
|
+
are published on [eBird.org](https://ebird.org), and they also make them available
|
|
10
|
+
via an [API](https://documenter.getpostman.com/view/664302/S1ENwy59). This project
|
|
11
|
+
contains a loader and models to take data from the API and load it into a database.
|
|
12
|
+
From there you can analyse the data with python, jupyter notebooks, or build a web
|
|
13
|
+
site.
|
|
14
|
+
|
|
15
|
+
To get started, you will need to
|
|
16
|
+
[sign up](https://secure.birds.cornell.edu/identity/account/create)
|
|
17
|
+
for an eBird account, if you don't already have one and
|
|
18
|
+
[register](https://ebird.org/data/download)
|
|
19
|
+
to get an API key. Make sure you read and understand the
|
|
20
|
+
[Terms of use](https://www.birds.cornell.edu/home/ebird-api-terms-of-use/),
|
|
21
|
+
and remember bandwidth and servers cost money, so don't abuse the service. If you
|
|
22
|
+
need large numbers of observations, then sign up to receive the
|
|
23
|
+
[eBird Basic Dataset](https://science.ebird.org/en/use-ebird-data/download-ebird-data-products).
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
You can use either [pip](https://pip.pypa.io/en/stable/) or [uv](https://docs.astral.sh/uv/)
|
|
28
|
+
to download the [package](https://pypi.org/project/ebird-api-data/) from PyPI and
|
|
29
|
+
install it into a virtualenv:
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
pip install ebird-api-data
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
or:
|
|
36
|
+
|
|
37
|
+
```shell
|
|
38
|
+
uv add ebird-api-data
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Update `INSTALLED_APPS` in your Django setting:
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
INSTALLED_APPS = [
|
|
45
|
+
...
|
|
46
|
+
ebird.api.data
|
|
47
|
+
]
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Finally, run the migrations to create the tables:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
python manage.py migrate
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Demo
|
|
57
|
+
|
|
58
|
+
If you check out the code from the repository there is a fully functioning
|
|
59
|
+
Django site. It contains pages for checklists, observations and species,
|
|
60
|
+
where you can browse the records or search by location, observer. date. etc.
|
|
61
|
+
The Django Admin lets you browse and edit the records in the database.
|
|
62
|
+
|
|
63
|
+
```shell
|
|
64
|
+
git clone git@github.com:StuartMacKay/ebird-api-data.git
|
|
65
|
+
cd ebird-api-data
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Create the virtual environment:
|
|
69
|
+
```shell
|
|
70
|
+
uv venv
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Activate it:
|
|
74
|
+
```shell
|
|
75
|
+
source .venv/bin/activate
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Install the requirements:
|
|
79
|
+
```shell
|
|
80
|
+
uv sync
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Create a copy of the .env.example file and add your API key:
|
|
84
|
+
```shell
|
|
85
|
+
cp .env.example .env
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
For example:
|
|
89
|
+
```shell
|
|
90
|
+
EBIRD_API_KEY=<my api key>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Run the database migrations:
|
|
94
|
+
```shell
|
|
95
|
+
python manage.py migrate
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Create a user:
|
|
99
|
+
```shell
|
|
100
|
+
python manage.py createsuperuser
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Create a copy of the .env.example file and add your API key:
|
|
104
|
+
```shell
|
|
105
|
+
cp .env.example .env
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
```shell
|
|
109
|
+
EBIRD_API_KEY=<my api key>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Now, download data from the API:
|
|
113
|
+
|
|
114
|
+
```shell
|
|
115
|
+
python manage.py add_checklists --days 2 US-NY-109
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This loads all the checklists, submitted in the past two days by birders in
|
|
119
|
+
Tompkins County, New York, where the Cornell Lab is based. You can use any
|
|
120
|
+
location code used by eBird, whether it's for a country, state/region, or
|
|
121
|
+
county. Remember, read the terms of use.
|
|
122
|
+
|
|
123
|
+
Run the demo:
|
|
124
|
+
|
|
125
|
+
```shell
|
|
126
|
+
python manage.py runserver
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Now, either visit the site, http:localhost:8000/, or log into the Django Admin,
|
|
130
|
+
http:localhost:8000/admin to browse the tables.
|
|
131
|
+
|
|
132
|
+
## Project Information
|
|
133
|
+
|
|
134
|
+
* Documentation: https://ebird-api-data.readthedocs.io/en/latest/
|
|
135
|
+
* Issues: https://todo.sr.ht/~smackay/ebird-api-data
|
|
136
|
+
* Repository: https://git.sr.ht/~smackay/ebird-api-data
|
|
137
|
+
* Announcements: https://lists.sr.ht/~smackay/ebirders-announce
|
|
138
|
+
* Discussions: https://lists.sr.ht/~smackay/ebirders-discuss
|
|
139
|
+
* Development: https://lists.sr.ht/~smackay/ebirders-develop
|
|
140
|
+
|
|
141
|
+
The repository is also mirrored on Github:
|
|
142
|
+
|
|
143
|
+
* Repository: https://github.com/StuartMacKay/ebird-api-data
|
|
144
|
+
|
|
145
|
+
The app is tested on Python 3.10+, and officially supports Django 4.2, 5.0 and 5.1.
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
eBird API Data is released under the terms of the [MIT](https://opensource.org/licenses/MIT) license.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "ebird-api-data"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.1"
|
|
4
4
|
description = "eBird API Data is a reusable Django app for loading data from eBird into a database."
|
|
5
5
|
keywords = ["checklists", "observations", "species", "Django", "eBird", "models"]
|
|
6
6
|
license = "MIT"
|
|
@@ -8,7 +8,7 @@ license-files = ["LICENSE"]
|
|
|
8
8
|
authors = [
|
|
9
9
|
{name = "Stuart MacKay", email = "smackay@flagstonesoftware.com"},
|
|
10
10
|
]
|
|
11
|
-
readme = "README.
|
|
11
|
+
readme = "README.md"
|
|
12
12
|
requires-python = ">=3.10"
|
|
13
13
|
dependencies = [
|
|
14
14
|
"beautifulsoup4>=4.13.3",
|
|
@@ -61,10 +61,11 @@ dev-dependencies = [
|
|
|
61
61
|
"django-extensions>=3.2.3",
|
|
62
62
|
"psycopg2-binary>=2.9.10",
|
|
63
63
|
"ipython>=8.37.0",
|
|
64
|
+
"django-autocomplete-light>=3.12.1",
|
|
64
65
|
]
|
|
65
66
|
|
|
66
67
|
[tool.bumpversion]
|
|
67
|
-
current_version = "0.
|
|
68
|
+
current_version = "0.2.1"
|
|
68
69
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
69
70
|
serialize = ["{major}.{minor}.{patch}"]
|
|
70
71
|
ignore_missing_version = false
|
|
@@ -89,16 +90,15 @@ search = 'release = "{current_version}"'
|
|
|
89
90
|
replace = 'release = "{new_version}"'
|
|
90
91
|
|
|
91
92
|
[[tool.bumpversion.files]]
|
|
92
|
-
filename = "CHANGELOG.
|
|
93
|
+
filename = "CHANGELOG.md"
|
|
93
94
|
search = """
|
|
94
|
-
Latest
|
|
95
|
-
|
|
95
|
+
## Latest
|
|
96
|
+
"""
|
|
96
97
|
replace = """
|
|
97
|
-
Latest
|
|
98
|
-
------
|
|
98
|
+
## Latest
|
|
99
99
|
|
|
100
|
-
{new_version}
|
|
101
|
-
|
|
100
|
+
## {new_version}
|
|
101
|
+
"""
|
|
102
102
|
|
|
103
103
|
[[tool.bumpversion.files]]
|
|
104
104
|
filename = "pyproject.toml"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.1"
|
|
@@ -303,19 +303,31 @@ class APILoader:
|
|
|
303
303
|
|
|
304
304
|
def get_observer(self, data: dict) -> Observer:
|
|
305
305
|
name: str = data.get("userDisplayName", "Anonymous eBirder")
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if observer.multiple:
|
|
306
|
+
is_multiple = Observer.objects.filter(original=name, multiple=True).exists()
|
|
307
|
+
if is_multiple:
|
|
308
|
+
identifier = self.get_observer_identifier(data)
|
|
310
309
|
observer, created = Observer.objects.get_or_create(
|
|
311
|
-
identifier=
|
|
312
|
-
defaults={
|
|
310
|
+
identifier=identifier,
|
|
311
|
+
defaults={
|
|
312
|
+
"name":name,
|
|
313
|
+
"original": random_word(8)
|
|
314
|
+
}
|
|
313
315
|
)
|
|
314
|
-
|
|
315
|
-
observer
|
|
316
|
-
|
|
316
|
+
else:
|
|
317
|
+
if observer := Observer.objects.filter(original=name).first():
|
|
318
|
+
created = False
|
|
319
|
+
else:
|
|
320
|
+
identifier = self.get_observer_identifier(data)
|
|
321
|
+
observer, created = Observer.objects.get_or_create(
|
|
322
|
+
identifier=identifier,
|
|
323
|
+
defaults={"name": name, "original":name,}
|
|
324
|
+
)
|
|
325
|
+
|
|
317
326
|
if created:
|
|
318
|
-
logger.info("Added observer: %s",
|
|
327
|
+
logger.info("Added observer: %s", name)
|
|
328
|
+
if Observer.objects.filter(original=name).count() > 1:
|
|
329
|
+
logger.error("Multiple observers exist with same name: %s", name)
|
|
330
|
+
|
|
319
331
|
return observer
|
|
320
332
|
|
|
321
333
|
def add_checklist(self, identifier: str) -> Checklist | None:
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Generated by Django 5.2.4 on 2025-07-14 09:34
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('data', '0001_initial'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name='checklist',
|
|
15
|
+
name='country',
|
|
16
|
+
field=models.IntegerField(),
|
|
17
|
+
),
|
|
18
|
+
migrations.AlterField(
|
|
19
|
+
model_name='checklist',
|
|
20
|
+
name='county',
|
|
21
|
+
field=models.IntegerField(null=True),
|
|
22
|
+
),
|
|
23
|
+
migrations.AlterField(
|
|
24
|
+
model_name='checklist',
|
|
25
|
+
name='location',
|
|
26
|
+
field=models.IntegerField(),
|
|
27
|
+
),
|
|
28
|
+
migrations.AlterField(
|
|
29
|
+
model_name='checklist',
|
|
30
|
+
name='observer',
|
|
31
|
+
field=models.IntegerField(),
|
|
32
|
+
),
|
|
33
|
+
migrations.AlterField(
|
|
34
|
+
model_name='checklist',
|
|
35
|
+
name='state',
|
|
36
|
+
field=models.IntegerField(),
|
|
37
|
+
),
|
|
38
|
+
migrations.AlterField(
|
|
39
|
+
model_name='filter',
|
|
40
|
+
name='location',
|
|
41
|
+
field=models.IntegerField(null=True),
|
|
42
|
+
),
|
|
43
|
+
migrations.AlterField(
|
|
44
|
+
model_name='filter',
|
|
45
|
+
name='species',
|
|
46
|
+
field=models.IntegerField(),
|
|
47
|
+
),
|
|
48
|
+
migrations.AlterField(
|
|
49
|
+
model_name='filter',
|
|
50
|
+
name='update_species',
|
|
51
|
+
field=models.IntegerField(),
|
|
52
|
+
),
|
|
53
|
+
migrations.AlterField(
|
|
54
|
+
model_name='location',
|
|
55
|
+
name='country',
|
|
56
|
+
field=models.IntegerField(),
|
|
57
|
+
),
|
|
58
|
+
migrations.AlterField(
|
|
59
|
+
model_name='location',
|
|
60
|
+
name='county',
|
|
61
|
+
field=models.IntegerField(null=True),
|
|
62
|
+
),
|
|
63
|
+
migrations.AlterField(
|
|
64
|
+
model_name='location',
|
|
65
|
+
name='state',
|
|
66
|
+
field=models.IntegerField(),
|
|
67
|
+
),
|
|
68
|
+
migrations.AlterField(
|
|
69
|
+
model_name='observation',
|
|
70
|
+
name='checklist',
|
|
71
|
+
field=models.IntegerField(),
|
|
72
|
+
),
|
|
73
|
+
migrations.AlterField(
|
|
74
|
+
model_name='observation',
|
|
75
|
+
name='country',
|
|
76
|
+
field=models.IntegerField(),
|
|
77
|
+
),
|
|
78
|
+
migrations.AlterField(
|
|
79
|
+
model_name='observation',
|
|
80
|
+
name='county',
|
|
81
|
+
field=models.IntegerField(null=True),
|
|
82
|
+
),
|
|
83
|
+
migrations.AlterField(
|
|
84
|
+
model_name='observation',
|
|
85
|
+
name='location',
|
|
86
|
+
field=models.IntegerField(),
|
|
87
|
+
),
|
|
88
|
+
migrations.AlterField(
|
|
89
|
+
model_name='observation',
|
|
90
|
+
name='observer',
|
|
91
|
+
field=models.IntegerField(),
|
|
92
|
+
),
|
|
93
|
+
migrations.AlterField(
|
|
94
|
+
model_name='observation',
|
|
95
|
+
name='species',
|
|
96
|
+
field=models.IntegerField(),
|
|
97
|
+
),
|
|
98
|
+
migrations.AlterField(
|
|
99
|
+
model_name='observation',
|
|
100
|
+
name='state',
|
|
101
|
+
field=models.IntegerField(),
|
|
102
|
+
),
|
|
103
|
+
]
|
ebird_api_data-0.2.1/src/ebird/api/data/migrations/0003_make_codes_and_identifiers_primary_keys.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Generated by Django 5.2.4 on 2025-07-14 09:49
|
|
2
|
+
|
|
3
|
+
from django.db import migrations, models
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Migration(migrations.Migration):
|
|
7
|
+
|
|
8
|
+
dependencies = [
|
|
9
|
+
('data', '0002_convert_foreign_keys_to_integers'),
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
operations = [
|
|
13
|
+
migrations.AlterField(
|
|
14
|
+
model_name='checklist',
|
|
15
|
+
name='id',
|
|
16
|
+
field=models.IntegerField(),
|
|
17
|
+
),
|
|
18
|
+
migrations.AlterField(
|
|
19
|
+
model_name='country',
|
|
20
|
+
name='id',
|
|
21
|
+
field=models.IntegerField(),
|
|
22
|
+
),
|
|
23
|
+
migrations.AlterField(
|
|
24
|
+
model_name='county',
|
|
25
|
+
name='id',
|
|
26
|
+
field=models.IntegerField(),
|
|
27
|
+
),
|
|
28
|
+
migrations.AlterField(
|
|
29
|
+
model_name='location',
|
|
30
|
+
name='id',
|
|
31
|
+
field=models.IntegerField(),
|
|
32
|
+
),
|
|
33
|
+
migrations.AlterField(
|
|
34
|
+
model_name='observation',
|
|
35
|
+
name='id',
|
|
36
|
+
field=models.IntegerField(),
|
|
37
|
+
),
|
|
38
|
+
migrations.AlterField(
|
|
39
|
+
model_name='observer',
|
|
40
|
+
name='id',
|
|
41
|
+
field=models.IntegerField(),
|
|
42
|
+
),
|
|
43
|
+
migrations.AlterField(
|
|
44
|
+
model_name='species',
|
|
45
|
+
name='id',
|
|
46
|
+
field=models.IntegerField(),
|
|
47
|
+
),
|
|
48
|
+
migrations.AlterField(
|
|
49
|
+
model_name='state',
|
|
50
|
+
name='id',
|
|
51
|
+
field=models.IntegerField(),
|
|
52
|
+
),
|
|
53
|
+
migrations.AlterField(
|
|
54
|
+
model_name='checklist',
|
|
55
|
+
name='identifier',
|
|
56
|
+
field=models.CharField(help_text='The unique identifier for the checklist.', max_length=15, primary_key=True, serialize=False, verbose_name='identifier'),
|
|
57
|
+
),
|
|
58
|
+
migrations.AlterField(
|
|
59
|
+
model_name='country',
|
|
60
|
+
name='code',
|
|
61
|
+
field=models.CharField(help_text='The code used to identify the country.', max_length=2, primary_key=True, serialize=False, verbose_name='code'),
|
|
62
|
+
),
|
|
63
|
+
migrations.AlterField(
|
|
64
|
+
model_name='county',
|
|
65
|
+
name='code',
|
|
66
|
+
field=models.CharField(help_text='The code used to identify the county.', max_length=10, primary_key=True, serialize=False, verbose_name='code'),
|
|
67
|
+
),
|
|
68
|
+
migrations.AlterField(
|
|
69
|
+
model_name='location',
|
|
70
|
+
name='identifier',
|
|
71
|
+
field=models.CharField(help_text='The unique identifier for the location.', max_length=15, primary_key=True, serialize=False, verbose_name='identifier'),
|
|
72
|
+
),
|
|
73
|
+
migrations.AlterField(
|
|
74
|
+
model_name='observation',
|
|
75
|
+
name='identifier',
|
|
76
|
+
field=models.CharField(help_text='A global unique identifier for the observation.', max_length=15, primary_key=True, serialize=False, verbose_name='identifier'),
|
|
77
|
+
),
|
|
78
|
+
migrations.AlterField(
|
|
79
|
+
model_name='observer',
|
|
80
|
+
name='identifier',
|
|
81
|
+
field=models.CharField(help_text='The code for the person submitted the checklist.', max_length=15, primary_key=True, serialize=False, verbose_name='identifier'),
|
|
82
|
+
),
|
|
83
|
+
migrations.AlterField(
|
|
84
|
+
model_name='species',
|
|
85
|
+
name='species_code',
|
|
86
|
+
field=models.CharField(help_text='The species code, e.g. ostric2, used in the eBird API.', max_length=10, primary_key=True, serialize=False, verbose_name='species code'),
|
|
87
|
+
),
|
|
88
|
+
migrations.AlterField(
|
|
89
|
+
model_name='state',
|
|
90
|
+
name='code',
|
|
91
|
+
field=models.CharField(help_text='The code used to identify the state.', max_length=6, primary_key=True, serialize=False, verbose_name='code'),
|
|
92
|
+
),
|
|
93
|
+
]
|