Skip to content

Commit 9d0289b

Browse files
committed
feat: use a Custom User Model (#262)
1 parent bfed31f commit 9d0289b

36 files changed

+2177
-1755
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ Simply choose one of the three and delete the others. If you don't like any of t
106106
### ⌨️ to get started
107107

108108
1. ensure that you have [cookiecutter](https://github.com/audreyr/cookiecutter) installed on your computer
109-
2. run `cookiecutter https://github.com/engineervix/cookiecutter-wagtail-vix.git` in your favourite shell. You’ll be prompted for some values, such as **project_name**, , **project_slug**, **email**, **wagtail_username** etc. A new wagtail project will be created in a folder named according to the **project_slug** at your current location.
109+
2. run `cookiecutter https://github.com/engineervix/cookiecutter-wagtail-vix.git` in your favourite shell. You’ll be prompted for some values, such as **project_name**, , **project_slug**, **email**, **wagtail_user_email** etc. A new wagtail project will be created in a folder named according to the **project_slug** at your current location.
110110
3. create a virtual environment for your project. `cd` into the project folder created above and install python dependencies: First, install [pip-tools](https://github.com/jazzband/pip-tools): `pip install pip-tools`, then run `pip-compile requirements.in` followed by `pip install -r requirements.txt`.
111111
4. Now would be a good time to setup your postgres/postgis database and ensure that you update `DATABASE_URL` and the other environment variables in your `.env` files. The essential ones for starters are `RECAPTCHA_PUBLIC_KEY`, `RECAPTCHA_PRIVATE_KEY` and `MAPBOX_ACCESS_TOKEN`.
112112
5. `export ENV_PATH=.envs/.dev.env`
113113
6. `./manage.py migrate`
114-
7. `./manage.py createsuperuser`. When prompted for a username, please use the **wagtail_username** you specified in step 2. This is important to ensure that you don't have issues when populating the database with initial data, which is tied to the username provided in step 2.
114+
7. `./manage.py createsuperuser`. When prompted for an email address, please use the **wagtail_user_email** you specified in step 2. This is important to ensure that you don't have issues when populating the database with initial data, which is tied to the email address provided in step 2.
115115
8. `./manage.py load_initial_data`
116116
9. `yarn`
117117
10. `gulp cp`

cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"version": "0.1.0",
1010
"timezone": "Africa/Lusaka",
1111
"python_version": ["3.6", "3.7", "3.8", "3.9"],
12-
"wagtail_username": "user"
12+
"wagtail_user_email": "{{ cookiecutter.author_name.lower()|replace(' ', '-') }}@{{ cookiecutter.domain_name.lower()|replace(' ', '-') }}"
1313
}

hooks/post_gen_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def main():
148148
shutil.move(backups, os.path.join(PROJECT_DIRECTORY, ".backups/"))
149149

150150
print(
151-
"Please ensure that you use {{ cookiecutter.wagtail_username }} as your username when you run `./manage.py createsuperuser`"
151+
"Please ensure that you use {{ cookiecutter.wagtail_user_email }} as your email address when you run `./manage.py createsuperuser`"
152152
)
153153

154154

tests/test_cookiecutter_generation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def context():
2323
"domain_name": "example.com",
2424
"version": "0.0.1",
2525
"timezone": "Africa/Lusaka",
26-
"wagtail_username": "somebody",
26+
"wagtail_user_email": "somebody@example.com",
2727
}
2828

2929

{{cookiecutter.project_slug}}/config/settings/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
# Application definition
4040

4141
INSTALLED_APPS = [
42+
"{{cookiecutter.project_slug}}.users",
4243
"{{cookiecutter.project_slug}}.base",
4344
"{{cookiecutter.project_slug}}.home",
4445
"{{cookiecutter.project_slug}}.blog",
@@ -269,6 +270,8 @@
269270

270271
MESSAGE_STORAGE = "django.contrib.messages.storage.session.SessionStorage"
271272

273+
AUTH_USER_MODEL = "users.User"
274+
272275
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
273276

274277
# Omitting the 'default' editor now leaves the original default editor intact,

{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/base/fixtures/data.json

Lines changed: 1930 additions & 1664 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)