Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appointment service be completed with define tasks #30

Open
wants to merge 128 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
2537a6a
set Location Api with post method
pooriyaadibrad Aug 30, 2024
ea194b8
added get method to location api
pooriyaadibrad Aug 30, 2024
681b300
added loactions path to url.py
pooriyaadibrad Aug 30, 2024
846cca4
changed the name of class Location that wtitten in views.py
pooriyaadibrad Aug 30, 2024
821c9b2
medicine views.py be updated
pooriyaadibrad Aug 30, 2024
f89f44f
Location permission be chageed
pooriyaadibrad Aug 30, 2024
5ff250b
intraction app be created
pooriyaadibrad Aug 30, 2024
a5e2bf1
intraction urls be placed next to the other urls
pooriyaadibrad Aug 30, 2024
64dec38
intraction Comment model be set
pooriyaadibrad Aug 30, 2024
d74f480
intraction set suggest model in python comment
pooriyaadibrad Aug 30, 2024
bbb9d07
intraction serilizers with Comment serilizer be set
pooriyaadibrad Aug 30, 2024
ea5232a
intraction Comment model be updated
pooriyaadibrad Aug 30, 2024
26362f0
ProviderDetails class Api in views.py be set
pooriyaadibrad Aug 30, 2024
0169f9e
ProviderDetails Api urls be set
pooriyaadibrad Aug 30, 2024
6694542
ProviderDetails Comment Problem be fixed
pooriyaadibrad Aug 30, 2024
d43de59
Interactions views.py be set with Post Comment api
pooriyaadibrad Aug 30, 2024
5151139
in Interactions urls.py created post Comment path
pooriyaadibrad Aug 30, 2024
898d370
Interactions views.py Comment be updated
pooriyaadibrad Aug 30, 2024
17f813b
Comment model be updated
pooriyaadibrad Aug 30, 2024
45a598e
medicine admin.py be updated
pooriyaadibrad Aug 30, 2024
76ca065
Comment be added to medicine admin.py provider subset
pooriyaadibrad Aug 30, 2024
421dc3d
Comment models be updated
pooriyaadibrad Aug 30, 2024
8b4f80f
added migrations to git hosting
pooriyaadibrad Aug 30, 2024
7ba1a18
Provider model be update
pooriyaadibrad Aug 30, 2024
210eb21
Provider search api be completed
pooriyaadibrad Aug 30, 2024
09ac216
config spectacular documant builder
pooriyaadibrad Sep 1, 2024
686f5be
added api shema to shema.yml
pooriyaadibrad Sep 1, 2024
227130f
integrate provider search api with Provider api
pooriyaadibrad Sep 2, 2024
976f18b
the medicine view be updated
pooriyaadibrad Sep 2, 2024
5db8bf8
added goolge authentication config to setting
pooriyaadibrad Sep 2, 2024
a5fad7d
setting.py be updated
pooriyaadibrad Sep 2, 2024
46901c7
medicine.url be updated
pooriyaadibrad Sep 2, 2024
ee8b530
schema file be added
pooriyaadibrad Sep 2, 2024
a7af648
added google authenticate url
pooriyaadibrad Sep 2, 2024
4d7db69
setting.py google auth config be update
pooriyaadibrad Sep 3, 2024
438d73a
google authenticate url be set
pooriyaadibrad Sep 3, 2024
f3bfb0d
google auth api be set
pooriyaadibrad Sep 3, 2024
f033ec9
url used in front be ser in googleUrlForFront file
pooriyaadibrad Sep 3, 2024
c390c00
account view be updated
pooriyaadibrad Sep 3, 2024
c52638e
the requirements.txt be updated
pooriyaadibrad Sep 3, 2024
eda1208
Revert "url used in front be set in googleUrlForFront file"
pooriyaadibrad Sep 3, 2024
639562e
set django caches in setting config
pooriyaadibrad Sep 3, 2024
540a80c
utils for sms service be created
pooriyaadibrad Sep 3, 2024
52dab81
sms url be created
pooriyaadibrad Sep 3, 2024
bb336f4
sms authenticate code builder api be created
pooriyaadibrad Sep 3, 2024
442d2fd
sms verification api be created
pooriyaadibrad Sep 3, 2024
11838f5
google authenticate be changed with added jwt access token
pooriyaadibrad Sep 3, 2024
7531e3a
google authenticate error be fixed
pooriyaadibrad Sep 3, 2024
c62ed7c
change shape of google api code style
pooriyaadibrad Sep 3, 2024
e69f40d
account url be updated
pooriyaadibrad Sep 3, 2024
3083d35
google request url be documented for front in googleAPiForFront file
pooriyaadibrad Sep 3, 2024
f4530fb
added guide comment to login auth api
pooriyaadibrad Sep 3, 2024
b74d0c8
added error handler to google auth api
pooriyaadibrad Sep 4, 2024
840d9d0
google auth api be updated
pooriyaadibrad Sep 4, 2024
93d12fc
verify sms auth api be updated
pooriyaadibrad Sep 4, 2024
7b866a7
added Sms Seriailizer
pooriyaadibrad Sep 4, 2024
74c2d1c
verify auth sms api be updated
pooriyaadibrad Sep 4, 2024
49d2ecf
auth sms api be updated
pooriyaadibrad Sep 4, 2024
7cd7bad
schema docs api be updated
pooriyaadibrad Sep 4, 2024
8bc8275
GTPR conditions be effect in auth api
pooriyaadibrad Sep 4, 2024
811c76a
google auth init api be set
pooriyaadibrad Sep 4, 2024
5f4700f
added google init auth url
pooriyaadibrad Sep 4, 2024
19140fe
google auth api be updated
pooriyaadibrad Sep 4, 2024
5598d7c
fixed error make GTPR idea
pooriyaadibrad Sep 4, 2024
f1a4817
schema file be updated
pooriyaadibrad Sep 4, 2024
0057b20
added comment for other Distributor in code
pooriyaadibrad Sep 4, 2024
9bd117f
updated url account api
pooriyaadibrad Sep 4, 2024
b7249f9
added guide comment to code
pooriyaadibrad Sep 4, 2024
61ef1bc
appointment serializers file be created
pooriyaadibrad Sep 4, 2024
79b7b55
Service Serializer be created
pooriyaadibrad Sep 4, 2024
93efede
Service api be created
pooriyaadibrad Sep 4, 2024
e52faac
added Service url
pooriyaadibrad Sep 4, 2024
cf26c19
added access level to Service api
pooriyaadibrad Sep 4, 2024
0eca737
Service api be updated with added guide comment
pooriyaadibrad Sep 4, 2024
35e5dc1
access level be updated in Location api
pooriyaadibrad Sep 4, 2024
9cf47a8
appointment serializer be write
pooriyaadibrad Sep 4, 2024
3657d27
appointment api be creared
pooriyaadibrad Sep 4, 2024
e4c3067
appointment details api be created
pooriyaadibrad Sep 4, 2024
67ede6a
added guide comment to api
pooriyaadibrad Sep 4, 2024
8048880
added to schema docs appointment all api
pooriyaadibrad Sep 4, 2024
b366d6c
schema.yml be updated
pooriyaadibrad Sep 4, 2024
2639d2a
setting pagination config be changed
pooriyaadibrad Sep 4, 2024
564fe87
base Provdier pagination be created
pooriyaadibrad Sep 5, 2024
daf0a8f
change medicine app pagination to limitoffset
pooriyaadibrad Sep 5, 2024
8ee34eb
added pagintaion to provider details api
pooriyaadibrad Sep 5, 2024
e287ad4
Provider access level writing be cleaned
pooriyaadibrad Sep 5, 2024
1bf137b
appointment pagintion be created
pooriyaadibrad Sep 5, 2024
6c55839
appointment pagination be set
pooriyaadibrad Sep 5, 2024
2e15c00
requirement.txt be updated
pooriyaadibrad Sep 5, 2024
61e394f
i used .env for enviroment varibale
pooriyaadibrad Sep 5, 2024
e3ca78f
environment varibale be set in setting
pooriyaadibrad Sep 5, 2024
b42b62e
infrastructure of test be created in interaction app
pooriyaadibrad Sep 5, 2024
04d295f
url test case be completed
pooriyaadibrad Sep 5, 2024
8373952
the comment serializer issue be fixed
pooriyaadibrad Sep 5, 2024
1a26ba8
added test database config
pooriyaadibrad Sep 6, 2024
675bff0
interaction views test be completed
pooriyaadibrad Sep 6, 2024
320ead9
appointment serilizer issue be fixed
pooriyaadibrad Sep 6, 2024
2a908d8
added comment to appointment serializer
pooriyaadibrad Sep 6, 2024
77d8bd8
delete appointment test.py
pooriyaadibrad Sep 6, 2024
b1b59ea
added comment to test_models for guide
pooriyaadibrad Sep 6, 2024
ebcd349
infrastructure of appointment test diractory
pooriyaadibrad Sep 6, 2024
2ea28a5
appointment url be set
pooriyaadibrad Sep 6, 2024
d30ed92
addde init file to appointment test
pooriyaadibrad Sep 6, 2024
bf1a1bf
appointment url test be completed
pooriyaadibrad Sep 6, 2024
f011ed3
fixed delete and put issue
pooriyaadibrad Sep 6, 2024
30d6065
appointment test_views be completed
pooriyaadibrad Sep 6, 2024
5fd9fb0
infrastructur of medicine test be completed
pooriyaadibrad Sep 6, 2024
08d7974
model test in medicene guide be completed
pooriyaadibrad Sep 6, 2024
dc774d6
fixed __init__ medicine test problem
pooriyaadibrad Sep 6, 2024
03e420f
the medicine url be updated
pooriyaadibrad Sep 6, 2024
f50b9d2
the medicine test url be completed
pooriyaadibrad Sep 6, 2024
0267779
fixed provier search issue
pooriyaadibrad Sep 6, 2024
24f560f
set provider test case
pooriyaadibrad Sep 6, 2024
66d79f8
set speciality test case
pooriyaadibrad Sep 6, 2024
4bb9aeb
set location test case
pooriyaadibrad Sep 6, 2024
75189b2
set Service test case
pooriyaadibrad Sep 6, 2024
bd6ce70
infrastructure of account test be set
pooriyaadibrad Sep 6, 2024
12d1cd2
account url be updated
pooriyaadibrad Sep 6, 2024
5aec15c
account utl test be completed
pooriyaadibrad Sep 6, 2024
224add6
added logout api to account views
pooriyaadibrad Sep 6, 2024
88f1a4b
logout url be set
pooriyaadibrad Sep 6, 2024
637e55c
logout test url be set
pooriyaadibrad Sep 6, 2024
841ffec
account model test be created
pooriyaadibrad Sep 6, 2024
08ba60b
fixed views issue
pooriyaadibrad Sep 6, 2024
7addb09
fixed account test views
pooriyaadibrad Sep 6, 2024
d0b2b90
set comment guide in test views
pooriyaadibrad Sep 6, 2024
61ae2db
set comment guide in test urls
pooriyaadibrad Sep 6, 2024
082281f
v1 of this projcet be complite
pooriyaadibrad Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions .idea/bootcamp_appointment.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions digital_appointment/accounts/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,7 @@ def update(self, instance, validated_data):
return super().update(instance, validated_data)


class SmsSerializer(serializers.Serializer):
mobile = serializers.CharField(max_length=11)
code = serializers.CharField(max_length=6, required=False)

3 changes: 0 additions & 3 deletions digital_appointment/accounts/tests.py

This file was deleted.

Empty file.
37 changes: 37 additions & 0 deletions digital_appointment/accounts/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from django.test import TestCase
from accounts.models import User
import datetime


class UserModelTest(TestCase):
"""model test for test creation and method of this object
if this override or writing in first time"""

"""base setup ot test"""
def setUp(self):
self.user = User.objects.create(
email='[email protected]',
password='<PASSWOd123@>',
username='test',
phone_number='1234567890',
birth_data=datetime.datetime.now(),
first_name='Test',
last_name='User',
)
"""test creation"""
def test_user_creation(self):
self.assertEqual(self.user.email, '[email protected]')
self.assertEqual(self.user.username, 'test')
self.assertEqual(self.user.phone_number, '1234567890')
"""password test"""
def test_user_password_setter(self):
self.assertFalse(self.user.set_password('<PASSWORD>'), '<PASSWOd123@>')
"""perm test"""
def test_has_perm(self):
self.assertTrue(not self.user.has_perm('accounts.change_email'))
"""module permission test"""
def test_has_module_perm(self):
self.assertTrue(self.user.has_module_perms('accounts'))
"""get full name test"""
def test_get_full_name(self):
self.assertEqual(self.user.get_full_name(), f'{self.user.first_name} {self.user.last_name}')
51 changes: 51 additions & 0 deletions digital_appointment/accounts/tests/test_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from django.test import SimpleTestCase
from django.urls import reverse, resolve
from accounts import views
from rest_framework_simplejwt.views import TokenRefreshView

class AccountsTestCase(SimpleTestCase):
def test_login_url(self):
url = reverse('token_obtain_pair')
self.assertEqual(url, '/api/accounts/login/')
self.assertEqual(resolve(url).func.view_class, views.CustomTokenObtainPairView)

def test_login_refresh_url(self):
url = reverse('token_refresh')
self.assertEqual(url, '/api/accounts/login/refresh/')
self.assertEqual(resolve(url).func.view_class, TokenRefreshView)

def test_logout_url(self):
url = reverse('logout')
self.assertEqual(url, '/api/accounts/logout/')
self.assertEqual(resolve(url).func.view_class, views.LogOutViewWithToken)

def test_user_url(self):
url = reverse('user')
self.assertEqual(url, '/api/accounts/user/')
self.assertEqual(resolve(url).func.view_class, views.User)

def test_user_detail_url(self):
url = reverse('user_detail',args=[1])
self.assertEqual(url, '/api/accounts/user/1/')
self.assertEqual(resolve(url).func.view_class, views.UserDetail)

def test_auth_google_url(self):
url = reverse('google_auth')
self.assertEqual(url, '/api/accounts/auth/google/start/')
self.assertEqual(resolve(url).func.view_class, views.GoogleAuthInit)

def test_auth_google_callback_url(self):
url = reverse('google_callback')
self.assertEqual(url, '/api/accounts/auth/google/callback/')
self.assertEqual(resolve(url).func.view_class, views.GoogleCallback)

def test_auth_sms_url(self):
url = reverse('sms')
self.assertEqual(url, '/api/accounts/auth/sms/')
self.assertEqual(resolve(url).func.view_class, views.SmsAuthentication)
def test_auth_sms_verify_url(self):
url = reverse('sms-verify')
self.assertEqual(url, '/api/accounts/auth/sms/verify/')
self.assertEqual(resolve(url).func.view_class, views.VerifyCodeSmsAuthentication)


109 changes: 109 additions & 0 deletions digital_appointment/accounts/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
from rest_framework.test import APITestCase
from rest_framework import status
from rest_framework_simplejwt.tokens import RefreshToken
from django.urls import reverse
from accounts.models import User
import datetime

class GoogleAuthTests(APITestCase):

def test_google_auth_init(self):
url = reverse('google_auth') # Use the related name you set in your url patterns
response = self.client.post(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIn('http', response.data) # Check if the returned data contains a URL

def test_google_callback_success(self):
# Assume we already set a valid `code` value or mock the request to simulate it
url = reverse('google_callback') # Use the related name you set in your url patterns
data = {
'code': 'VALID_AUTH_CODE'
}
response = self.client.get(url, data=data, format='json')
self.assertIn(response.status_code, [status.HTTP_200_OK, status.HTTP_400_BAD_REQUEST])


def test_google_callback_no_code(self):
url = reverse('google_callback')
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertIn('error', response.data)
"""
we need better service for write this service

class SmsAuthTests(APITestCase):

def test_sms_authentication(self):
url = reverse('sms') # Update as per your URL configuration
data = {
'mobile': '1234567890',
}
response = self.client.post(url, data, format='json')
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIn('message', response.data)

def test_verify_code_sms_authentication(self):
url = reverse('sms-verify') # Update as per your URL configuration
data = {
'code': 'VALID_CODE',
'mobile': '1234567890',
}
response = self.client.post(url, data)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertIn('tokens', response.data)
"""
class UserTests(APITestCase):

def setUp(self):
self.user = User.objects.create(
username='testuser',
email='[email protected]',
password='testpass123'
)
"""authentication access for test"""
self.token = self.generate_jwt_token(self.user)

self.client.credentials(HTTP_AUTHORIZATION=f'Bearer {self.token}')

def generate_jwt_token(self, user):
"""Generate a JWT token for the given user."""
return RefreshToken.for_user(user).access_token

def test_user_creation(self):
url = reverse('user') # Update as per your URL configuration
data = {
'username': 'updatedusername',
'email': '[email protected]',
'password': '<PASSWORd132@',
'first_name': 'updatedfirst_name',
'last_name': 'updatedlast_name',
'phone_number': '1324567895',
'birth_data': datetime.datetime.now(),
}
response = self.client.post(url, data, format='json', HTTP_AUTHORIZATION=f'Bearer {self.token}')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)

def test_user_detail(self):
url = reverse('user_detail', args=[self.user.id]) # Update as per your URL configuration
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['username'], self.user.username)

def test_user_update(self):
url = reverse('user_detail', args=[self.user.id]) # Update as per your URL configuration
data = {
'username': 'updatedusername',
'email': '[email protected]',
'password': '<PASSWORd132@',
'first_name': 'updatedfirst_name',
'last_name': 'updatedlast_name',
'phone_number': '1324567895',
'birth_data': datetime.datetime.now(),
}
response = self.client.put(url, data, format='json', HTTP_AUTHORIZATION=f'Bearer {self.token}')
self.assertEqual(response.status_code, status.HTTP_200_OK)

def test_user_delete(self):
url = reverse('user_detail', args=[self.user.id]) # Update as per your URL configuration
response = self.client.delete(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
17 changes: 11 additions & 6 deletions digital_appointment/accounts/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from . import views
from django.urls import path
from django.urls import path, include
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView

urlpatterns = [
path("login/", views.CustomTokenObtainPairView.as_view()),
path("login/refresh/", TokenRefreshView.as_view()),
path("user/", views.User.as_view()),
path("user/<int:pk>/", views.UserDetail.as_view()),
path("profile/", views.ProfileView.as_view())
path("login/", views.CustomTokenObtainPairView.as_view(), name="token_obtain_pair"),
path("login/refresh/", TokenRefreshView.as_view(), name="token_refresh"),
path("logout/", views.LogOutViewWithToken.as_view(), name="logout"),
path("user/", views.User.as_view(), name="user"),
path("user/<int:pk>/", views.UserDetail.as_view(), name="user_detail"),
path("profile/", views.ProfileView.as_view(), name="profile"),
path('auth/google/start/', views.GoogleAuthInit.as_view(), name='google_auth'),
path('auth/google/callback/', views.GoogleCallback.as_view(), name='google_callback'),
path('auth/sms/', views.SmsAuthentication.as_view(), name='sms'),
path('auth/sms/verify/', views.VerifyCodeSmsAuthentication.as_view(), name='sms-verify'),
]
46 changes: 46 additions & 0 deletions digital_appointment/accounts/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from django.core.cache import cache
import random
import requests
import datetime


def send_quick_otp(mobile):
"""
Send a quick OTP using AmootSMS API.

Args:
mobile (str): The mobile number to send the OTP to.
line_number (str): The length of the OTP code.
send_date_time (datetime): An optional code to include in the request.

Returns:
dict: The JSON response from the AmootSMS API.
"""
"""rest api sms panel token"""
token = "A10FD5F3C01EAAF32E69DE9DD535030515BB431B"
"""default config"""
line_number = "public"
random_code_auth = random.randint(100000, 999999)
cache.set(mobile, random_code_auth, timeout=300)

data = {
"SendDateTime": datetime.datetime.now().isoformat(),
"SMSMessageText": f'سلام به کاربر محترم ویترووین شیلد کد احراز شما {random_code_auth}',
"LineNumber": line_number,
"Mobiles": mobile
}
headers = {
"Authorization": token
}
response = requests.post("https://portal.amootsms.com/rest/SendSimple", data=data, headers=headers)

if response.status_code == 200:
return response.json()
else:
return None


def verify_sms_code(user_phone, code):
"""for verify sms code"""
stored_code = cache.get(user_phone)
return stored_code == code
Loading