accrete 0.0.122__py3-none-any.whl → 0.0.123__py3-none-any.whl

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.
File without changes
@@ -0,0 +1,11 @@
1
+ from django.contrib import admin
2
+ from .models import Country
3
+
4
+
5
+ class CountryAdmin(admin.ModelAdmin):
6
+ model = Country
7
+ list_display = ('name', 'iso_code_a2', 'iso_code_a3', 'vat_prefix', 'order_priority')
8
+ search_fields = ('name', 'iso_code_a2', 'iso_code_a3', 'vat_prefix')
9
+
10
+
11
+ admin.site.register(Country, CountryAdmin)
@@ -0,0 +1,6 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class CountryConfig(AppConfig):
5
+ default_auto_field = 'django.db.models.BigAutoField'
6
+ name = 'accrete.contrib.country'
@@ -0,0 +1,33 @@
1
+ # Generated by Django 5.1.4 on 2025-02-19 16:59
2
+
3
+ import accrete.fields
4
+ import django.db.models.functions.text
5
+ from django.db import migrations, models
6
+
7
+
8
+ class Migration(migrations.Migration):
9
+
10
+ initial = True
11
+
12
+ dependencies = [
13
+ ]
14
+
15
+ operations = [
16
+ migrations.CreateModel(
17
+ name='Country',
18
+ fields=[
19
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20
+ ('name', accrete.fields.TranslatedCharField(verbose_name='Name')),
21
+ ('iso_code_a2', models.CharField(max_length=2, verbose_name='ISO Code Alpha 2')),
22
+ ('iso_code_a3', models.CharField(max_length=3, verbose_name='ISO Code Alpha 3')),
23
+ ('vat_prefix', models.CharField(blank=True, max_length=3, null=True, verbose_name='VAT ID Prefix')),
24
+ ('order_priority', models.IntegerField(default=0, verbose_name='Order Priority')),
25
+ ],
26
+ options={
27
+ 'verbose_name': 'Country',
28
+ 'verbose_name_plural': 'Countries',
29
+ 'db_table': 'accrete_country',
30
+ 'ordering': ['-order_priority', django.db.models.functions.text.Lower('name')],
31
+ },
32
+ ),
33
+ ]
@@ -0,0 +1,286 @@
1
+ # Generated by Django 5.1.4 on 2025-02-19 14:32
2
+ import logging
3
+ from django.db import migrations
4
+ from django.db import connection
5
+
6
+ _logger = logging.getLogger(__name__)
7
+
8
+
9
+ def create_countries(apps, schema_editor):
10
+ with connection.cursor() as cr:
11
+ cr.execute(
12
+ """
13
+ INSERT INTO
14
+ accrete_country(name, iso_code_a2, iso_code_a3, vat_prefix, order_priority)
15
+ VALUES
16
+ ('{"de-de": "Aruba", "en-us": "Aruba"}', 'AW', 'ABW', null, 0),
17
+ ('{"de-de": "Afghanistan", "en-us": "Afghanistan"}', 'AF', 'AFG', null, 0),
18
+ ('{"de-de": "Angola", "en-us": "Angola"}', 'AO', 'AGO', null, 0),
19
+ ('{"de-de": "Anguilla", "en-us": "Anguilla"}', 'AI', 'AIA', null, 0),
20
+ ('{"de-de": "Åland Islands", "en-us": "Åland Islands"}', 'AX', 'ALA', null, 0),
21
+ ('{"de-de": "Albanien", "en-us": "Albania"}', 'AL', 'ALB', null, 0),
22
+ ('{"de-de": "Andorra", "en-us": "Andorra"}', 'AD', 'AND', null, 0),
23
+ ('{"de-de": "Vereinigte Arabische Emirate", "en-us": "United Arab Emirates"}', 'AE', 'ARE', null, 0),
24
+ ('{"de-de": "Argentinien", "en-us": "Argentina"}', 'AR', 'ARG', null, 0),
25
+ ('{"de-de": "Armenien", "en-us": "Armenia"}', 'AM', 'ARM', null, 0),
26
+ ('{"de-de": "American Samoa", "en-us": "American Samoa"}', 'AS', 'ASM', null, 0),
27
+ ('{"de-de": "Antarctica", "en-us": "Antarctica"}', 'AQ', 'ATA', null, 0),
28
+ ('{"de-de": "French Southern Territories", "en-us": "French Southern Territories"}', 'TF', 'ATF', null, 0),
29
+ ('{"de-de": "Antigua and Barbuda", "en-us": "Antigua and Barbuda"}', 'AG', 'ATG', null, 0),
30
+ ('{"de-de": "Australien", "en-us": "Australia"}', 'AU', 'AUS', null, 0),
31
+ ('{"de-de": "Österreich", "en-us": "Austria"}', 'AT', 'AUT', 'AT', 0),
32
+ ('{"de-de": "Aserbaidschan", "en-us": "Azerbaijan"}', 'AZ', 'AZE', null, 0),
33
+ ('{"de-de": "Burundi", "en-us": "Burundi"}', 'BI', 'BDI', null, 0),
34
+ ('{"de-de": "Belgien", "en-us": "Belgium"}', 'BE', 'BEL', 'BE', 0),
35
+ ('{"de-de": "Benin", "en-us": "Benin"}', 'BJ', 'BEN', null, 0),
36
+ ('{"de-de": "Bonaire, Sint Eustatius and Saba", "en-us": "Bonaire, Sint Eustatius and Saba"}', 'BQ', 'BES', null, 0),
37
+ ('{"de-de": "Burkina Faso", "en-us": "Burkina Faso"}', 'BF', 'BFA', null, 0),
38
+ ('{"de-de": "Bangladesch", "en-us": "Bangladesh"}', 'BD', 'BGD', null, 0),
39
+ ('{"de-de": "Bulgarien", "en-us": "Bulgaria"}', 'BG', 'BGR', 'BG', 0),
40
+ ('{"de-de": "Bahrain", "en-us": "Bahrain"}', 'BH', 'BHR', null, 0),
41
+ ('{"de-de": "Bahamas", "en-us": "Bahamas"}', 'BS', 'BHS', null, 0),
42
+ ('{"de-de": "Bosnien und Herzegowina", "en-us": "Bosnia and Herzegovina"}', 'BA', 'BIH', null, 0),
43
+ ('{"de-de": "Saint Barthélemy", "en-us": "Saint Barthélemy"}', 'BL', 'BLM', null, 0),
44
+ ('{"de-de": "Belarus", "en-us": "Belarus"}', 'BY', 'BLR', null, 0),
45
+ ('{"de-de": "Belize", "en-us": "Belize"}', 'BZ', 'BLZ', null, 0),
46
+ ('{"de-de": "Bermuda", "en-us": "Bermuda"}', 'BM', 'BMU', null, 0),
47
+ ('{"de-de": "Bolivien", "en-us": "Bolivia, Plurinational State of"}', 'BO', 'BOL', null, 0),
48
+ ('{"de-de": "Brasilien", "en-us": "Brazil"}', 'BR', 'BRA', null, 0),
49
+ ('{"de-de": "Barbados", "en-us": "Barbados"}', 'BB', 'BRB', null, 0),
50
+ ('{"de-de": "Brunei Darussalam", "en-us": "Brunei Darussalam"}', 'BN', 'BRN', null, 0),
51
+ ('{"de-de": "Bhutan", "en-us": "Bhutan"}', 'BT', 'BTN', null, 0),
52
+ ('{"de-de": "Bouvet Island", "en-us": "Bouvet Island"}', 'BV', 'BVT', null, 0),
53
+ ('{"de-de": "Botswana", "en-us": "Botswana"}', 'BW', 'BWA', null, 0),
54
+ ('{"de-de": "Central African Republic", "en-us": "Central African Republic"}', 'CF', 'CAF', null, 0),
55
+ ('{"de-de": "Kanada", "en-us": "Canada"}', 'CA', 'CAN', null, 0),
56
+ ('{"de-de": "Cocos (Keeling) Islands", "en-us": "Cocos (Keeling) Islands"}', 'CC', 'CCK', null, 0),
57
+ ('{"de-de": "Schweiz", "en-us": "Switzerland"}', 'CH', 'CHE', null, 0),
58
+ ('{"de-de": "Chile", "en-us": "Chile"}', 'CL', 'CHL', null, 0),
59
+ ('{"de-de": "China", "en-us": "China"}', 'CN', 'CHN', null, 0),
60
+ ('{"de-de": "Elfenbeinküste", "en-us": "Ivory Coast"}', 'CI', 'CIV', null, 0),
61
+ ('{"de-de": "Cameroon", "en-us": "Cameroon"}', 'CM', 'CMR', null, 0),
62
+ ('{"de-de": "Congo, The Democratic Republic of the", "en-us": "Congo, The Democratic Republic of the"}', 'CD', 'COD', null, 0),
63
+ ('{"de-de": "Congo", "en-us": "Congo"}', 'CG', 'COG', null, 0),
64
+ ('{"de-de": "Cook Islands", "en-us": "Cook Islands"}', 'CK', 'COK', null, 0),
65
+ ('{"de-de": "Kolumbien", "en-us": "Colombia"}', 'CO', 'COL', null, 0),
66
+ ('{"de-de": "Comoros", "en-us": "Comoros"}', 'KM', 'COM', null, 0),
67
+ ('{"de-de": "Cabo Verde", "en-us": "Cabo Verde"}', 'CV', 'CPV', null, 0),
68
+ ('{"de-de": "Costa Rica", "en-us": "Costa Rica"}', 'CR', 'CRI', null, 0),
69
+ ('{"de-de": "Kuba", "en-us": "Cuba"}', 'CU', 'CUB', null, 0),
70
+ ('{"de-de": "Curaçao", "en-us": "Curaçao"}', 'CW', 'CUW', null, 0),
71
+ ('{"de-de": "Christmas Island", "en-us": "Christmas Island"}', 'CX', 'CXR', null, 0),
72
+ ('{"de-de": "Cayman Islands", "en-us": "Cayman Islands"}', 'KY', 'CYM', null, 0),
73
+ ('{"de-de": "Zypern", "en-us": "Cyprus"}', 'CY', 'CYP', 'CY', 0),
74
+ ('{"de-de": "Tschechien", "en-us": "Czechia"}', 'CZ', 'CZE', 'CZ', 0),
75
+ ('{"de-de": "Deutschland", "en-us": "Germany"}', 'DE', 'DEU', 'DE', 0),
76
+ ('{"de-de": "Djibouti", "en-us": "Djibouti"}', 'DJ', 'DJI', null, 0),
77
+ ('{"de-de": "Dominica", "en-us": "Dominica"}', 'DM', 'DMA', null, 0),
78
+ ('{"de-de": "Dänemark", "en-us": "Denmark"}', 'DK', 'DNK', 'DK', 0),
79
+ ('{"de-de": "Dominican Republic", "en-us": "Dominican Republic"}', 'DO', 'DOM', null, 0),
80
+ ('{"de-de": "Algerien", "en-us": "Algeria"}', 'DZ', 'DZA', null, 0),
81
+ ('{"de-de": "Ecuador", "en-us": "Ecuador"}', 'EC', 'ECU', null, 0),
82
+ ('{"de-de": "Ägypten", "en-us": "Egypt"}', 'EG', 'EGY', null, 0),
83
+ ('{"de-de": "Eritrea", "en-us": "Eritrea"}', 'ER', 'ERI', null, 0),
84
+ ('{"de-de": "Western Sahara", "en-us": "Western Sahara"}', 'EH', 'ESH', null, 0),
85
+ ('{"de-de": "Spanien", "en-us": "Spain"}', 'ES', 'ESP', 'ES', 0),
86
+ ('{"de-de": "Estland", "en-us": "Estonia"}', 'EE', 'EST', 'EE', 0),
87
+ ('{"de-de": "Ethiopia", "en-us": "Ethiopia"}', 'ET', 'ETH', null, 0),
88
+ ('{"de-de": "Finnland", "en-us": "Finland"}', 'FI', 'FIN', 'FI', 0),
89
+ ('{"de-de": "Fiji", "en-us": "Fiji"}', 'FJ', 'FJI', null, 0),
90
+ ('{"de-de": "Falkland Islands (Malvinas)", "en-us": "Falkland Islands (Malvinas)"}', 'FK', 'FLK', null, 0),
91
+ ('{"de-de": "Frankreich", "en-us": "France"}', 'FR', 'FRA', 'FR', 0),
92
+ ('{"de-de": "Faroe Islands", "en-us": "Faroe Islands"}', 'FO', 'FRO', null, 0),
93
+ ('{"de-de": "Micronesia, Federated States of", "en-us": "Micronesia, Federated States of"}', 'FM', 'FSM', null, 0),
94
+ ('{"de-de": "Gabon", "en-us": "Gabon"}', 'GA', 'GAB', null, 0),
95
+ ('{"de-de": "Vereinigtes Königreich", "en-us": "United Kingdom"}', 'GB', 'GBR', null, 0),
96
+ ('{"de-de": "Georgia", "en-us": "Georgia"}', 'GE', 'GEO', null, 0),
97
+ ('{"de-de": "Guernsey", "en-us": "Guernsey"}', 'GG', 'GGY', null, 0),
98
+ ('{"de-de": "Ghana", "en-us": "Ghana"}', 'GH', 'GHA', null, 0),
99
+ ('{"de-de": "Gibraltar", "en-us": "Gibraltar"}', 'GI', 'GIB', null, 0),
100
+ ('{"de-de": "Guinea", "en-us": "Guinea"}', 'GN', 'GIN', null, 0),
101
+ ('{"de-de": "Guadeloupe", "en-us": "Guadeloupe"}', 'GP', 'GLP', null, 0),
102
+ ('{"de-de": "Gambia", "en-us": "Gambia"}', 'GM', 'GMB', null, 0),
103
+ ('{"de-de": "Guinea-Bissau", "en-us": "Guinea-Bissau"}', 'GW', 'GNB', null, 0),
104
+ ('{"de-de": "Equatorial Guinea", "en-us": "Equatorial Guinea"}', 'GQ', 'GNQ', null, 0),
105
+ ('{"de-de": "Griechenland", "en-us": "Greece"}', 'GR', 'GRC', null, 0),
106
+ ('{"de-de": "Grenada", "en-us": "Grenada"}', 'GD', 'GRD', null, 0),
107
+ ('{"de-de": "Greenland", "en-us": "Greenland"}', 'GL', 'GRL', null, 0),
108
+ ('{"de-de": "Guatemala", "en-us": "Guatemala"}', 'GT', 'GTM', null, 0),
109
+ ('{"de-de": "French Guiana", "en-us": "French Guiana"}', 'GF', 'GUF', null, 0),
110
+ ('{"de-de": "Guam", "en-us": "Guam"}', 'GU', 'GUM', null, 0),
111
+ ('{"de-de": "Guyana", "en-us": "Guyana"}', 'GY', 'GUY', null, 0),
112
+ ('{"de-de": "Hong Kong", "en-us": "Hong Kong"}', 'HK', 'HKG', null, 0),
113
+ ('{"de-de": "Heard Island and McDonald Islands", "en-us": "Heard Island and McDonald Islands"}', 'HM', 'HMD', null, 0),
114
+ ('{"de-de": "Honduras", "en-us": "Honduras"}', 'HN', 'HND', null, 0),
115
+ ('{"de-de": "Kroatien", "en-us": "Croatia"}', 'HR', 'HRV', 'HR', 0),
116
+ ('{"de-de": "Haiti", "en-us": "Haiti"}', 'HT', 'HTI', null, 0),
117
+ ('{"de-de": "Ungarn", "en-us": "Hungary"}', 'HU', 'HUN', 'HU', 0),
118
+ ('{"de-de": "Indonesien", "en-us": "Indonesia"}', 'ID', 'IDN', null, 0),
119
+ ('{"de-de": "Isle of Man", "en-us": "Isle of Man"}', 'IM', 'IMN', null, 0),
120
+ ('{"de-de": "Indien", "en-us": "India"}', 'IN', 'IND', null, 0),
121
+ ('{"de-de": "British Indian Ocean Territory", "en-us": "British Indian Ocean Territory"}', 'IO', 'IOT', null, 0),
122
+ ('{"de-de": "Irland", "en-us": "Ireland"}', 'IE', 'IRL', 'IE', 0),
123
+ ('{"de-de": "Iran, Islamic Republic of", "en-us": "Iran, Islamic Republic of"}', 'IR', 'IRN', null, 0),
124
+ ('{"de-de": "Iraq", "en-us": "Iraq"}', 'IQ', 'IRQ', null, 0),
125
+ ('{"de-de": "Iceland", "en-us": "Iceland"}', 'IS', 'ISL', null, 0),
126
+ ('{"de-de": "Israel", "en-us": "Israel"}', 'IL', 'ISR', null, 0),
127
+ ('{"de-de": "Italien", "en-us": "Italy"}', 'IT', 'ITA', 'IT', 0),
128
+ ('{"de-de": "Jamaica", "en-us": "Jamaica"}', 'JM', 'JAM', null, 0),
129
+ ('{"de-de": "Jersey", "en-us": "Jersey"}', 'JE', 'JEY', null, 0),
130
+ ('{"de-de": "Jordan", "en-us": "Jordan"}', 'JO', 'JOR', null, 0),
131
+ ('{"de-de": "Japan", "en-us": "Japan"}', 'JP', 'JPN', null, 0),
132
+ ('{"de-de": "Kasachstan", "en-us": "Kazakhstan"}', 'KZ', 'KAZ', null, 0),
133
+ ('{"de-de": "Kenia", "en-us": "Kenya"}', 'KE', 'KEN', null, 0),
134
+ ('{"de-de": "Kyrgyzstan", "en-us": "Kyrgyzstan"}', 'KG', 'KGZ', null, 0),
135
+ ('{"de-de": "Cambodia", "en-us": "Cambodia"}', 'KH', 'KHM', null, 0),
136
+ ('{"de-de": "Kiribati", "en-us": "Kiribati"}', 'KI', 'KIR', null, 0),
137
+ ('{"de-de": "Saint Kitts and Nevis", "en-us": "Saint Kitts and Nevis"}', 'KN', 'KNA', null, 0),
138
+ ('{"de-de": "Südkorea", "en-us": "Korea, Republic of"}', 'KR', 'KOR', null, 0),
139
+ ('{"de-de": "Kuwait", "en-us": "Kuwait"}', 'KW', 'KWT', null, 0),
140
+ ('{"de-de": "Lao Peoples Democratic Republic", "en-us": "Lao Peoples Democratic Republic"}', 'LA', 'LAO', null, 0),
141
+ ('{"de-de": "Lebanon", "en-us": "Lebanon"}', 'LB', 'LBN', null, 0),
142
+ ('{"de-de": "Liberia", "en-us": "Liberia"}', 'LR', 'LBR', null, 0),
143
+ ('{"de-de": "Libya", "en-us": "Libya"}', 'LY', 'LBY', null, 0),
144
+ ('{"de-de": "Saint Lucia", "en-us": "Saint Lucia"}', 'LC', 'LCA', null, 0),
145
+ ('{"de-de": "Liechtenstein", "en-us": "Liechtenstein"}', 'LI', 'LIE', null, 0),
146
+ ('{"de-de": "Sri Lanka", "en-us": "Sri Lanka"}', 'LK', 'LKA', null, 0),
147
+ ('{"de-de": "Lesotho", "en-us": "Lesotho"}', 'LS', 'LSO', null, 0),
148
+ ('{"de-de": "Litauen", "en-us": "Lithuania"}', 'LT', 'LTU', 'LT', 0),
149
+ ('{"de-de": "Luxemburg", "en-us": "Luxembourg"}', 'LU', 'LUX', 'LU', 0),
150
+ ('{"de-de": "Lettland", "en-us": "Latvia"}', 'LV', 'LVA', 'LV', 0),
151
+ ('{"de-de": "Macao", "en-us": "Macao"}', 'MO', 'MAC', null, 0),
152
+ ('{"de-de": "Saint Martin (French part)", "en-us": "Saint Martin (French part)"}', 'MF', 'MAF', null, 0),
153
+ ('{"de-de": "Marokko", "en-us": "Morocco"}', 'MA', 'MAR', null, 0),
154
+ ('{"de-de": "Monaco", "en-us": "Monaco"}', 'MC', 'MCO', null, 0),
155
+ ('{"de-de": "Moldova, Republic of", "en-us": "Moldova, Republic of"}', 'MD', 'MDA', null, 0),
156
+ ('{"de-de": "Madagascar", "en-us": "Madagascar"}', 'MG', 'MDG', null, 0),
157
+ ('{"de-de": "Maldives", "en-us": "Maldives"}', 'MV', 'MDV', null, 0),
158
+ ('{"de-de": "Mexiko", "en-us": "Mexico"}', 'MX', 'MEX', null, 0),
159
+ ('{"de-de": "Marshall Islands", "en-us": "Marshall Islands"}', 'MH', 'MHL', null, 0),
160
+ ('{"de-de": "North Macedonia", "en-us": "North Macedonia"}', 'MK', 'MKD', null, 0),
161
+ ('{"de-de": "Mali", "en-us": "Mali"}', 'ML', 'MLI', null, 0),
162
+ ('{"de-de": "Malta", "en-us": "Malta"}', 'MT', 'MLT', 'MT', 0),
163
+ ('{"de-de": "Myanmar", "en-us": "Myanmar"}', 'MM', 'MMR', null, 0),
164
+ ('{"de-de": "Montenegro", "en-us": "Montenegro"}', 'ME', 'MNE', null, 0),
165
+ ('{"de-de": "Mongolia", "en-us": "Mongolia"}', 'MN', 'MNG', null, 0),
166
+ ('{"de-de": "Northern Mariana Islands", "en-us": "Northern Mariana Islands"}', 'MP', 'MNP', null, 0),
167
+ ('{"de-de": "Mozambique", "en-us": "Mozambique"}', 'MZ', 'MOZ', null, 0),
168
+ ('{"de-de": "Mauritania", "en-us": "Mauritania"}', 'MR', 'MRT', null, 0),
169
+ ('{"de-de": "Montserrat", "en-us": "Montserrat"}', 'MS', 'MSR', null, 0),
170
+ ('{"de-de": "Martinique", "en-us": "Martinique"}', 'MQ', 'MTQ', null, 0),
171
+ ('{"de-de": "Mauritius", "en-us": "Mauritius"}', 'MU', 'MUS', null, 0),
172
+ ('{"de-de": "Malawi", "en-us": "Malawi"}', 'MW', 'MWI', null, 0),
173
+ ('{"de-de": "Malaysia", "en-us": "Malaysia"}', 'MY', 'MYS', null, 0),
174
+ ('{"de-de": "Mayotte", "en-us": "Mayotte"}', 'YT', 'MYT', null, 0),
175
+ ('{"de-de": "Namibia", "en-us": "Namibia"}', 'NA', 'NAM', null, 0),
176
+ ('{"de-de": "New Caledonia", "en-us": "New Caledonia"}', 'NC', 'NCL', null, 0),
177
+ ('{"de-de": "Niger", "en-us": "Niger"}', 'NE', 'NER', null, 0),
178
+ ('{"de-de": "Norfolk Island", "en-us": "Norfolk Island"}', 'NF', 'NFK', null, 0),
179
+ ('{"de-de": "Nigeria", "en-us": "Nigeria"}', 'NG', 'NGA', null, 0),
180
+ ('{"de-de": "Nicaragua", "en-us": "Nicaragua"}', 'NI', 'NIC', null, 0),
181
+ ('{"de-de": "Niue", "en-us": "Niue"}', 'NU', 'NIU', null, 0),
182
+ ('{"de-de": "Niederlande", "en-us": "Netherlands"}', 'NL', 'NLD', 'NL', 0),
183
+ ('{"de-de": "Norwegen", "en-us": "Norway"}', 'NO', 'NOR', null, 0),
184
+ ('{"de-de": "Nepal", "en-us": "Nepal"}', 'NP', 'NPL', null, 0),
185
+ ('{"de-de": "Nauru", "en-us": "Nauru"}', 'NR', 'NRU', null, 0),
186
+ ('{"de-de": "Neuseeland", "en-us": "New Zealand"}', 'NZ', 'NZL', null, 0),
187
+ ('{"de-de": "Oman", "en-us": "Oman"}', 'OM', 'OMN', null, 0),
188
+ ('{"de-de": "Pakistan", "en-us": "Pakistan"}', 'PK', 'PAK', null, 0),
189
+ ('{"de-de": "Panama", "en-us": "Panama"}', 'PA', 'PAN', null, 0),
190
+ ('{"de-de": "Pitcairn", "en-us": "Pitcairn"}', 'PN', 'PCN', null, 0),
191
+ ('{"de-de": "Peru", "en-us": "Peru"}', 'PE', 'PER', null, 0),
192
+ ('{"de-de": "Philippinen", "en-us": "Philippines"}', 'PH', 'PHL', null, 0),
193
+ ('{"de-de": "Palau", "en-us": "Palau"}', 'PW', 'PLW', null, 0),
194
+ ('{"de-de": "Papua New Guinea", "en-us": "Papua New Guinea"}', 'PG', 'PNG', null, 0),
195
+ ('{"de-de": "Polen", "en-us": "Poland"}', 'PL', 'POL', 'PL', 0),
196
+ ('{"de-de": "Puerto Rico", "en-us": "Puerto Rico"}', 'PR', 'PRI', null, 0),
197
+ ('{"de-de": "Nordkorea", "en-us": "North Korea"}', 'KP', 'PRK', null, 0),
198
+ ('{"de-de": "Portugal", "en-us": "Portugal"}', 'PT', 'PRT', 'PT', 0),
199
+ ('{"de-de": "Paraguay", "en-us": "Paraguay"}', 'PY', 'PRY', null, 0),
200
+ ('{"de-de": "Palestine, State of", "en-us": "Palestine, State of"}', 'PS', 'PSE', null, 0),
201
+ ('{"de-de": "French Polynesia", "en-us": "French Polynesia"}', 'PF', 'PYF', null, 0),
202
+ ('{"de-de": "Qatar", "en-us": "Qatar"}', 'QA', 'QAT', null, 0),
203
+ ('{"de-de": "Réunion", "en-us": "Réunion"}', 'RE', 'REU', null, 0),
204
+ ('{"de-de": "Rumänien", "en-us": "Romania"}', 'RO', 'ROU', 'RO', 0),
205
+ ('{"de-de": "Russland", "en-us": "Russian Federation"}', 'RU', 'RUS', null, 0),
206
+ ('{"de-de": "Rwanda", "en-us": "Rwanda"}', 'RW', 'RWA', null, 0),
207
+ ('{"de-de": "Saudi-Arabien", "en-us": "Saudi Arabia"}', 'SA', 'SAU', null, 0),
208
+ ('{"de-de": "Sudan", "en-us": "Sudan"}', 'SD', 'SDN', null, 0),
209
+ ('{"de-de": "Senegal", "en-us": "Senegal"}', 'SN', 'SEN', null, 0),
210
+ ('{"de-de": "Singapur", "en-us": "Singapore"}', 'SG', 'SGP', null, 0),
211
+ ('{"de-de": "South Georgia and the South Sandwich Islands", "en-us": "South Georgia and the South Sandwich Islands"}', 'GS', 'SGS', null, 0),
212
+ ('{"de-de": "Saint Helena, Ascension and Tristan da Cunha", "en-us": "Saint Helena, Ascension and Tristan da Cunha"}', 'SH', 'SHN', null, 0),
213
+ ('{"de-de": "Svalbard and Jan Mayen", "en-us": "Svalbard and Jan Mayen"}', 'SJ', 'SJM', null, 0),
214
+ ('{"de-de": "Solomon Islands", "en-us": "Solomon Islands"}', 'SB', 'SLB', null, 0),
215
+ ('{"de-de": "Sierra Leone", "en-us": "Sierra Leone"}', 'SL', 'SLE', null, 0),
216
+ ('{"de-de": "El Salvador", "en-us": "El Salvador"}', 'SV', 'SLV', null, 0),
217
+ ('{"de-de": "San Marino", "en-us": "San Marino"}', 'SM', 'SMR', null, 0),
218
+ ('{"de-de": "Somalia", "en-us": "Somalia"}', 'SO', 'SOM', null, 0),
219
+ ('{"de-de": "Saint Pierre and Miquelon", "en-us": "Saint Pierre and Miquelon"}', 'PM', 'SPM', null, 0),
220
+ ('{"de-de": "Serbien", "en-us": "Serbia"}', 'RS', 'SRB', null, 0),
221
+ ('{"de-de": "South Sudan", "en-us": "South Sudan"}', 'SS', 'SSD', null, 0),
222
+ ('{"de-de": "Sao Tome and Principe", "en-us": "Sao Tome and Principe"}', 'ST', 'STP', null, 0),
223
+ ('{"de-de": "Suriname", "en-us": "Suriname"}', 'SR', 'SUR', null, 0),
224
+ ('{"de-de": "Slowakei", "en-us": "Slovakia"}', 'SK', 'SVK', 'SK', 0),
225
+ ('{"de-de": "Slowenien", "en-us": "Slovenia"}', 'SI', 'SVN', 'SI', 0),
226
+ ('{"de-de": "Schweden", "en-us": "Sweden"}', 'SE', 'SWE', 'SE', 0),
227
+ ('{"de-de": "Eswatini", "en-us": "Eswatini"}', 'SZ', 'SWZ', null, 0),
228
+ ('{"de-de": "Sint Maarten (Dutch part)", "en-us": "Sint Maarten (Dutch part)"}', 'SX', 'SXM', null, 0),
229
+ ('{"de-de": "Seychelles", "en-us": "Seychelles"}', 'SC', 'SYC', null, 0),
230
+ ('{"de-de": "Syrian Arab Republic", "en-us": "Syrian Arab Republic"}', 'SY', 'SYR', null, 0),
231
+ ('{"de-de": "Turks and Caicos Islands", "en-us": "Turks and Caicos Islands"}', 'TC', 'TCA', null, 0),
232
+ ('{"de-de": "Chad", "en-us": "Chad"}', 'TD', 'TCD', null, 0),
233
+ ('{"de-de": "Togo", "en-us": "Togo"}', 'TG', 'TGO', null, 0),
234
+ ('{"de-de": "Thailand", "en-us": "Thailand"}', 'TH', 'THA', null, 0),
235
+ ('{"de-de": "Tajikistan", "en-us": "Tajikistan"}', 'TJ', 'TJK', null, 0),
236
+ ('{"de-de": "Tokelau", "en-us": "Tokelau"}', 'TK', 'TKL', null, 0),
237
+ ('{"de-de": "Turkmenistan", "en-us": "Turkmenistan"}', 'TM', 'TKM', null, 0),
238
+ ('{"de-de": "Timor-Leste", "en-us": "Timor-Leste"}', 'TL', 'TLS', null, 0),
239
+ ('{"de-de": "Tonga", "en-us": "Tonga"}', 'TO', 'TON', null, 0),
240
+ ('{"de-de": "Trinidad and Tobago", "en-us": "Trinidad and Tobago"}', 'TT', 'TTO', null, 0),
241
+ ('{"de-de": "Tunisia", "en-us": "Tunisia"}', 'TN', 'TUN', null, 0),
242
+ ('{"de-de": "Türkei", "en-us": "Turkey"}', 'TR', 'TUR', null, 0),
243
+ ('{"de-de": "Tuvalu", "en-us": "Tuvalu"}', 'TV', 'TUV', null, 0),
244
+ ('{"de-de": "Taiwan, Province of China", "en-us": "Taiwan, Province of China"}', 'TW', 'TWN', null, 0),
245
+ ('{"de-de": "Tanzania, United Republic of", "en-us": "Tanzania, United Republic of"}', 'TZ', 'TZA', null, 0),
246
+ ('{"de-de": "Uganda", "en-us": "Uganda"}', 'UG', 'UGA', null, 0),
247
+ ('{"de-de": "Ukraine", "en-us": "Ukraine"}', 'UA', 'UKR', null, 0),
248
+ ('{"de-de": "United States Minor Outlying Islands", "en-us": "United States Minor Outlying Islands"}', 'UM', 'UMI', null, 0),
249
+ ('{"de-de": "Uruguay", "en-us": "Uruguay"}', 'UY', 'URY', null, 0),
250
+ ('{"de-de": "Vereinigte Staaten", "en-us": "United States"}', 'US', 'USA', null, 0),
251
+ ('{"de-de": "Uzbekistan", "en-us": "Uzbekistan"}', 'UZ', 'UZB', null, 0),
252
+ ('{"de-de": "Holy See (Vatican City State)", "en-us": "Holy See (Vatican City State)"}', 'VA', 'VAT', null, 0),
253
+ ('{"de-de": "Saint Vincent and the Grenadines", "en-us": "Saint Vincent and the Grenadines"}', 'VC', 'VCT', null, 0),
254
+ ('{"de-de": "Venezuela, Bolivarian Republic of", "en-us": "Venezuela, Bolivarian Republic of"}', 'VE', 'VEN', null, 0),
255
+ ('{"de-de": "Virgin Islands, British", "en-us": "Virgin Islands, British"}', 'VG', 'VGB', null, 0),
256
+ ('{"de-de": "Virgin Islands, U.S.", "en-us": "Virgin Islands, U.S."}', 'VI', 'VIR', null, 0),
257
+ ('{"de-de": "Vietnam", "en-us": "Viet Nam"}', 'VN', 'VNM', null, 0),
258
+ ('{"de-de": "Vanuatu", "en-us": "Vanuatu"}', 'VU', 'VUT', null, 0),
259
+ ('{"de-de": "Wallis and Futuna", "en-us": "Wallis and Futuna"}', 'WF', 'WLF', null, 0),
260
+ ('{"de-de": "Samoa", "en-us": "Samoa"}', 'WS', 'WSM', null, 0),
261
+ ('{"de-de": "Yemen", "en-us": "Yemen"}', 'YE', 'YEM', null, 0),
262
+ ('{"de-de": "Südafrika", "en-us": "South Africa"}', 'ZA', 'ZAF', null, 0),
263
+ ('{"de-de": "Zambia", "en-us": "Zambia"}', 'ZM', 'ZMB', null, 0),
264
+ ('{"de-de": "Zimbabwe", "en-us": "Zimbabwe"}', 'ZW', 'ZWE', null, 0)
265
+ """
266
+ )
267
+
268
+
269
+ def revert(apps, schema_editor):
270
+ Country = apps.get_model('country', 'Country')
271
+ countries = Country.objects.all()
272
+ try:
273
+ countries.delete()
274
+ except Exception as e:
275
+ _logger.exception(e)
276
+
277
+
278
+ class Migration(migrations.Migration):
279
+
280
+ dependencies = [
281
+ ('country', '0001_initial'),
282
+ ]
283
+
284
+ operations = [
285
+ migrations.RunPython(create_countries, revert)
286
+ ]
File without changes
@@ -0,0 +1,42 @@
1
+ from django.db import models
2
+ from django.db.models.functions import Lower
3
+ from django.utils.translation import gettext_lazy as _
4
+ from accrete.fields import TranslatedCharField
5
+
6
+
7
+ class Country(models.Model):
8
+
9
+ class Meta:
10
+ verbose_name = _('Country')
11
+ verbose_name_plural = _('Countries')
12
+ db_table = 'accrete_country'
13
+ ordering = ['-order_priority', Lower('name')]
14
+
15
+ name = TranslatedCharField(
16
+ verbose_name=_('Name')
17
+ )
18
+
19
+ iso_code_a2 = models.CharField(
20
+ verbose_name=_('ISO Code Alpha 2'),
21
+ max_length=2
22
+ )
23
+
24
+ iso_code_a3 = models.CharField(
25
+ verbose_name=_('ISO Code Alpha 3'),
26
+ max_length=3
27
+ )
28
+
29
+ vat_prefix = models.CharField(
30
+ verbose_name=_('VAT ID Prefix'),
31
+ max_length=3,
32
+ null=True,
33
+ blank=True
34
+ )
35
+
36
+ order_priority = models.IntegerField(
37
+ verbose_name=_('Order Priority'),
38
+ default=0
39
+ )
40
+
41
+ def __str__(self):
42
+ return self.name
accrete/fields.py ADDED
@@ -0,0 +1,129 @@
1
+ import json
2
+ from django import forms
3
+ from django.db import connection
4
+ from django.db.models import JSONField
5
+ from django.core import checks
6
+ from django.utils.translation import get_language, gettext_lazy as _
7
+ from django.utils.text import capfirst
8
+ from django.conf import settings
9
+
10
+
11
+ class TranslatedCharField(JSONField):
12
+
13
+ description = _("A JSON object to store translated strings")
14
+ default_language = settings.LANGUAGE_CODE
15
+
16
+ def check(self, **kwargs):
17
+ errors = super().check(**kwargs)
18
+ errors.extend(self._check_choices())
19
+ return errors
20
+
21
+ def _check_choices(self):
22
+ errors = []
23
+ if self.choices is not None:
24
+ errors.append(
25
+ checks.Error(
26
+ "%s does not support Choices." % type(self).__name__,
27
+ obj=self.model,
28
+ id="fields.E180",
29
+ )
30
+ )
31
+ return errors
32
+
33
+ def pre_save(self, model_instance, add):
34
+ if not model_instance.pk:
35
+ old_val = dict()
36
+ else:
37
+ with connection.cursor() as cr:
38
+ query = """SELECT %s FROM %s WHERE id = %s""" % (
39
+ self.attname,
40
+ model_instance._meta.db_table,
41
+ model_instance.pk
42
+ )
43
+ cr.execute(query)
44
+ row = cr.fetchone()
45
+ row = row and row[0]
46
+ old_val = row and json.loads(row) or dict()
47
+ language = get_language()
48
+ new_val = getattr(model_instance, self.attname)
49
+ if new_val in [None, False, '']:
50
+ return {self.default_language: ''}
51
+ if isinstance(new_val, dict):
52
+ new_val = new_val.get(language, '')
53
+ old_val.update({language: new_val})
54
+ if language != self.default_language and not old_val.get(self.default_language):
55
+ old_val.update({self.default_language: new_val})
56
+ return old_val
57
+
58
+ def from_db_value(self, value, expression, connection):
59
+ value = super().from_db_value(value, expression, connection)
60
+ language = get_language()
61
+ if value is None:
62
+ return None
63
+ if not isinstance(value, dict):
64
+ value = dict()
65
+ char_val = value.get(language)
66
+ if not char_val:
67
+ char_val = value.get(self.default_language, None)
68
+ return char_val
69
+
70
+ def to_python(self, value):
71
+ if value is None:
72
+ return None
73
+ if isinstance(value, str):
74
+ return value
75
+ language = get_language()
76
+ char_value = ''
77
+ if isinstance(value, dict):
78
+ char_value = value.get(language)
79
+ if not char_value:
80
+ char_value = value.get(self.default_language, '')
81
+ return char_value
82
+
83
+ def formfield(self, form_class=None, choices_form_class=None, **kwargs):
84
+ defaults = {
85
+ "required": not self.blank,
86
+ "label": capfirst(self.verbose_name),
87
+ "help_text": self.help_text,
88
+ }
89
+ if self.has_default():
90
+ if callable(self.default):
91
+ defaults["initial"] = self.default
92
+ defaults["show_hidden_initial"] = True
93
+ else:
94
+ defaults["initial"] = self.get_default()
95
+ if self.choices is not None:
96
+ # Fields with choices get special treatment.
97
+ include_blank = self.blank or not (
98
+ self.has_default() or "initial" in kwargs
99
+ )
100
+ defaults["choices"] = self.get_choices(include_blank=include_blank)
101
+ defaults["coerce"] = self.to_python
102
+ if self.null:
103
+ defaults["empty_value"] = None
104
+ if choices_form_class is not None:
105
+ form_class = choices_form_class
106
+ else:
107
+ form_class = forms.TypedChoiceField
108
+ # Many of the subclass-specific formfield arguments (min_value,
109
+ # max_value) don't apply for choice fields, so be sure to only pass
110
+ # the values that TypedChoiceField will understand.
111
+ for k in list(kwargs):
112
+ if k not in (
113
+ "coerce",
114
+ "empty_value",
115
+ "choices",
116
+ "required",
117
+ "widget",
118
+ "label",
119
+ "initial",
120
+ "help_text",
121
+ "error_messages",
122
+ "show_hidden_initial",
123
+ "disabled",
124
+ ):
125
+ del kwargs[k]
126
+ defaults.update(kwargs)
127
+ if form_class is None:
128
+ form_class = forms.CharField
129
+ return form_class(**defaults)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: accrete
3
- Version: 0.0.122
3
+ Version: 0.0.123
4
4
  Summary: Django Shared Schema Multi Tenant
5
5
  Author-email: Benedikt Jilek <benedikt.jilek@pm.me>
6
6
  License: Copyright (c) 2023 Benedikt Jilek
@@ -2,6 +2,7 @@ accrete/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  accrete/admin.py,sha256=MUYUmCFlGYPowiXTbwl4_Q6Cq0-neiL53WW4P76JCLs,1174
3
3
  accrete/apps.py,sha256=F7ynMLHJr_6bRujWtZVUzCliY2CGKiDvyUmL4F68L2E,146
4
4
  accrete/config.py,sha256=eJUbvyBO3DvAD6xkVKjTAzlXy7V7EK9bVyb91girfUs,299
5
+ accrete/fields.py,sha256=9SlltB5AJvDfiAbYGWZemrqpjqDl1XNgNrhyTGoBJ2A,4693
5
6
  accrete/forms.py,sha256=H2hPQemslRLvTVV0Wl1TfUmTc5wU3Z98nQTMiLMliqo,1288
6
7
  accrete/managers.py,sha256=DevRVm7cStvlfz6TriitSINr40POCi4HNaHX48VkrMA,1620
7
8
  accrete/middleware.py,sha256=YN73WloNkN01oel9Dcj3xyhurcWoB6zMV0NT3hY8DGw,2264
@@ -12,6 +13,13 @@ accrete/tests.py,sha256=Agltbzwwh5htvq_Qi9vqvxutzmg_GwgPS_N19xJZRlw,7197
12
13
  accrete/urls.py,sha256=goDFR-yhOlLLy7AMi9pmh2aBkxdtZtwXNg6mwI2zPhU,227
13
14
  accrete/views.py,sha256=dwgXLkIjqjG16vlG4C6QeS191HoDnT7bZtkLahJB6wQ,2582
14
15
  accrete/contrib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ accrete/contrib/country/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ accrete/contrib/country/admin.py,sha256=0dAcFPfC8c80fhKKOL26-5Wl1uWXBYrkUJEjo2sEkk4,329
18
+ accrete/contrib/country/apps.py,sha256=95KSUCEezHIvXmxGXCST7Ag1xvpREHQGy2mIJWWx9R0,162
19
+ accrete/contrib/country/models.py,sha256=waflXa6oCVowzFQmhySQohzRmcjB10mv25EehCqDR-U,983
20
+ accrete/contrib/country/migrations/0001_initial.py,sha256=M-wKIa9gFtkZHatg-m-LRvrUrEZcKnenRtxLu7NMLbQ,1261
21
+ accrete/contrib/country/migrations/0002_auto_20250219_1759.py,sha256=hSP0WEErHHJWCYTYvJSI00JWzH1iEcobNLR_4n8Ygq8,24841
22
+ accrete/contrib/country/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
23
  accrete/contrib/log/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
24
  accrete/contrib/log/admin.py,sha256=xeuLk1GdU_M0rZR8SQUzcMeWvV9ud0hz_LJmaut5eJE,1211
17
25
  accrete/contrib/log/apps.py,sha256=O0Cje3MmpxPToJVgO195lBg0tRCy9Ou87-ntcdGBKM0,369
@@ -249,7 +257,7 @@ accrete/utils/forms.py,sha256=IvxbXNpSd4a-JBgsTJhs2GHe-DCRWX-xnVPRcoiCzbI,3104
249
257
  accrete/utils/log.py,sha256=BH0MBDweAjx30wGBO4F3sFhbgkSoEs7T1lLLjlYZNnA,407
250
258
  accrete/utils/models.py,sha256=2xTacvcpmDK_Bp4rAK7JdVLf8HU009LYNJ6eSpMgYZI,1014
251
259
  accrete/utils/views.py,sha256=AutijWetWGgjdO1PNc4gxCblT-i1fAfldNDFRbO9Sac,5012
252
- accrete-0.0.122.dist-info/METADATA,sha256=Cp7xgqCJtMHE3V1b8EgdUEcV-feC4XoiuIYwz48y_ec,4953
253
- accrete-0.0.122.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
254
- accrete-0.0.122.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
255
- accrete-0.0.122.dist-info/RECORD,,
260
+ accrete-0.0.123.dist-info/METADATA,sha256=wUGZk9TrXWGL3Hnzb4GofGgl-cM2DQ4g1leMMPOsQhM,4953
261
+ accrete-0.0.123.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
262
+ accrete-0.0.123.dist-info/licenses/LICENSE,sha256=_7laeMIHnsd3Y2vJEXDYXq_PEXxIcjgJsGt8UIKTRWc,1057
263
+ accrete-0.0.123.dist-info/RECORD,,