Skip to content

Commit dde55a9

Browse files
Initial Commit, Creating the base Django Application with the Dashboard (#2)
* Initializing the Django Application * adding a new app bootstrap along with login url and social login for google * Adding the Dashbord URL * Adding code for rendering the dashboard, adding unit tests for dashboard view helpers adding layout and the template method for the views
1 parent 4d0d236 commit dde55a9

File tree

19 files changed

+909
-0
lines changed

19 files changed

+909
-0
lines changed

BrowserStackAutomation/__init__.py

Whitespace-only changes.

BrowserStackAutomation/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for BrowserStackAutomation project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "BrowserStackAutomation.settings")
15+
16+
application = get_asgi_application()

BrowserStackAutomation/settings.py

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
"""
2+
Django settings for BrowserStackAutomation project.
3+
4+
Generated by 'django-admin startproject' using Django 4.1.3.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/4.1/ref/settings/
11+
"""
12+
13+
import glob
14+
from os.path import join
15+
import json
16+
from pathlib import Path
17+
import os
18+
19+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
20+
BASE_DIR = Path(__file__).resolve().parent.parent
21+
22+
23+
# Quick-start development settings - unsuitable for production
24+
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
25+
26+
# SECURITY WARNING: keep the secret key used in production secret!
27+
SECRET_KEY = ""
28+
29+
# SECURITY WARNING: don't run with debug turned on in production!
30+
DEBUG = True
31+
32+
ALLOWED_HOSTS = []
33+
34+
35+
# Application definition
36+
37+
INSTALLED_APPS = [
38+
"django.contrib.admin",
39+
"django.contrib.auth",
40+
"django.contrib.contenttypes",
41+
"django.contrib.sessions",
42+
"django.contrib.messages",
43+
"django.contrib.staticfiles",
44+
"bootprocess.apps.BootprocessConfig",
45+
'social_django',
46+
'Access',
47+
]
48+
49+
MIDDLEWARE = [
50+
"django.middleware.security.SecurityMiddleware",
51+
"django.contrib.sessions.middleware.SessionMiddleware",
52+
"django.middleware.common.CommonMiddleware",
53+
"django.middleware.csrf.CsrfViewMiddleware",
54+
"django.contrib.auth.middleware.AuthenticationMiddleware",
55+
"django.contrib.messages.middleware.MessageMiddleware",
56+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
57+
'social_django.middleware.SocialAuthExceptionMiddleware',
58+
]
59+
60+
AUTHENTICATION_BACKENDS = (
61+
'social_core.backends.google.GoogleOAuth2',
62+
'django.contrib.auth.backends.ModelBackend',
63+
)
64+
65+
SOCIAL_AUTH_PIPELINE = (
66+
'social_core.pipeline.social_auth.social_details',
67+
'social_core.pipeline.social_auth.social_uid',
68+
'social_core.pipeline.social_auth.auth_allowed',
69+
'social_core.pipeline.social_auth.social_user',
70+
'social_core.pipeline.user.get_username',
71+
'social_core.pipeline.user.create_user',
72+
'social_core.pipeline.social_auth.associate_user',
73+
'social_core.pipeline.social_auth.load_extra_data',
74+
'social_core.pipeline.user.user_details',
75+
'social_core.pipeline.debug.debug',
76+
)
77+
78+
SOCIAL_AUTH_DISCONNECT_PIPELINE = (
79+
# Verifies that the social association can be disconnected from the current
80+
# user (ensure that the user login mechanism is not compromised by this
81+
# disconnection).
82+
#'social.pipeline.disconnect.allowed_to_disconnect',
83+
84+
# Collects the social associations to disconnect.
85+
'social_core.pipeline.disconnect.get_entries',
86+
87+
# Revoke any access_token when possible.
88+
'social_core.pipeline.disconnect.revoke_tokens',
89+
90+
# Removes the social associations.
91+
'social_core.pipeline.disconnect.disconnect',
92+
)
93+
94+
ROOT_URLCONF = "BrowserStackAutomation.urls"
95+
96+
template_dirs = glob.glob(join(BASE_DIR, "templates"))
97+
98+
TEMPLATES = [
99+
{
100+
"BACKEND": "django.template.backends.django.DjangoTemplates",
101+
"DIRS": template_dirs,
102+
"APP_DIRS": True,
103+
"OPTIONS": {
104+
"context_processors": [
105+
"django.template.context_processors.debug",
106+
"django.template.context_processors.request",
107+
"django.contrib.auth.context_processors.auth",
108+
"django.contrib.messages.context_processors.messages",
109+
],
110+
},
111+
},
112+
]
113+
114+
WSGI_APPLICATION = "BrowserStackAutomation.wsgi.application"
115+
116+
117+
# Database
118+
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
119+
120+
DATABASES = {
121+
"default": {
122+
"ENGINE": "django.db.backends.sqlite3",
123+
"NAME": BASE_DIR / "db.sqlite3",
124+
}
125+
}
126+
127+
128+
# Password validation
129+
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
130+
131+
AUTH_PASSWORD_VALIDATORS = [
132+
{
133+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
134+
},
135+
{
136+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
137+
},
138+
{
139+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
140+
},
141+
{
142+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
143+
},
144+
]
145+
146+
147+
# Internationalization
148+
# https://docs.djangoproject.com/en/4.1/topics/i18n/
149+
150+
LANGUAGE_CODE = "en-us"
151+
152+
TIME_ZONE = "UTC"
153+
154+
USE_I18N = True
155+
156+
USE_TZ = True
157+
158+
159+
# Static files (CSS, JavaScript, Images)
160+
# https://docs.djangoproject.com/en/4.1/howto/static-files/
161+
162+
STATIC_URL = "static/"
163+
STATIC_ROOT = os.path.join(BASE_DIR, 'public/')
164+
STATICFILES_DIRS = [
165+
os.path.join(BASE_DIR, "static/"),
166+
]
167+
# Default primary key field type
168+
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
169+
170+
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
171+
172+
173+
with open('config.json') as data_file:
174+
data = json.load(data_file)
175+
176+
177+
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = data['googleapi']['SOCIAL_AUTH_GOOGLE_OAUTH2_KEY']
178+
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET= data['googleapi']['SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET']
179+
SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS = data['googleapi']['SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS']
180+
181+
USER_STATUS_CHOICES = [
182+
('1', 'active'),
183+
('2', 'offboarding'),
184+
('3', 'offboarded'),
185+
]
186+
187+
DEFAULT_ACCESS_GROUP = 'default_access_group'

BrowserStackAutomation/urls.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""BrowserStackAutomation URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/4.1/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from bootprocess.views import dashboard, logout_view
17+
from django.contrib import admin
18+
from django.contrib.auth import views as auth_views
19+
from django.urls import re_path, include
20+
from Access.views import showAccessHistory, pendingFailure, pendingRevoke, updateUserInfo, createNewGroup, allUserAccessList, allUsersList, requestAccess, groupRequestAccess
21+
from django.conf.urls.static import static
22+
23+
urlpatterns = [
24+
re_path(r'^admin/', admin.site.urls),
25+
re_path(r'^$',dashboard, name='dashboard'),
26+
re_path(r'^login/$', auth_views.LoginView.as_view(), name='login'),
27+
re_path(r'^logout/$', logout_view, name='logout'),
28+
re_path(r'^oauth/', include('social_django.urls', namespace='social')),
29+
30+
re_path(r'^access/showAccessHistory$', showAccessHistory, name='showAccessHistory'),
31+
re_path(r'^resolve/pendingFailure',pendingFailure, name='pendingFailure'),
32+
re_path(r'^resolve/pendingRevoke',pendingRevoke, name='pendingRevoke'),
33+
re_path(r'^user/updateUserInfo/',updateUserInfo,name='updateUserInfo'),
34+
re_path(r'^group/create$', createNewGroup, name='createNewGroup'),
35+
re_path(r'^access/userAccesses$', allUserAccessList, name='allUserAccessList'),
36+
re_path(r'^access/usersList$', allUsersList, name='allUsersList'),
37+
re_path(r'^access/requestAccess$', requestAccess, name='requestAccess'),
38+
re_path(r'^group/requestAccess$', groupRequestAccess, name='groupRequestAccess'),
39+
]

BrowserStackAutomation/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for BrowserStackAutomation project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "BrowserStackAutomation.settings")
15+
16+
application = get_wsgi_application()

bootprocess/__init__.py

Whitespace-only changes.

bootprocess/admin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.contrib import admin
2+
3+
from Access.models import User
4+
5+
admin.site.register(User)

bootprocess/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 BootprocessConfig(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "bootprocess"

bootprocess/general.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from os import environ
2+
import boto3
3+
4+
def emailSES(destination, subject,body):
5+
print("Email Sent!!!")
6+
return True

bootprocess/migrations/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)