Skip to content

Commit

Permalink
Rename app to rest_routes
Browse files Browse the repository at this point in the history
  • Loading branch information
aybruhm committed Apr 1, 2022
1 parent c53614c commit 0c8dd60
Show file tree
Hide file tree
Showing 26 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
djangorest_auth
djangorest_routes
htmlcov
.vscode

Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include LICENSE
include README.md
recursive-include rest_auth/templates *
recursive-include rest_routes/templates *
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ Quick Start
pip install djangorest-routes
```

2. Add "djangorest_auth" to your INSTALLED_APPS setting like this:
2. Add "djangorest_routes" to your INSTALLED_APPS setting like this:
```
INSTALLED_APPS = [
...
'djangorest_routes',
'rest_routes',
]
```

2. Include the polls URLconf in your project urls.py like this:
```
path('rest_routes/', include('djangorest_routes.urls')),
path('rest_routes/', include('rest_routes.urls')),
```

4. Run ``python manage.py migrate`` to create the djangorest-auth-as-service models.
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Django's command-line utility for administrative tasks."""
import os
import sys
from djangorest_auth.config.base import RUNTIME_ENVIRON
from djangorest_routes.config.base import RUNTIME_ENVIRON


def main():
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion rest_auth/apps.py → rest_routes/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

class AuthConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "rest_auth"
name = "rest_routes"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.db import migrations, models
import hashid_field.field
import rest_auth.managers
import rest_routes.managers


class Migration(migrations.Migration):
Expand Down Expand Up @@ -89,7 +89,7 @@ class Migration(migrations.Migration):
"verbose_name_plural": "Users",
},
managers=[
("objects", rest_auth.managers.UserManager()),
("objects", rest_routes.managers.UserManager()),
],
),
]
File renamed without changes.
2 changes: 1 addition & 1 deletion rest_auth/models.py → rest_routes/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
from django.db import models
from hashid_field import HashidField
from rest_auth.managers import UserManager
from rest_routes.managers import UserManager


HASH_FIELD_SALT = "xj-mnplwwfxqg%3deo&worodl4h2$z5izs!(lxh*&bp%ch_"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from random import choices
from django.contrib.auth import get_user_model

from rest_auth.utils import send_html_to_email
from rest_routes.utils import send_html_to_email


User = get_user_model()
Expand Down
2 changes: 1 addition & 1 deletion rest_auth/serializers.py → rest_routes/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


"""Custom app -> Rest Auth Imports"""
from rest_auth.otp_verifications import OTPVerification
from rest_routes.otp_verifications import OTPVerification


"""Class Instantiations"""
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from unittest import mock
from rest_auth import managers, models
from rest_routes import managers, models
from rest_framework.test import APITestCase


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from rest_framework.test import APITestCase
from rest_auth.models import User
from rest_routes.models import User



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AuthOniichanTestCase(APITestCase):
"""

def test_konnichiwa(self):
response = self.client.get("http://127.0.0.1:8000/rest_auth/")
response = self.client.get("http://127.0.0.1:8000/rest_routes/")
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_user_register(self):
Expand All @@ -22,7 +22,7 @@ def test_user_register(self):
"phone_number": "08137281916",
"email": "abram@test.com",
}
response = self.client.post("http://127.0.0.1:8000/rest_auth/register/", data)
response = self.client.post("http://127.0.0.1:8000/rest_routes/register/", data)
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_register_bad_request(self):
Expand All @@ -32,37 +32,37 @@ def test_register_bad_request(self):
"phone_number": "08137281916",
"email": "abram@test.com",
}
response = self.client.post("http://127.0.0.1:8000/rest_auth/register/", data)
response = self.client.post("http://127.0.0.1:8000/rest_routes/register/", data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)


# def test_resend_oniichan_otp(self):
# data = {"email": "israelvictory87@gmail.com"}
# response = self.client.post("http://127.0.0.1:8000/rest_auth/resend_otp_code/", data=data)
# response = self.client.post("http://127.0.0.1:8000/rest_routes/resend_otp_code/", data=data)
# self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_resend_oniichan_otp_bad_request(self):
data = {"email": "abram@hello.com"}
response = self.client.post("http://127.0.0.1:8000/rest_auth/resend_otp_code/", data)
response = self.client.post("http://127.0.0.1:8000/rest_routes/resend_otp_code/", data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(response.data, {"status": "failed", "message": "Credentials does not match our record!"})

def test_confirm_otp_bad_request(self):
data = {"email": "abram@test.com", "otp_code": "453521"}
response = self.client.post("http://127.0.0.1:8000/rest_auth/confirm_otp/", data)
response = self.client.post("http://127.0.0.1:8000/rest_routes/confirm_otp/", data)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_logout(self):
response = self.client.post("http://127.0.0.1:8000/rest_auth/logout/")
response = self.client.post("http://127.0.0.1:8000/rest_routes/logout/")
self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)

def test_email_otp_verify_page(self):
response = self.client.get("http://127.0.0.1:8000/rest_auth/otp_verify/")
response = self.client.get("http://127.0.0.1:8000/rest_routes/otp_verify/")
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "emails/authentication/otp_verify.html")

def test_welcome_user_page(self):
response = self.client.get("http://127.0.0.1:8000/rest_auth/welcome/")
response = self.client.get("http://127.0.0.1:8000/rest_routes/welcome/")
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "emails/users/welcome.html")

Expand Down
2 changes: 1 addition & 1 deletion rest_auth/urls.py → rest_routes/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from rest_auth.views import (
from rest_routes.views import (
RegisterOniichan,
ConfirmOniichanOTP,
ResendOniichanOTP,
Expand Down
File renamed without changes.
34 changes: 17 additions & 17 deletions rest_auth/views.py → rest_routes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@


"""Custom app -> Rest Auth Imports"""
from rest_auth.utils import send_html_to_email
from rest_auth.serializers import (
from rest_routes.utils import send_html_to_email
from rest_routes.serializers import (
CompleteResetPasswordOTPSerializer,
RegisterUserSerializer,
ChangeUserPasswordSerializer,
Expand All @@ -27,7 +27,7 @@
UserSerializer,
UserLoginObtainPairSerializer,
)
from rest_auth.otp_verifications import OTPVerification
from rest_routes.otp_verifications import OTPVerification


"""Django Imports"""
Expand Down Expand Up @@ -55,22 +55,22 @@ def get(self, request: HttpRequest) -> Response:
welcome_data = {
"yosh!": "If you made it here, I'm proud of you!",
"routes": {
"register": BASE_URL + "rest_auth/register/",
"login (jwt)": BASE_URL + "rest_auth/login/token/",
"login (refresh jwt)": BASE_URL + "rest_auth/login/refresh/",
"confirm_otp": BASE_URL + "rest_auth/confirm_otp/",
"resend_otp_code": BASE_URL + "rest_auth/resend_otp_code/",
"logout": BASE_URL + "rest_auth/logout/",
"change_password": BASE_URL + "rest_auth/change_password/<str:email>/",
"reset_password (token)": BASE_URL + "rest_auth/password_reset/",
"register": BASE_URL + "rest_routes/register/",
"login (jwt)": BASE_URL + "rest_routes/login/token/",
"login (refresh jwt)": BASE_URL + "rest_routes/login/refresh/",
"confirm_otp": BASE_URL + "rest_routes/confirm_otp/",
"resend_otp_code": BASE_URL + "rest_routes/resend_otp_code/",
"logout": BASE_URL + "rest_routes/logout/",
"change_password": BASE_URL + "rest_routes/change_password/<str:email>/",
"reset_password (token)": BASE_URL + "rest_routes/password_reset/",
"reset_password_confirm (token)": BASE_URL
+ "rest_auth/password_reset/confirm/",
"reset_password_otp (otp)": BASE_URL + "rest_auth/password_reset_otp/",
+ "rest_routes/password_reset/confirm/",
"reset_password_otp (otp)": BASE_URL + "rest_routes/password_reset_otp/",
"reset_password_otp_confirm (otp)": BASE_URL
+ "rest_auth/password_reset_otp/confirm/",
+ "rest_routes/password_reset_otp/confirm/",
"reset_password_otp_complete (otp)": BASE_URL
+ "rest_auth/password_reset_otp/complete/",
"suspend_user": BASE_URL + "rest_auth/suspend_user/<str:email>/",
+ "rest_routes/password_reset_otp/complete/",
"suspend_user": BASE_URL + "rest_routes/suspend_user/<str:email>/",
},
}
return Response(data=welcome_data, status=status.HTTP_200_OK)
Expand Down Expand Up @@ -571,7 +571,7 @@ def password_reset_token_created(
"""

"Context to be applied on email"
token_redirect_url = "/rest_auth/password_reset/confirm/"
token_redirect_url = "/rest_routes/password_reset/confirm/"
token_key = reset_password_token.key

context = {
Expand Down

0 comments on commit 0c8dd60

Please sign in to comment.