Skip to content

Commit ab8fe08

Browse files
authored
Merge pull request #1 from stenwire/sten/add-cars-and-authme-apps
Sten/add cars and authme apps
2 parents e2ba517 + 3c7af87 commit ab8fe08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1686
-23
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
TREBLLE_PROJECT_ID='add project id without quote'
22
TREBLLE_API_KEY='add api key without quote'
3+
SECRET_KEY="add django secret key without quote"

Pipfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ name = "pypi"
77
django = "*"
88
treblle = "*"
99
python-decouple = "*"
10+
pyjwt = "*"
11+
black = "*"
12+
django-cors-headers = "==1.1.0"
13+
djangorestframework = "*"
14+
djoser = "*"
15+
pandas = "*"
16+
install = "*"
17+
djangorestframework-simplejwt = "*"
18+
isort = "*"
1019

1120
[dev-packages]
1221

Pipfile.lock

Lines changed: 378 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,34 @@ pipenv shell
2424
pipenv install
2525
```
2626
- Create a copy of `.env.example` and rename to `.env` then fill in the values
27-
>- find the treblle keys on the treblle dashboard
27+
>- find the treblle keys on the treblle dashboard
28+
29+
- Create admin user with:
30+
> whilst in project directory
31+
```shell
32+
python manage.py shell
33+
34+
>>> from auth.me import CustomUser
35+
36+
>>> CustomUser.objects.create_user(email="youremail@example.com",username="johnDoe707", password="strongpassword", is_staff=True, is_superuser=True)
37+
```
38+
39+
# Testing API
40+
41+
Postman Docs: [click here📬](https://documenter.getpostman.com/view/16596786/2s93zFXKTM)
42+
43+
Swagger Docs:
44+
45+
- use this to generate datetime object to fill into respective fields
46+
```python
47+
from datetime import datetime
48+
49+
t4 = datetime(year = 2018, month = 7, day = 12, hour = 7, minute = 9, second = 33)
50+
t5 = datetime(year = 2018, month = 7, day = 14, hour = 5, minute = 55, second = 13)
51+
t6 = t5 - t4
52+
53+
54+
print("t4 =", t4)
55+
print("t5 =", t5)
56+
print("t6 =", t6)
57+
```

authme/__init__.py

Whitespace-only changes.

authme/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

authme/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class AuthmeConfig(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "authme"

authme/backends.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from django.contrib.auth import get_user_model
2+
from django.contrib.auth.backends import ModelBackend
3+
4+
5+
class EmailBackend(ModelBackend):
6+
def authenticate(self, request, email=None, password=None, **kwargs):
7+
UserModel = get_user_model()
8+
try:
9+
user = UserModel.objects.get(email=email)
10+
except UserModel.DoesNotExist:
11+
return None
12+
else:
13+
if user.check_password(password):
14+
return user
15+
return None
16+
17+
def get_user(self, user_id):
18+
UserModel = get_user_model()
19+
try:
20+
return UserModel.objects.get(pk=user_id)
21+
except UserModel.DoesNotExist:
22+
return None

authme/migrations/0001_initial.py

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Generated by Django 4.2.3 on 2023-07-06 03:21
2+
3+
import uuid
4+
5+
import django.utils.timezone
6+
from django.db import migrations, models
7+
8+
9+
class Migration(migrations.Migration):
10+
initial = True
11+
12+
dependencies = [
13+
("auth", "0012_alter_user_first_name_max_length"),
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name="CustomUser",
19+
fields=[
20+
("password", models.CharField(max_length=128, verbose_name="password")),
21+
(
22+
"last_login",
23+
models.DateTimeField(
24+
blank=True, null=False, verbose_name="last login"
25+
),
26+
),
27+
(
28+
"is_superuser",
29+
models.BooleanField(
30+
default=False,
31+
help_text="Designates that this user has all permissions without explicitly assigning them.",
32+
verbose_name="superuser status",
33+
),
34+
),
35+
(
36+
"first_name",
37+
models.CharField(
38+
blank=True, max_length=150, verbose_name="first name"
39+
),
40+
),
41+
(
42+
"last_name",
43+
models.CharField(
44+
blank=True, max_length=150, verbose_name="last name"
45+
),
46+
),
47+
(
48+
"is_staff",
49+
models.BooleanField(
50+
default=False,
51+
help_text="Designates whether the user can log into this admin site.",
52+
verbose_name="staff status",
53+
),
54+
),
55+
(
56+
"is_active",
57+
models.BooleanField(
58+
default=True,
59+
help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
60+
verbose_name="active",
61+
),
62+
),
63+
(
64+
"date_joined",
65+
models.DateTimeField(
66+
default=django.utils.timezone.now, verbose_name="date joined"
67+
),
68+
),
69+
(
70+
"id",
71+
models.UUIDField(
72+
default=uuid.uuid4,
73+
primary_key=True,
74+
serialize=False,
75+
unique=True,
76+
),
77+
),
78+
("created", models.DateTimeField(auto_now_add=True)),
79+
("last_updated", models.DateTimeField(auto_now=True)),
80+
(
81+
"email",
82+
models.EmailField(
83+
max_length=254, unique=True, verbose_name="email address"
84+
),
85+
),
86+
(
87+
"username",
88+
models.CharField(
89+
max_length=150, unique=True, verbose_name="username"
90+
),
91+
),
92+
(
93+
"groups",
94+
models.ManyToManyField(
95+
blank=True,
96+
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
97+
related_name="user_set",
98+
related_query_name="user",
99+
to="auth.group",
100+
verbose_name="groups",
101+
),
102+
),
103+
(
104+
"user_permissions",
105+
models.ManyToManyField(
106+
blank=True,
107+
help_text="Specific permissions for this user.",
108+
related_name="user_set",
109+
related_query_name="user",
110+
to="auth.permission",
111+
verbose_name="user permissions",
112+
),
113+
),
114+
],
115+
options={
116+
"verbose_name": "user",
117+
"verbose_name_plural": "users",
118+
},
119+
),
120+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Generated by Django 4.2.3 on 2023-07-06 03:24
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("authme", "0001_initial"),
9+
]
10+
11+
operations = [
12+
migrations.AlterField(
13+
model_name="customuser",
14+
name="last_login",
15+
field=models.DateTimeField(
16+
blank=True, null=True, verbose_name="last login"
17+
),
18+
),
19+
]

0 commit comments

Comments
 (0)