Spaces:
Sleeping
Sleeping
Commit
·
284f0f1
1
Parent(s):
9edfa52
Update database connection options and improve home page structure
Browse files- BridgeMentor/settings.py +4 -4
- core/templates/home.html +45 -43
BridgeMentor/settings.py
CHANGED
@@ -104,10 +104,10 @@ DATABASES = {
|
|
104 |
'PASSWORD': os.environ['DB_PASSWORD'],
|
105 |
'HOST': os.environ['DB_HOST'],
|
106 |
'PORT': os.environ['DB_PORT'],
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
},
|
112 |
}
|
113 |
|
|
|
104 |
'PASSWORD': os.environ['DB_PASSWORD'],
|
105 |
'HOST': os.environ['DB_HOST'],
|
106 |
'PORT': os.environ['DB_PORT'],
|
107 |
+
'OPTIONS': {
|
108 |
+
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
|
109 |
+
'connect_timeout': 20,
|
110 |
+
},
|
111 |
},
|
112 |
}
|
113 |
|
core/templates/home.html
CHANGED
@@ -1,48 +1,50 @@
|
|
1 |
<!-- home/templates/home/home.html -->
|
2 |
<!DOCTYPE html>
|
3 |
<html>
|
4 |
-
|
5 |
-
|
6 |
-
</
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
return
|
28 |
-
}
|
29 |
-
|
30 |
-
const res = await fetch(`/api/search/?q=${encodeURIComponent(query)}`)
|
31 |
-
const data = await res.json()
|
32 |
-
|
33 |
resultsList.innerHTML = ''
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
})
|
46 |
-
|
47 |
-
</
|
48 |
-
</
|
|
|
|
|
|
1 |
<!-- home/templates/home/home.html -->
|
2 |
<!DOCTYPE html>
|
3 |
<html>
|
4 |
+
|
5 |
+
<head>
|
6 |
+
<title>BridgeMentor</title>
|
7 |
+
</head>
|
8 |
+
|
9 |
+
<body>
|
10 |
+
{% if user.is_authenticated %}
|
11 |
+
<span>Welcome, {{ user.first_name }}!</span> <a href="{% url 'logout' %}">Logout</a>
|
12 |
+
{% else %}
|
13 |
+
<a href="{% url 'social:begin' 'google-oauth2' %}">Login With Google</a>
|
14 |
+
{% endif %}
|
15 |
+
|
16 |
+
<h2>Search Domains</h2>
|
17 |
+
<input type="text" id="search-input" placeholder="Type something..." autocomplete="off" />
|
18 |
+
<ul id="results-list"></ul>
|
19 |
+
|
20 |
+
<script>
|
21 |
+
const input = document.getElementById('search-input')
|
22 |
+
const resultsList = document.getElementById('results-list')
|
23 |
+
|
24 |
+
input.addEventListener('input', async () => {
|
25 |
+
const query = input.value.trim()
|
26 |
+
if (!query) {
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
resultsList.innerHTML = ''
|
28 |
+
return
|
29 |
+
}
|
30 |
+
|
31 |
+
const res = await fetch(`/api/search/?q=${encodeURIComponent(query)}`)
|
32 |
+
const data = await res.json()
|
33 |
+
|
34 |
+
resultsList.innerHTML = ''
|
35 |
+
data.results.forEach((item) => {
|
36 |
+
const li = document.createElement('li')
|
37 |
+
|
38 |
+
const link = document.createElement('a')
|
39 |
+
link.href = `/${item.type.toLowerCase()}/${item.id}/`
|
40 |
+
link.textContent = item.text
|
41 |
+
link.style.textDecoration = 'none'
|
42 |
+
link.style.color = 'black'
|
43 |
+
li.appendChild(link)
|
44 |
+
resultsList.appendChild(li)
|
45 |
})
|
46 |
+
})
|
47 |
+
</script>
|
48 |
+
</body>
|
49 |
+
|
50 |
+
</html>
|