Skip to content

Commit

Permalink
Removed the values from terraform, created new dummey users.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmoud-Emad committed Nov 5, 2023
1 parent 683f866 commit 80dd745
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 45 deletions.
6 changes: 4 additions & 2 deletions server/cshr/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

from server.cshr.models.abstracts import TimeStamp
from server.cshr.models.office import Office
from server.cshr.utils.dummy_data import create_locations
from server.cshr.utils.dummy_data import create_locations, create_users
from server.cshr.utils.generate import generate_random_color

from server.components import config

class TEAM(models.TextChoices):

Check failure on line 14 in server/cshr/models/users.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/models/users.py#L14

Expected 2 blank lines, found 1 (E302)
"""enum class for team options"""
Expand Down Expand Up @@ -47,6 +47,8 @@ def create_user(self, email: str, password: str) -> "User":
raise ValueError("Users must have an email address")

create_locations()
if config("DJANGO_DEBUG") == "ON":
create_users()

user = self.model(
email=self.normalize_email(email),
Expand Down
142 changes: 140 additions & 2 deletions server/cshr/utils/dummy_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,128 @@
from typing import List, Dict, Any
from server.cshr.models.office import WEEKEND_DAYS, Office
from server.cshr.models.users import User, TEAM, USER_TYPE, GENDER_TYPE

users: List[Dict[str, Any]] = [
{
"first_name": "Nayer",
"last_name": "Admin",
"password": "123456789",
"email": "[email protected]",
"mobile_number": "123456789123",
"telegram_link": "@nayer",
"team": TEAM.BusinessDevelopment,
"user_type": USER_TYPE.ADMIN,
"address": "---",
"job_title": "Manager",
"gender" : GENDER_TYPE.MALE,

Check failure on line 17 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L17

Whitespace before ':' (E203)
},
{
"first_name": "Nayer",
"last_name": "User",
"password": "123456789",
"email": "[email protected]",
"mobile_number": "123456789123",
"telegram_link": "@nayer",
"team": TEAM.BusinessDevelopment,
"user_type": USER_TYPE.USER,
"address": "---",
"job_title": "Manager",
"gender" : GENDER_TYPE.MALE,

Check failure on line 30 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L30

Whitespace before ':' (E203)
},
{
"first_name": "Nayer",
"last_name": "Supervisor",
"password": "123456789",
"email": "[email protected]",
"mobile_number": "123456789123",
"telegram_link": "@nayer",
"team": TEAM.BusinessDevelopment,
"user_type": USER_TYPE.SUPERVISOR,
"address": "---",
"job_title": "Manager",
"gender" : GENDER_TYPE.MALE,

Check failure on line 43 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L43

Whitespace before ':' (E203)
},
{
"first_name": "Rafik",
"last_name": "Admin",
"password": "123456789",
"email": "[email protected]",
"mobile_number": "123456789123",
"telegram_link": "@rafik",
"team": TEAM.HRAndFinance,
"user_type": USER_TYPE.ADMIN,
"address": "---",
"job_title": "HR",
"gender" : GENDER_TYPE.MALE,

Check failure on line 56 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L56

Whitespace before ':' (E203)
},
{
"first_name": "Rafik",
"last_name": "User",
"password": "123456789",
"email": "[email protected]",
"mobile_number": "123456789123",
"telegram_link": "@rafik",
"team": TEAM.HRAndFinance,
"user_type": USER_TYPE.USER,
"address": "---",
"job_title": "HR",
"gender" : GENDER_TYPE.MALE,

Check failure on line 69 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L69

Whitespace before ':' (E203)
},
{
"first_name": "Rafik",
"last_name": "Supervisor",
"password": "123456789",
"email": "[email protected]",
"mobile_number": "123456789123",
"telegram_link": "@rafik",
"team": TEAM.HRAndFinance,
"user_type": USER_TYPE.SUPERVISOR,
"address": "---",
"job_title": "HR",
"gender" : GENDER_TYPE.MALE,

Check failure on line 82 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L82

Whitespace before ':' (E203)
},
{
"first_name": "Evon",
"last_name": "Admin",
"password": "123456789",
"email": "[email protected]",
"mobile_number": "123456789123",
"telegram_link": "@evon",
"team": TEAM.HRAndFinance,
"user_type": USER_TYPE.ADMIN,
"address": "---",
"job_title": "HR",
"gender" : GENDER_TYPE.FEMALE,

Check failure on line 95 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L95

Whitespace before ':' (E203)
},
{
"first_name": "Evon",
"last_name": "User",
"password": "123456789",
"email": "[email protected]",
"mobile_number": "123456789123",
"telegram_link": "@evon",
"team": TEAM.HRAndFinance,
"user_type": USER_TYPE.USER,
"address": "---",
"job_title": "HR",
"gender" : GENDER_TYPE.FEMALE,

Check failure on line 108 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L108

Whitespace before ':' (E203)
},
{
"first_name": "Evon",
"last_name": "Supervisor",
"password": "123456789",
"email": "[email protected]",
"mobile_number": "123456789123",
"telegram_link": "@evon",
"team": TEAM.HRAndFinance,
"user_type": USER_TYPE.SUPERVISOR,
"address": "---",
"job_title": "HR",
"gender" : GENDER_TYPE.FEMALE,

Check failure on line 121 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L121

Whitespace before ':' (E203)
},
]

locations = [
locations: List[Dict[str, Any]] = [
{
"name": "Belgium",
"country": "Belgium",
Expand Down Expand Up @@ -40,4 +161,21 @@ def create_locations():
name=location.get("name"),
country=location.get("country"),
weekend=location.get("weekend")
)
)

def create_users():

Check failure on line 166 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L166

Expected 2 blank lines, found 1 (E302)
for user in users:

Check failure on line 167 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L167

Indentation is not a multiple of 4 (E111)
User.objects.create(
first_name=user.get("first_name"),
last_name=user.get("last_name"),
email=user.get("email"),
password=user.get("password"),
mobile_number=user.get("mobile_number"),
telegram_link=user.get("telegram_link"),
team=user.get("team"),
user_type=user.get("user_type"),
address=user.get("address"),
job_title=user.get("job_title"),
gender=user.get("gender"),
)

Check failure on line 181 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L181

Blank line contains whitespace (W293)

Check failure on line 181 in server/cshr/utils/dummy_data.py

View workflow job for this annotation

GitHub Actions / Flake8

server/cshr/utils/dummy_data.py#L181

No newline at end of file (W292)
17 changes: 0 additions & 17 deletions terraform/.terraform.lock.hcl

This file was deleted.

46 changes: 23 additions & 23 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,81 +8,81 @@ terraform {
}

provider "grid" {
mnemonics = "actual reveal dish guilt inner film scheme between lonely myself material replace"
network = "dev"
mnemonics = ""
network = ""
}

data "grid_gateway_domain" "server_domain" {
node = 11
name = "newcshrserver"
node = 2
name = "cshrserver"
}

data "grid_gateway_domain" "client_domain" {
node = 11
name = "newcshr"
node = 2
name = "cshr"
}

resource "grid_network" "net2" {
nodes = [11]
nodes = [2]
ip_range = "10.1.0.0/16"
name = "newcshrnetwork"
description = "newer network"
add_wg_access = true
}

resource "grid_deployment" "d1" {
node = 11
node = 2
network_name = grid_network.net2.name
vms {
name = "cshrservervm"
flist = "https://hub.grid.tf/omda.3bot/codescalersinternship-cshr_server-latest.flist"
name = ""
flist = ""
cpu = 2
memory = 4096
publicip = false
planetary = true
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCF3JezThwSchTvkF2oPtn8X6chevNsfE58dIY3/eg5zK9tKgNYIB2saoFh12a0AJU424sAeLO0HghhNhe/Co62xkzHhk6EpXWNSFkrlzw+FVn1FKDZbbOZH47sC3n6p5a3YhM4dALssZ/aZdpaKBgXkzk91usJ+GVa+eOnpMRBlHgi9PpvowyzPSKeH9ZcVRBPnVU+nQGyV+kd6RahNBoNgNrHu/QFI92yg/y/7Szus1IS0U92cWKf/K/Sot7O10kSjmj06lMGOO8zdENk/xrtUtRHzemCj+mq0Q/3KUMCGvdb/tH0TDeNenxvibummiym4VTcnYqbm+RDXWG8HUc/RPfEVBl8p1NGZnkBt6QJl5hddHaYwx8CCmf3maSrQFcmrWYtlUDBXYkPyrv0qmy2gM1PScntF/X9zhIfnELlyAVAKXfzVwixrBh7oOIAqefydSVcwWtCXoH38F5q/zo9bQv+eHntI83mZrUUT7JGirQF64fpJKbCZPhv0kUm9bF7DVQMiyRZdk748cgVp7dEzMVlrfZ2eIvZag5zmuJTPB7bw00+Ik9jNaOIhEoCWEaYBw7KmrLonesV8rWUkEAwWPe28bXCVmUZlgZbWJi7BFWCst2Z/j2WgScHbdAv28gAcneDW4yQmt2YaYqXqmwgSVCaD/irq5FSO4upmo5u0Q== [email protected]"
DJANGO_DEBUG="ON"
EMAIL="[email protected]"
EMAIL_PASSWORD="ubunyyzgxeoxhnze"
EMAIL_HOST="smtp.gmail.com"
REDIS_HOST="redis://localhost:6379"
DJANGO_SUPERUSER_EMAIL="[email protected]"
DJANGO_SUPERUSER_PASSWORD="0000"
SSH_KEY=""
DJANGO_DEBUG=""
EMAIL=""
EMAIL_PASSWORD=""
EMAIL_HOST=""
REDIS_HOST=""
DJANGO_SUPERUSER_EMAIL=""
DJANGO_SUPERUSER_PASSWORD=""
SERVER_DOMAIN_NAME=format(data.grid_gateway_domain.server_domain.fqdn)
CLIENT_DOMAIN_NAME=format(data.grid_gateway_domain.client_domain.fqdn)
}
}
}

resource "grid_deployment" "d2" {
node = 11
node = 2
network_name = grid_network.net2.name
vms {
name = "cshrclientvmnew"
publicip = false
planetary = true
flist = "https://hub.grid.tf/omda.3bot/codescalersinternship-cshr_client-latest.flist"
flist = ""
cpu = 2
memory = 4096
entrypoint = "/sbin/zinit init"
env_vars = {
SSH_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCF3JezThwSchTvkF2oPtn8X6chevNsfE58dIY3/eg5zK9tKgNYIB2saoFh12a0AJU424sAeLO0HghhNhe/Co62xkzHhk6EpXWNSFkrlzw+FVn1FKDZbbOZH47sC3n6p5a3YhM4dALssZ/aZdpaKBgXkzk91usJ+GVa+eOnpMRBlHgi9PpvowyzPSKeH9ZcVRBPnVU+nQGyV+kd6RahNBoNgNrHu/QFI92yg/y/7Szus1IS0U92cWKf/K/Sot7O10kSjmj06lMGOO8zdENk/xrtUtRHzemCj+mq0Q/3KUMCGvdb/tH0TDeNenxvibummiym4VTcnYqbm+RDXWG8HUc/RPfEVBl8p1NGZnkBt6QJl5hddHaYwx8CCmf3maSrQFcmrWYtlUDBXYkPyrv0qmy2gM1PScntF/X9zhIfnELlyAVAKXfzVwixrBh7oOIAqefydSVcwWtCXoH38F5q/zo9bQv+eHntI83mZrUUT7JGirQF64fpJKbCZPhv0kUm9bF7DVQMiyRZdk748cgVp7dEzMVlrfZ2eIvZag5zmuJTPB7bw00+Ik9jNaOIhEoCWEaYBw7KmrLonesV8rWUkEAwWPe28bXCVmUZlgZbWJi7BFWCst2Z/j2WgScHbdAv28gAcneDW4yQmt2YaYqXqmwgSVCaD/irq5FSO4upmo5u0Q== [email protected]"
SSH_KEY = ""
SERVER_BASE_URL=format("https://%s", data.grid_gateway_domain.server_domain.fqdn)
}
}
}

resource "grid_name_proxy" "p1" {
node = 11
node = 2
name = "newcshrserver"
backends = [format("http://[%s]:8000", grid_deployment.d1.vms[0].ygg_ip)]
tls_passthrough = false
}

resource "grid_name_proxy" "p2" {
node = 11
node = 2
name = "newcshr"
backends = [format("http://[%s]:6000", grid_deployment.d2.vms[0].ygg_ip)]
tls_passthrough = false
Expand Down
1 change: 0 additions & 1 deletion terraform/state.json

This file was deleted.

0 comments on commit 80dd745

Please sign in to comment.