summaryrefslogtreecommitdiff
path: root/python-django-address.spec
blob: 2d4157b798234a449b4879265eefc96b7811faa3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
%global _empty_manifest_terminate_build 0
Name:		python-django-address
Version:	0.2.8
Release:	1
Summary:	A django application for describing addresses.
License:	BSD
URL:		https://github.com/furious-luke/django-address
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/4f/5a/488ff3c27477da39cc469aa81b52773169f166dcdc450678913c05aece11/django-address-0.2.8.tar.gz
BuildArch:	noarch


%description
# Overview
Django Address is a set of models and methods for working with postal addresses.
# Requirements
 * Python (3.5, 3.6, 3.7, 3.8)
 * Django (2.2, 3.0)
We **recommend** and only officially support the latest patch release of each Python and Django series. 
# Installation
For more detailed instructions, [view the Readme for the example site](https://github.com/furious-luke/django-address/blob/master/example_site/README.md) included with this package.
```bash
pip install django-address
```
Then, add `address` to your `INSTALLED_APPS` list in `settings.py`:
```python
INSTALLED_APPS = [
    # ... 
    'address',
    # ... 
]
```
You can either store your Google API key in an environment variable as `GOOGLE_API_KEY` or you can
 specify the key in `settings.py`. If you have an environment variable set it will override what you put in settings.py.
 For more information, including enabling the Google Places API, refer to [the example site](https://github.com/furious-luke/django-address/blob/master/example_site/README.md).
```
GOOGLE_API_KEY = 'AIzaSyD--your-google-maps-key-SjQBE'
```
# The Model
The rationale behind the model structure is centered on trying to make
it easy to enter addresses that may be poorly defined. The model field included
uses Google Maps API v3 (via the nicely done [geocomplete jquery plugin](http://ubilabs.github.io/geocomplete/)) to
determine a proper address where possible. However if this isn't possible the
raw address is used and the user is responsible for breaking the address down
into components.
It's currently assumed any address is represent-able using four components:
country, state, locality and street address. In addition, country code, state
code and postal code may be stored, if they exist.
There are four Django models used:
```
  Country
    name
    code
  State
    name
    code
    country -> Country
  Locality
    name
    postal_code
    state -> State
  Address
    raw
    street_number
    route
    locality -> Locality
```
# Address Field
To simplify storage and access of addresses, a subclass of `ForeignKey` named
`AddressField` has been created. It provides an easy method for setting new
addresses.
## ON_DELETE behavior of Address Field
By default, if you delete an Address that is related to another object, 
Django's [cascade behavior](https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.on_delete) 
is used. This means the related object will also be deleted. You may also choose
to set `null=True` when defining an address field to have the address set
to Null instead of deleting the related object. For more information and an example,
see the readme for the `django-address` example_site.
## Creation
It can be created using the same optional arguments as a ForeignKey field.
For example:
```python
  from address.models import AddressField
  class MyModel(models.Model):
    address1 = AddressField()
    address2 = AddressField(related_name='+', blank=True, null=True)
```
## Setting Values
Values can be set either by assigning an Address object:
```python
  addr = Address(...)
  addr.save()
  obj.address = addr
```
Or by supplying a dictionary of address components:
```python
  obj.address = {'street_number': '1', 'route': 'Somewhere Ave', ...}
```
The structure of the address components is as follows:
```python
  {
    'raw': '1 Somewhere Ave, Northcote, VIC 3070, AU',
    'street_number': '1',
    'route': 'Somewhere Ave',
    'locality': 'Northcote',
    'postal_code': '3070',
    'state': 'Victoria',
    'state_code': 'VIC',
    'country': 'Australia',
    'country_code': 'AU'
  }
```
All except the `raw` field can be omitted. In addition, a raw address may
be set directly:
```python
obj.address = 'Out the back of 1 Somewhere Ave, Northcote, Australia'
```
## Getting Values
When accessed, the address field simply returns an Address object. This way
all components may be accessed naturally through the object. For example::
```python
  route = obj.address.route
  state_name = obj.address.locality.state.name
```
## Forms
Included is a form field for simplifying address entry. A Google maps
auto-complete is performed in the browser and passed to the view. If
the lookup fails the raw entered value is used.
TODO: Talk about this more.
## Partial Example
The model:
```python
from address.models import AddressField
class Person(models.Model):
  address = AddressField(on_delete=models.CASCADE)
```
The form:
```python
from address.forms import AddressField
class PersonForm(forms.Form):
  address = AddressField()
```
The template:
```html
<head>
{{ form.media }} <!-- needed for JS/GoogleMaps lookup -->
</head>
<body>
  {{ form }}
</body>
```
## Running Django-Address Tests
Django-address currently has partial form and model test coverage using `django.test.TestCase`.
To run the current tests:
 1. [Clone](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) `django-address` locally.
 1. Navigate to the example site, . `/django-address/example_site`
 1. Create a [virtual environment](https://www.tangowithdjango.com/book17/chapters/requirements.html#virtual-environments) and install the example site dependencies. For example:
    ```
    mkvirtualenv -p python3 django-address
    pip install -r requirements.txt
    ```
 1. Run `./manage.py test`
## Important note regarding US Territories
Django-address does not currently support the parsing of US territories aka Protectorates such as Guam or Puerto Rico.
This topic is under active consideration and its status is described in [#82](https://github.com/furious-luke/django-address/issues/82)
## Project Status Notes
This library was created by [Luke Hodkinson](@furious-luke) originally focused on Australian addresses.
In 2015 Luke began working to abstract the project so it could handle a wider variety of international addresses.
This became the current `dev` branch.  While good progress was made on this, the branch became stale and releases
continued under the current model architecture on master. 
The project is currently in open development, read more about the project status [in this issue](https://github.com/furious-luke/django-address/issues/98).  
If you have questions, bug reports or suggestions please create a New Issue for the project.

%package -n python3-django-address
Summary:	A django application for describing addresses.
Provides:	python-django-address
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-django-address
# Overview
Django Address is a set of models and methods for working with postal addresses.
# Requirements
 * Python (3.5, 3.6, 3.7, 3.8)
 * Django (2.2, 3.0)
We **recommend** and only officially support the latest patch release of each Python and Django series. 
# Installation
For more detailed instructions, [view the Readme for the example site](https://github.com/furious-luke/django-address/blob/master/example_site/README.md) included with this package.
```bash
pip install django-address
```
Then, add `address` to your `INSTALLED_APPS` list in `settings.py`:
```python
INSTALLED_APPS = [
    # ... 
    'address',
    # ... 
]
```
You can either store your Google API key in an environment variable as `GOOGLE_API_KEY` or you can
 specify the key in `settings.py`. If you have an environment variable set it will override what you put in settings.py.
 For more information, including enabling the Google Places API, refer to [the example site](https://github.com/furious-luke/django-address/blob/master/example_site/README.md).
```
GOOGLE_API_KEY = 'AIzaSyD--your-google-maps-key-SjQBE'
```
# The Model
The rationale behind the model structure is centered on trying to make
it easy to enter addresses that may be poorly defined. The model field included
uses Google Maps API v3 (via the nicely done [geocomplete jquery plugin](http://ubilabs.github.io/geocomplete/)) to
determine a proper address where possible. However if this isn't possible the
raw address is used and the user is responsible for breaking the address down
into components.
It's currently assumed any address is represent-able using four components:
country, state, locality and street address. In addition, country code, state
code and postal code may be stored, if they exist.
There are four Django models used:
```
  Country
    name
    code
  State
    name
    code
    country -> Country
  Locality
    name
    postal_code
    state -> State
  Address
    raw
    street_number
    route
    locality -> Locality
```
# Address Field
To simplify storage and access of addresses, a subclass of `ForeignKey` named
`AddressField` has been created. It provides an easy method for setting new
addresses.
## ON_DELETE behavior of Address Field
By default, if you delete an Address that is related to another object, 
Django's [cascade behavior](https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.on_delete) 
is used. This means the related object will also be deleted. You may also choose
to set `null=True` when defining an address field to have the address set
to Null instead of deleting the related object. For more information and an example,
see the readme for the `django-address` example_site.
## Creation
It can be created using the same optional arguments as a ForeignKey field.
For example:
```python
  from address.models import AddressField
  class MyModel(models.Model):
    address1 = AddressField()
    address2 = AddressField(related_name='+', blank=True, null=True)
```
## Setting Values
Values can be set either by assigning an Address object:
```python
  addr = Address(...)
  addr.save()
  obj.address = addr
```
Or by supplying a dictionary of address components:
```python
  obj.address = {'street_number': '1', 'route': 'Somewhere Ave', ...}
```
The structure of the address components is as follows:
```python
  {
    'raw': '1 Somewhere Ave, Northcote, VIC 3070, AU',
    'street_number': '1',
    'route': 'Somewhere Ave',
    'locality': 'Northcote',
    'postal_code': '3070',
    'state': 'Victoria',
    'state_code': 'VIC',
    'country': 'Australia',
    'country_code': 'AU'
  }
```
All except the `raw` field can be omitted. In addition, a raw address may
be set directly:
```python
obj.address = 'Out the back of 1 Somewhere Ave, Northcote, Australia'
```
## Getting Values
When accessed, the address field simply returns an Address object. This way
all components may be accessed naturally through the object. For example::
```python
  route = obj.address.route
  state_name = obj.address.locality.state.name
```
## Forms
Included is a form field for simplifying address entry. A Google maps
auto-complete is performed in the browser and passed to the view. If
the lookup fails the raw entered value is used.
TODO: Talk about this more.
## Partial Example
The model:
```python
from address.models import AddressField
class Person(models.Model):
  address = AddressField(on_delete=models.CASCADE)
```
The form:
```python
from address.forms import AddressField
class PersonForm(forms.Form):
  address = AddressField()
```
The template:
```html
<head>
{{ form.media }} <!-- needed for JS/GoogleMaps lookup -->
</head>
<body>
  {{ form }}
</body>
```
## Running Django-Address Tests
Django-address currently has partial form and model test coverage using `django.test.TestCase`.
To run the current tests:
 1. [Clone](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) `django-address` locally.
 1. Navigate to the example site, . `/django-address/example_site`
 1. Create a [virtual environment](https://www.tangowithdjango.com/book17/chapters/requirements.html#virtual-environments) and install the example site dependencies. For example:
    ```
    mkvirtualenv -p python3 django-address
    pip install -r requirements.txt
    ```
 1. Run `./manage.py test`
## Important note regarding US Territories
Django-address does not currently support the parsing of US territories aka Protectorates such as Guam or Puerto Rico.
This topic is under active consideration and its status is described in [#82](https://github.com/furious-luke/django-address/issues/82)
## Project Status Notes
This library was created by [Luke Hodkinson](@furious-luke) originally focused on Australian addresses.
In 2015 Luke began working to abstract the project so it could handle a wider variety of international addresses.
This became the current `dev` branch.  While good progress was made on this, the branch became stale and releases
continued under the current model architecture on master. 
The project is currently in open development, read more about the project status [in this issue](https://github.com/furious-luke/django-address/issues/98).  
If you have questions, bug reports or suggestions please create a New Issue for the project.

%package help
Summary:	Development documents and examples for django-address
Provides:	python3-django-address-doc
%description help
# Overview
Django Address is a set of models and methods for working with postal addresses.
# Requirements
 * Python (3.5, 3.6, 3.7, 3.8)
 * Django (2.2, 3.0)
We **recommend** and only officially support the latest patch release of each Python and Django series. 
# Installation
For more detailed instructions, [view the Readme for the example site](https://github.com/furious-luke/django-address/blob/master/example_site/README.md) included with this package.
```bash
pip install django-address
```
Then, add `address` to your `INSTALLED_APPS` list in `settings.py`:
```python
INSTALLED_APPS = [
    # ... 
    'address',
    # ... 
]
```
You can either store your Google API key in an environment variable as `GOOGLE_API_KEY` or you can
 specify the key in `settings.py`. If you have an environment variable set it will override what you put in settings.py.
 For more information, including enabling the Google Places API, refer to [the example site](https://github.com/furious-luke/django-address/blob/master/example_site/README.md).
```
GOOGLE_API_KEY = 'AIzaSyD--your-google-maps-key-SjQBE'
```
# The Model
The rationale behind the model structure is centered on trying to make
it easy to enter addresses that may be poorly defined. The model field included
uses Google Maps API v3 (via the nicely done [geocomplete jquery plugin](http://ubilabs.github.io/geocomplete/)) to
determine a proper address where possible. However if this isn't possible the
raw address is used and the user is responsible for breaking the address down
into components.
It's currently assumed any address is represent-able using four components:
country, state, locality and street address. In addition, country code, state
code and postal code may be stored, if they exist.
There are four Django models used:
```
  Country
    name
    code
  State
    name
    code
    country -> Country
  Locality
    name
    postal_code
    state -> State
  Address
    raw
    street_number
    route
    locality -> Locality
```
# Address Field
To simplify storage and access of addresses, a subclass of `ForeignKey` named
`AddressField` has been created. It provides an easy method for setting new
addresses.
## ON_DELETE behavior of Address Field
By default, if you delete an Address that is related to another object, 
Django's [cascade behavior](https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.on_delete) 
is used. This means the related object will also be deleted. You may also choose
to set `null=True` when defining an address field to have the address set
to Null instead of deleting the related object. For more information and an example,
see the readme for the `django-address` example_site.
## Creation
It can be created using the same optional arguments as a ForeignKey field.
For example:
```python
  from address.models import AddressField
  class MyModel(models.Model):
    address1 = AddressField()
    address2 = AddressField(related_name='+', blank=True, null=True)
```
## Setting Values
Values can be set either by assigning an Address object:
```python
  addr = Address(...)
  addr.save()
  obj.address = addr
```
Or by supplying a dictionary of address components:
```python
  obj.address = {'street_number': '1', 'route': 'Somewhere Ave', ...}
```
The structure of the address components is as follows:
```python
  {
    'raw': '1 Somewhere Ave, Northcote, VIC 3070, AU',
    'street_number': '1',
    'route': 'Somewhere Ave',
    'locality': 'Northcote',
    'postal_code': '3070',
    'state': 'Victoria',
    'state_code': 'VIC',
    'country': 'Australia',
    'country_code': 'AU'
  }
```
All except the `raw` field can be omitted. In addition, a raw address may
be set directly:
```python
obj.address = 'Out the back of 1 Somewhere Ave, Northcote, Australia'
```
## Getting Values
When accessed, the address field simply returns an Address object. This way
all components may be accessed naturally through the object. For example::
```python
  route = obj.address.route
  state_name = obj.address.locality.state.name
```
## Forms
Included is a form field for simplifying address entry. A Google maps
auto-complete is performed in the browser and passed to the view. If
the lookup fails the raw entered value is used.
TODO: Talk about this more.
## Partial Example
The model:
```python
from address.models import AddressField
class Person(models.Model):
  address = AddressField(on_delete=models.CASCADE)
```
The form:
```python
from address.forms import AddressField
class PersonForm(forms.Form):
  address = AddressField()
```
The template:
```html
<head>
{{ form.media }} <!-- needed for JS/GoogleMaps lookup -->
</head>
<body>
  {{ form }}
</body>
```
## Running Django-Address Tests
Django-address currently has partial form and model test coverage using `django.test.TestCase`.
To run the current tests:
 1. [Clone](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) `django-address` locally.
 1. Navigate to the example site, . `/django-address/example_site`
 1. Create a [virtual environment](https://www.tangowithdjango.com/book17/chapters/requirements.html#virtual-environments) and install the example site dependencies. For example:
    ```
    mkvirtualenv -p python3 django-address
    pip install -r requirements.txt
    ```
 1. Run `./manage.py test`
## Important note regarding US Territories
Django-address does not currently support the parsing of US territories aka Protectorates such as Guam or Puerto Rico.
This topic is under active consideration and its status is described in [#82](https://github.com/furious-luke/django-address/issues/82)
## Project Status Notes
This library was created by [Luke Hodkinson](@furious-luke) originally focused on Australian addresses.
In 2015 Luke began working to abstract the project so it could handle a wider variety of international addresses.
This became the current `dev` branch.  While good progress was made on this, the branch became stale and releases
continued under the current model architecture on master. 
The project is currently in open development, read more about the project status [in this issue](https://github.com/furious-luke/django-address/issues/98).  
If you have questions, bug reports or suggestions please create a New Issue for the project.

%prep
%autosetup -n django-address-0.2.8

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-django-address -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Tue Apr 25 2023 Python_Bot <Python_Bot@openeuler.org> - 0.2.8-1
- Package Spec generated