django-ctct 0.0.1.dev1__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.
- django_ctct-0.0.1.dev1/LICENSE +21 -0
- django_ctct-0.0.1.dev1/PKG-INFO +179 -0
- django_ctct-0.0.1.dev1/README.md +156 -0
- django_ctct-0.0.1.dev1/django_ctct/__init__.py +0 -0
- django_ctct-0.0.1.dev1/django_ctct/admin.py +566 -0
- django_ctct-0.0.1.dev1/django_ctct/apps.py +36 -0
- django_ctct-0.0.1.dev1/django_ctct/management/commands/import_ctct.py +211 -0
- django_ctct-0.0.1.dev1/django_ctct/managers.py +1148 -0
- django_ctct-0.0.1.dev1/django_ctct/models.py +996 -0
- django_ctct-0.0.1.dev1/django_ctct/signals.py +69 -0
- django_ctct-0.0.1.dev1/django_ctct/urls.py +8 -0
- django_ctct-0.0.1.dev1/django_ctct/utils.py +34 -0
- django_ctct-0.0.1.dev1/django_ctct/vendor.py +107 -0
- django_ctct-0.0.1.dev1/django_ctct/views.py +24 -0
- django_ctct-0.0.1.dev1/pyproject.toml +39 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Geoffrey B. Eisenbarth
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: django-ctct
|
|
3
|
+
Version: 0.0.1.dev1
|
|
4
|
+
Summary: A Django interface for the Constant Contact API
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: Geoffrey Eisenbarth
|
|
7
|
+
Author-email: geoffrey.eisenbarth@gmail.com
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Dist: django (>=3.2.0,<6.0.0)
|
|
17
|
+
Requires-Dist: pyjwt (>=2.10.1,<3.0.0)
|
|
18
|
+
Requires-Dist: ratelimit (>=2.2.1,<3.0.0)
|
|
19
|
+
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
20
|
+
Requires-Dist: tqdm (>=4.67.1,<5.0.0)
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# Constant Contact Integration for Django
|
|
24
|
+
|
|
25
|
+
[](https://codecov.io/gh/geoffrey-eisenbarth/django-ctct)
|
|
26
|
+
|
|
27
|
+
This Django app provides a seamless interface to the Constant Contact API, allowing you to manage contacts, email campaigns, and other Constant Contact functionalities directly from your Django project.
|
|
28
|
+
|
|
29
|
+
**Warning:** This package is under active development. While it is our intention to develop with a consistent API going forward, we will not make promises until a later version is released.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install django-ctct
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
1) **Add to `INSTALLED_APPS`:**
|
|
40
|
+
|
|
41
|
+
In your Django project's settings.py file, add `'django_ctct'` to the `'INSTALLED_APPS'`list (order doesn't matter):
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
INSTALLED_APPS = [
|
|
45
|
+
# ... django apps
|
|
46
|
+
'django_ctct',
|
|
47
|
+
# ... other apps
|
|
48
|
+
]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
2) **Include URLs:**
|
|
52
|
+
|
|
53
|
+
In your project's `urls.py` file, include the `django_ctct` URLs:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from django.contrib import admin
|
|
57
|
+
from django.urls import path, include
|
|
58
|
+
|
|
59
|
+
urlpatterns = [
|
|
60
|
+
path('admin/', admin.site.urls),
|
|
61
|
+
path('django-ctct/', include('django_ctct.urls')),
|
|
62
|
+
# ... other URL patterns
|
|
63
|
+
]
|
|
64
|
+
```
|
|
65
|
+
3) **ConstantContact API Credentials:**
|
|
66
|
+
|
|
67
|
+
Head to https://app.constantcontact.com/pages/dma/portal/ to set up your application with ConstantContact.
|
|
68
|
+
Pay particular attention to the "Redirect URI" field: it's crucial that this matches your Django project's server name (with `/django-ctct/auth/` at the end).
|
|
69
|
+
For example, if your Django project is hosted at `www.example.com` with SSL, then the value should be `https://www.example.com/django-ctct/auth/`.
|
|
70
|
+
If you're running Django's development server at `127.0.0.1:8000`, then you should set it to `http://127.0.0.1:8000/django-ctct/auth/`.
|
|
71
|
+
After that's finished, you'll need to configure your ConstantContact API credentials in `settings.py`:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
# Required settings
|
|
75
|
+
CTCT_PUBLIC_KEY = "YOUR_PUBLIC_KEY"
|
|
76
|
+
CTCT_SECRET_KEY = "YOUR_SECRET_KEY"
|
|
77
|
+
CTCT_REDIRECT_URI = "REDIRECT_URI_FROM_CTCT"
|
|
78
|
+
CTCT_FROM_NAME = "YOUR_EMAIL_NAME"
|
|
79
|
+
CTCT_FROM_EMAIL = "YOUR_EMAIL_ADDRESS"
|
|
80
|
+
|
|
81
|
+
# Optional settings
|
|
82
|
+
CTCT_REPLY_TO_EMAIL = "YOUR_REPLY_TO_ADDRESS"
|
|
83
|
+
CTCT_PHYSICAL_ADDRESS = {
|
|
84
|
+
'address_line1': '1060 W Addison St',
|
|
85
|
+
'address_line2': '',
|
|
86
|
+
'address_optional': '',
|
|
87
|
+
'city': 'Chicago',
|
|
88
|
+
'country_code': 'US',
|
|
89
|
+
'country_name': 'United States',
|
|
90
|
+
'organization_name': 'Wrigley Field',
|
|
91
|
+
'postal_code': '60613',
|
|
92
|
+
'state_code': 'IL',
|
|
93
|
+
}
|
|
94
|
+
CTCT_PREVIEW_RECIPIENTS = (
|
|
95
|
+
('First Recipient', 'first@recipient.com'),
|
|
96
|
+
('Second Recipient', 'second@recipient.com'),
|
|
97
|
+
)
|
|
98
|
+
CTCT_PREVIEW_MESSAGE = "This is an EmailCampaign preview."
|
|
99
|
+
|
|
100
|
+
# Optional functionality settings and their default settings
|
|
101
|
+
CTCT_USE_ADMIN = False # Add django-ctct models to admin
|
|
102
|
+
CTCT_SYNC_ADMIN = False # Django admin CRUD operations will sync with ctct account
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Important:** Store your API credentials securely. Avoid committing them directly to your version control repository.
|
|
106
|
+
|
|
107
|
+
* `CTCT_FROM_EMAIL` must be a verified email address for your ConstantContact.com account.
|
|
108
|
+
* `CTCT_REPLY_TO_EMAIL` will default to `CTCT_FROM_EMAIL` if not set.
|
|
109
|
+
* `CTCT_PHYSICAL_ADDRESS` will default to the information set in your ConstantContact.com account if not set.
|
|
110
|
+
* `CTCT_PREVIEW_RECIPIENTS` will default to `settings.MANAGERS` if not set.
|
|
111
|
+
* `CTCT_PREVIEW_MESSAGE` will be blank by default.
|
|
112
|
+
|
|
113
|
+
3) **Run Migrations:**
|
|
114
|
+
```bash
|
|
115
|
+
> ./manage.py makemigrations
|
|
116
|
+
> ./manage.py migrate
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
4) **Create Authenticatin Token:**
|
|
120
|
+
|
|
121
|
+
After the app has been installed and configured, you must generate your first auth token:
|
|
122
|
+
* Open up the `CTCT_REDIRECT_URI` address in your browser
|
|
123
|
+
* Use your ConstantContact credentials to log in
|
|
124
|
+
* From this point forward `django-ctct` should use refresh tokens, so no need to manually log in again
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
## Usage
|
|
128
|
+
If you wish to import data from ConstantContact.com into your local database (recommended), then run the following:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
> ./manage.py import_ctct
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
You will be asked before each model type is imported. **Note** ConstantContact does not provide a bulk API endpoint for fetching Campaign Activities, so depending on the size of your account, this might take some time and possible put you over their 10,000 request per day limit if you run it regularly.
|
|
135
|
+
|
|
136
|
+
Since ConstantContact does not offer any webhooks, you will need to set up a cron job if you want your account to remain syncronized with ConstantContact's database. You can use the `--no-input` flag to bypass the interactive questions. The `--stats-only` flag is useful for running a cron job to keep EmailCampaign statistics updated.
|
|
137
|
+
|
|
138
|
+
If you wish to use the Django admin to interact with ConstantContact, you must explicitly set the `CTCT_USE_ADMIN` and `CTCT_SYNC_ADMIN` settings to `True`.
|
|
139
|
+
|
|
140
|
+
## Testing
|
|
141
|
+
|
|
142
|
+
To install dev dependencies:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
> git clone git@github.com:geoffrey-eisenbarth/django-ctct.git
|
|
146
|
+
> cd django-ctct
|
|
147
|
+
> python -m pip install --upgrade pip
|
|
148
|
+
> pip intall poetry
|
|
149
|
+
> poetry install --with dev
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
To run tests:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
> poetry run coverage run tests/project/manage.py test
|
|
156
|
+
> poetry run coverage report
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Contributing
|
|
160
|
+
|
|
161
|
+
Once version 0.0.1 is released on PyPI, we hope to implement the following new features (in no particular order):
|
|
162
|
+
|
|
163
|
+
* Support for API syncing using signals (`post_save`, `pre_delete`, `m2m_changed`, etc). This will be controlled by the `CTCT_SYNC_SIGNALS` setting. **Update** This probably won't work as desired since the primary object will be saved before related objects are.
|
|
164
|
+
* Background task support using `django-tasks` (which hopefully will merge into Django). This will be controlled by the `CTCT_ENQUEUE_DEFAULT` setting.
|
|
165
|
+
* Add `models.CheckConstraint` and `models.UniqueConstraint` constraints that are currently commented out.
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
I'm always open to new suggestions, so please reach out on GitHub: https://github.com/geoffrey-eisenbarth/django-ctct/
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
This package is currently distributed under the MIT license.
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
## Support
|
|
177
|
+
|
|
178
|
+
If you have any issues or questions, please feel free to reach out to me on GitHub: https://github.com/geoffrey-eisenbarth/django-ctct/issues
|
|
179
|
+
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Constant Contact Integration for Django
|
|
2
|
+
|
|
3
|
+
[](https://codecov.io/gh/geoffrey-eisenbarth/django-ctct)
|
|
4
|
+
|
|
5
|
+
This Django app provides a seamless interface to the Constant Contact API, allowing you to manage contacts, email campaigns, and other Constant Contact functionalities directly from your Django project.
|
|
6
|
+
|
|
7
|
+
**Warning:** This package is under active development. While it is our intention to develop with a consistent API going forward, we will not make promises until a later version is released.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install django-ctct
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Configuration
|
|
16
|
+
|
|
17
|
+
1) **Add to `INSTALLED_APPS`:**
|
|
18
|
+
|
|
19
|
+
In your Django project's settings.py file, add `'django_ctct'` to the `'INSTALLED_APPS'`list (order doesn't matter):
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
INSTALLED_APPS = [
|
|
23
|
+
# ... django apps
|
|
24
|
+
'django_ctct',
|
|
25
|
+
# ... other apps
|
|
26
|
+
]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2) **Include URLs:**
|
|
30
|
+
|
|
31
|
+
In your project's `urls.py` file, include the `django_ctct` URLs:
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from django.contrib import admin
|
|
35
|
+
from django.urls import path, include
|
|
36
|
+
|
|
37
|
+
urlpatterns = [
|
|
38
|
+
path('admin/', admin.site.urls),
|
|
39
|
+
path('django-ctct/', include('django_ctct.urls')),
|
|
40
|
+
# ... other URL patterns
|
|
41
|
+
]
|
|
42
|
+
```
|
|
43
|
+
3) **ConstantContact API Credentials:**
|
|
44
|
+
|
|
45
|
+
Head to https://app.constantcontact.com/pages/dma/portal/ to set up your application with ConstantContact.
|
|
46
|
+
Pay particular attention to the "Redirect URI" field: it's crucial that this matches your Django project's server name (with `/django-ctct/auth/` at the end).
|
|
47
|
+
For example, if your Django project is hosted at `www.example.com` with SSL, then the value should be `https://www.example.com/django-ctct/auth/`.
|
|
48
|
+
If you're running Django's development server at `127.0.0.1:8000`, then you should set it to `http://127.0.0.1:8000/django-ctct/auth/`.
|
|
49
|
+
After that's finished, you'll need to configure your ConstantContact API credentials in `settings.py`:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
# Required settings
|
|
53
|
+
CTCT_PUBLIC_KEY = "YOUR_PUBLIC_KEY"
|
|
54
|
+
CTCT_SECRET_KEY = "YOUR_SECRET_KEY"
|
|
55
|
+
CTCT_REDIRECT_URI = "REDIRECT_URI_FROM_CTCT"
|
|
56
|
+
CTCT_FROM_NAME = "YOUR_EMAIL_NAME"
|
|
57
|
+
CTCT_FROM_EMAIL = "YOUR_EMAIL_ADDRESS"
|
|
58
|
+
|
|
59
|
+
# Optional settings
|
|
60
|
+
CTCT_REPLY_TO_EMAIL = "YOUR_REPLY_TO_ADDRESS"
|
|
61
|
+
CTCT_PHYSICAL_ADDRESS = {
|
|
62
|
+
'address_line1': '1060 W Addison St',
|
|
63
|
+
'address_line2': '',
|
|
64
|
+
'address_optional': '',
|
|
65
|
+
'city': 'Chicago',
|
|
66
|
+
'country_code': 'US',
|
|
67
|
+
'country_name': 'United States',
|
|
68
|
+
'organization_name': 'Wrigley Field',
|
|
69
|
+
'postal_code': '60613',
|
|
70
|
+
'state_code': 'IL',
|
|
71
|
+
}
|
|
72
|
+
CTCT_PREVIEW_RECIPIENTS = (
|
|
73
|
+
('First Recipient', 'first@recipient.com'),
|
|
74
|
+
('Second Recipient', 'second@recipient.com'),
|
|
75
|
+
)
|
|
76
|
+
CTCT_PREVIEW_MESSAGE = "This is an EmailCampaign preview."
|
|
77
|
+
|
|
78
|
+
# Optional functionality settings and their default settings
|
|
79
|
+
CTCT_USE_ADMIN = False # Add django-ctct models to admin
|
|
80
|
+
CTCT_SYNC_ADMIN = False # Django admin CRUD operations will sync with ctct account
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Important:** Store your API credentials securely. Avoid committing them directly to your version control repository.
|
|
84
|
+
|
|
85
|
+
* `CTCT_FROM_EMAIL` must be a verified email address for your ConstantContact.com account.
|
|
86
|
+
* `CTCT_REPLY_TO_EMAIL` will default to `CTCT_FROM_EMAIL` if not set.
|
|
87
|
+
* `CTCT_PHYSICAL_ADDRESS` will default to the information set in your ConstantContact.com account if not set.
|
|
88
|
+
* `CTCT_PREVIEW_RECIPIENTS` will default to `settings.MANAGERS` if not set.
|
|
89
|
+
* `CTCT_PREVIEW_MESSAGE` will be blank by default.
|
|
90
|
+
|
|
91
|
+
3) **Run Migrations:**
|
|
92
|
+
```bash
|
|
93
|
+
> ./manage.py makemigrations
|
|
94
|
+
> ./manage.py migrate
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
4) **Create Authenticatin Token:**
|
|
98
|
+
|
|
99
|
+
After the app has been installed and configured, you must generate your first auth token:
|
|
100
|
+
* Open up the `CTCT_REDIRECT_URI` address in your browser
|
|
101
|
+
* Use your ConstantContact credentials to log in
|
|
102
|
+
* From this point forward `django-ctct` should use refresh tokens, so no need to manually log in again
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
## Usage
|
|
106
|
+
If you wish to import data from ConstantContact.com into your local database (recommended), then run the following:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
> ./manage.py import_ctct
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
You will be asked before each model type is imported. **Note** ConstantContact does not provide a bulk API endpoint for fetching Campaign Activities, so depending on the size of your account, this might take some time and possible put you over their 10,000 request per day limit if you run it regularly.
|
|
113
|
+
|
|
114
|
+
Since ConstantContact does not offer any webhooks, you will need to set up a cron job if you want your account to remain syncronized with ConstantContact's database. You can use the `--no-input` flag to bypass the interactive questions. The `--stats-only` flag is useful for running a cron job to keep EmailCampaign statistics updated.
|
|
115
|
+
|
|
116
|
+
If you wish to use the Django admin to interact with ConstantContact, you must explicitly set the `CTCT_USE_ADMIN` and `CTCT_SYNC_ADMIN` settings to `True`.
|
|
117
|
+
|
|
118
|
+
## Testing
|
|
119
|
+
|
|
120
|
+
To install dev dependencies:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
> git clone git@github.com:geoffrey-eisenbarth/django-ctct.git
|
|
124
|
+
> cd django-ctct
|
|
125
|
+
> python -m pip install --upgrade pip
|
|
126
|
+
> pip intall poetry
|
|
127
|
+
> poetry install --with dev
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
To run tests:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
> poetry run coverage run tests/project/manage.py test
|
|
134
|
+
> poetry run coverage report
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Contributing
|
|
138
|
+
|
|
139
|
+
Once version 0.0.1 is released on PyPI, we hope to implement the following new features (in no particular order):
|
|
140
|
+
|
|
141
|
+
* Support for API syncing using signals (`post_save`, `pre_delete`, `m2m_changed`, etc). This will be controlled by the `CTCT_SYNC_SIGNALS` setting. **Update** This probably won't work as desired since the primary object will be saved before related objects are.
|
|
142
|
+
* Background task support using `django-tasks` (which hopefully will merge into Django). This will be controlled by the `CTCT_ENQUEUE_DEFAULT` setting.
|
|
143
|
+
* Add `models.CheckConstraint` and `models.UniqueConstraint` constraints that are currently commented out.
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
I'm always open to new suggestions, so please reach out on GitHub: https://github.com/geoffrey-eisenbarth/django-ctct/
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
This package is currently distributed under the MIT license.
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
## Support
|
|
155
|
+
|
|
156
|
+
If you have any issues or questions, please feel free to reach out to me on GitHub: https://github.com/geoffrey-eisenbarth/django-ctct/issues
|
|
File without changes
|