Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@
'django.contrib.staticfiles',
'django_filters',
'django_crontab',
'rest_framework',
'emp',
'accounts',
'crispy_forms',
'moodle',
'spoken',
'ckeditor',
'events',
'utilities',



]

Expand Down Expand Up @@ -171,7 +175,7 @@
}
ROLE_ID = { 'MANAGER': 1,'STUDENT':2,'EMPLOYER':3}
ROLES = {'MANAGER':(1,'MANAGER'),'STUDENT':(2,'STUDENT'),'EMPLOYER':(3,'EMPLOYER')}
CRISPY_TEMPLATE_PACK = 'bootstrap4'

MESSAGE_TAGS = {
messages.DEBUG: 'alert-info',
messages.INFO: 'alert-info',
Expand Down Expand Up @@ -226,4 +230,7 @@
GALLERY_TESTIMONIAL = GALLERY_TESTIMONIAL
CONTACT_MAIL = CONTACT_MAIL

PASS_GRADE=PASS_GRADE
PASS_GRADE=PASS_GRADE

# CRISPY_TEMPLATE_PACK = ''
# CRISPY_TEMPLATE_PACK = 'bootstrap4'
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
path('',include('emp.urls')),
path('',include('moodle.urls')),
path('',include('accounts.urls')),
path('api/', include('utilities.urls')),

# ]
]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions employer_recommendation_system/utilities/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions employer_recommendation_system/utilities/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class UtilitiesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'utilities'
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "service_account",
"project_id": "job-fair-398302",
"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HG5qtumhaOuEMhkXTmWNQP07YPlOgJvlHivY6qZ0PLl\nP8lE0QNLVLGmRJ3Nc+ykv49G1EXyWrOyXh4XbW0R1BCqrEkg43pR/bEUaGmYhEUq\nNsfX8s4siwKBgAWT/H68AVo5PutDFMmgNAmBJ56qY4w2p8sRhTphs0CSdWjkAOM2\neKXrjKiWEXJlH5Aqo5H3dLV02kUPccgBPugrVQJ2GLWTbQz+N3lkwmgZULSqvhU9\nTsPwqQjrNlTqzlr44ZatNiaBQuCWs3huX/+f1dDISQ0rh5QmYe02uOstAoGAMaLM\nzWXFcW09d8TCls1B6+COhBNcRX9lHphVOUJrLefb6D4q4XFljOnjp2wEqTi4Pxc2\nPP3lL/bHJ0w70y7D5pFp1yaZWiPymC9XjyxPYj0o8iFHzdxYqMTkdZN/gc5V1xpM\nVRVxuBf+kmh42qtplLZVkPYMtjkNjZsa1F+IYaUCgYA79fEsXsH065UAtxvOYqd8\n2S6kBlBDYE16ap39k7GtsCK0x9JzuEhi0sH/sUGbkJIo569ms31Xk5o1Ax9iZYrJ\njLvTctAFPygD3G9Mjvwj+Aq94LmTZ0yugjJcOCneqJdQOX/MMNS2d+JnIaiEQD/p\nXw2iClQUkRgHyHTazBnHZA==\n-----END PRIVATE KEY-----\n",
"client_email": "job-fair@job-fair-398302.iam.gserviceaccount.com",
"client_id": "114252800178464690673",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/job-fair%40job-fair-398302.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
Empty file.
3 changes: 3 additions & 0 deletions employer_recommendation_system/utilities/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
23 changes: 23 additions & 0 deletions employer_recommendation_system/utilities/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from emp.models import Company




def project_one():
print("Hello World")
company = Company(
name="Example Company",
emp_name="John Doe",
emp_contact="123-456-7890",
state_c=1, # Replace with the actual state ID
city_c=1, # Replace with the actual city ID
address="123 Main St",
email="example@example.com",
logo="logo.png", # Replace with the actual logo file path
description="This is an example company",

)


company.save()
print("Jagaur")
17 changes: 17 additions & 0 deletions employer_recommendation_system/utilities/script1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from emp.models import Job
from datetime import date

def project_two():
print("Hello World")
job = Job(
title="Software Engineer",
# location="New York",
requirements="Python, Django, SQL",
job_type_id= 1,
last_app_date= date(2023, 8, 30),
foss ="",
institute_type=""
)

job.save()
print(" World")
3 changes: 3 additions & 0 deletions employer_recommendation_system/utilities/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
6 changes: 6 additions & 0 deletions employer_recommendation_system/utilities/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.urls import path
from . import views

urlpatterns = [
path('fetch-google-sheet/<str:spreadsheet_id>/', views.fetch_google_sheet, name='fetch_google_sheet'),
]
62 changes: 62 additions & 0 deletions employer_recommendation_system/utilities/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from django.http import JsonResponse
from google.oauth2.service_account import Credentials
import gspread
from emp.models import Company,Job
from emp.views import CompanyDetailView

# from spreadsheet.models import SheetData

def fetch_google_sheet(request, spreadsheet_id):
# Load the credentials from the JSON key file
print(1)
scopes = [
'https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive'
]

print(f"spreadsheet_id : {spreadsheet_id}")
credentials = Credentials.from_service_account_file('/home/rohini/Desktop/ers/Employer-Recommendation-System/employer_recommendation_system/utilities/job-fair-398302-53e26af2ca93.json',
scopes=scopes)
print(2)
# Authenticate with Google Sheets
gc = gspread.authorize(credentials)
print(3)
try:
# Open the Google Sheets spreadsheet by ID
sheet = gc.open_by_key(spreadsheet_id)

# Access a specific worksheet within the spreadsheet
worksheet = sheet.get_worksheet(0) # Change the index as needed

# Fetch the data from the worksheet
data = worksheet.get_all_records()
print(type(data))
print(data)
# Save data to the database
for row in data:
company_name = row.get("Company Name")
job_description = row.get('job_description')
print(f"company_name : {company_name}")
company = Company(name=company_name)
# CompanyDetailView.append(company)
company.save()





# spreadsheet_id = ('1EUN10lGd7_ikNgt7pWRyt5RA5yCVorwMOQOqbDnuzrE')
# response = fetch_google_sheet(request, spreadsheet_id)
# Query the database to check if data is stored
# Retrieve all records as a queryset
# You can print or return 'stored_data' as a JSON response to verify

return JsonResponse({'message': 'Data fetched and stored successfully.'})




# Return the data as JSON response
# return JsonResponse(data, safe=False)
except Exception as e:
return JsonResponse({'error': str(e)}, status=500)