settings.py

master
VARUN 2 weeks ago
parent ecca878bde
commit 8c3180c758

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

@ -102,7 +102,7 @@ def validate_admin(request):
return JsonResponse(response) return JsonResponse(response)
@csrf_exempt
def admin_login(request): def admin_login(request):
if request.method == 'POST': if request.method == 'POST':
phone = request.POST.get('phone') phone = request.POST.get('phone')
@ -122,6 +122,7 @@ def admin_login(request):
return JsonResponse({'error': 'Incorrect password.'}, status=401) return JsonResponse({'error': 'Incorrect password.'}, status=401)
return JsonResponse( return JsonResponse(
{'success': 'Login successful', 'redirect_url': f'/skyonnadmin/admin/dashboard/{admin.admin_id}'}) {'success': 'Login successful', 'redirect_url': f'/skyonnadmin/admin/dashboard/{admin.admin_id}'})
return JsonResponse({'success': 'Phone number is valid.'}, status=200) return JsonResponse({'success': 'Phone number is valid.'}, status=200)
@ -138,7 +139,6 @@ def admin_dashboard(request, admin_id):
print(full_name) print(full_name)
return render(request, 'skyonnadmin/admin_dashboard.html', {'first_name': full_name, 'admin_id': admin_id,'picture': admin.picture}) return render(request, 'skyonnadmin/admin_dashboard.html', {'first_name': full_name, 'admin_id': admin_id,'picture': admin.picture})
# Admin dashboard logic goes here
def logout_view(request): def logout_view(request):

@ -83,6 +83,7 @@ DATABASES = {
'USER': 'root', 'USER': 'root',
'PASSWORD': '', 'PASSWORD': '',
'HOST': '34.93.75.170', 'HOST': '34.93.75.170',
#'HOST':'localhost',
'PORT': '3306', 'PORT': '3306',
'OPTIONS': { 'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",

@ -107,12 +107,12 @@
<input type="text" id="last_name" name="last_name" required> <input type="text" id="last_name" name="last_name" required>
</div> </div>
<div class="input-group"> <div class="input-group">
<label for="phone">Phone no.*:</label> <label for="phone" >Phone no.*:</label>
<input type="text" id="phone" name="phone" required> <input type="text" id="phone" name="phone" required maxlength="10" pattern="\d{10}">
</div> </div>
<div class="input-group"> <div class="input-group">
<label for="phone_2">Phone no. 2:</label> <label for="phone_2">Phone no. 2:</label>
<input type="text" id="phone_2" name="phone_2"> <input type="text" id="phone_2" name="phone_2" maxlength="10" pattern="\d{10}">
</div> </div>
<div class="input-group"> <div class="input-group">
<label for="company_email">Company Email*:</label> <label for="company_email">Company Email*:</label>

@ -417,12 +417,12 @@ cursor:pointer;
<span class="material-icons">notifications</span> <span class="material-icons">notifications</span>
<span class="material-icons">account_circle</span> <span class="material-icons">account_circle</span>
</div> </div>
<button class="sidebar__compose" id="compose" onclick="showCompose(event)" style="display: block; margin-bottom: 20px;"> <button class="sidebar__compose" id="compose" onclick="showCompose(event)" style="display: block; margin-bottom: 20px;margin-left: 100px;">
<span class="material-icons">add</span> Compose <span class="material-icons">add</span> Compose
</button> </button>
<!-- Sidebar Options --> <!-- Sidebar Options -->
<div class="sidebarOption-container" style="position: sticky; top: 20px; margin-top: -140px; margin-left: 150px;"> <div class="sidebarOption-container" style="position: sticky; top: 20px; margin-top: -140px; margin-left: 250px;">
<div class="sidebarOption sidebarOption__active" style="width: 100px;" id="inboxButton" onclick="setActiveBox(this, 'inbox'); renderInbox(); HideMessageDetails()"> <div class="sidebarOption sidebarOption__active" style="width: 100px;" id="inboxButton" onclick="setActiveBox(this, 'inbox'); renderInbox(); HideMessageDetails()">
<span class="material-icons" style="color:black;">inbox</span> <span class="material-icons" style="color:black;">inbox</span>
<h3>Inbox</h3> <h3>Inbox</h3>
@ -442,15 +442,16 @@ cursor:pointer;
<div id="InboxContainer" style="display:block;margin-left: 0px; top:100px; "></div> <div id="InboxContainer" style="display:block;margin-left: 0px; top:100px; "></div>
<div id="SentContainer" style="display: none;"> <div id="SentContainer" style="display: none;">
<!-- Sent Messages --> Sent Messages
</div> </div>
<div id="MessageDetailsContainer" style="display: none; height:auto; padding: 20px; border: 1px solid #ddd; margin-left: 0px; margin-top:10px; border:none; width:100%; box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; border-radius:20px;"> <div id="MessageDetailsContainer" style="display: none; height:auto; padding: 20px; border: 1px solid #ddd; margin-left: 0px; margin-top:10px; border:none; width:100%; box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; border-radius:20px;">
<button id="BackToInboxButton" onclick="backToInbox(event)"> <button id="BackToInboxButton" onclick="backToInbox(event)">
<i class="fa fa-arrow-left"></i> <!-- Back arrow icon --> <i class="fa fa-arrow-left"></i>
<span id="BackToInboxText">Back to Inbox</span> <!-- Text to show on hover --> <!-- <span id="BackToInboxText">Back to Inbox</span>-->
</button> </button>
<div id="MessageDetails" style="height: auto;"></div> <div id="MessageDetails" style="height: auto;"></div>
<div id="ConversationThread" style="height:auto;"></div> <div id="ConversationThread" style="height:auto;"></div>
</div> </div>
@ -494,8 +495,14 @@ cursor:pointer;
<button class="compose-button discard" id="Discardbutton" style="margin-left:50px; border-radius: 10px; border: none; position:fixed; color:white; background:#1F51FF;font-size:17px; width:80px; height:30px; font-weight:bold; letter-spacing:1px;" onclick="CloseCompose(event)">Discard</button> <button class="compose-button discard" id="Discardbutton" style="margin-left:50px; border-radius: 10px; border: none; position:fixed; color:white; background:#1F51FF;font-size:17px; width:80px; height:30px; font-weight:bold; letter-spacing:1px;" onclick="CloseCompose(event)">Discard</button>
<!-- <i class="fa-solid fa-paperclip" onclick="document.getElementById('attachment').click();" style="color: #1F51FF; margin-right:90px; font-size:23px; cursor: pointer;"></i>--> <i class="fa-solid fa-paperclip" id="attachment-icon" style="margin-left:150px; border: none; position:fixed; color:#1F51FF; font-size:23px; cursor: pointer;" onclick="document.getElementById('attachment-input').click();"></i>
<input type="file" id="attachment" name="attachment" style="margin-left:150px;" accept=".pdf,.doc,.docx,.txt"> <input type="file" id="attachment-input" name="attachment" style="display: none;" accept=".pdf,.doc,.docx,.txt" onchange="showFileName()">
<span id="file-name"
style="margin-left: 180px; font-size: 15px; color: black; max-width: 300px;
display: inline-block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;"></span>
</div>
</div> </div>
</div> </div>

@ -630,7 +630,7 @@ function showMessageDetails(message_id) {
fetch(`/unread_message_count/?user_id=${userId}`) fetch(`/unread_message_count/?user_id=${userId}`)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
console.log(data.unread_count); console.log('unread_count:',data.unread_count);
const notificationBadge = document.getElementById('messageNotificationBadge'); const notificationBadge = document.getElementById('messageNotificationBadge');
if (data.unread_count > 0) { if (data.unread_count > 0) {
notificationBadge.textContent = data.unread_count ; notificationBadge.textContent = data.unread_count ;
@ -789,8 +789,6 @@ function HideMessageDetails() {
messageDetailsContainer.style.display = 'none'; messageDetailsContainer.style.display = 'none';
} }
function backToInbox(event) { function backToInbox(event) {
event.preventDefault(); event.preventDefault();
const inboxContainer = document.getElementById('InboxContainer'); const inboxContainer = document.getElementById('InboxContainer');
@ -801,8 +799,6 @@ function backToInbox(event) {
messageDetailsContainer.style.display = 'none'; messageDetailsContainer.style.display = 'none';
} }
function replyMessage(event, message_id, type) { function replyMessage(event, message_id, type) {
event.preventDefault(); event.preventDefault();
console.log(message_id); console.log(message_id);
@ -904,11 +900,11 @@ emailList.forEach((email, index) => {
&times; &times;
</button> </button>
<div id="emailBars">${emailBarsHtml}</div> <!-- Dynamic email bars --> <div id="emailBars">${emailBarsHtml}</div> <!-- Dynamic email bars -->
<textarea id="message" name="message" placeholder="" <textarea id="message" name="message" placeholder="" style="width: 107%; height: 150px; border: none; margin-bottom: 10px; margin-left: -20px; border-top:1px solid #D3D3D3; outline: none; padding: 5px; resize: none; box-sizing: border-box;"></textarea>
style="width: 107%; height: 150px; border: none; margin-bottom: 10px; margin-left: -20px; border-top:1px solid #D3D3D3; outline: none; padding: 5px; resize: none; box-sizing: border-box;"></textarea>
<button type="button" style="border-radius: 10px; top:-800px; color:white; background:#1F51FF;font-size:17px; border: none; width:70px; height:30px; font-weight:bold;" onclick="sendReply(event, '${message.message_id}')">Send</button> <button type="button" style="border-radius: 10px; top:-800px; color:white; background:#1F51FF;font-size:17px; border: none; width:70px; height:30px; font-weight:bold;" onclick="sendReply(event, '${message.message_id}')">Send</button>
<!-- <i class="fa-solid fa-paperclip" onclick="document.getElementById('attachment').click();" style="color: #1F51FF; margin-left:10px; font-size:23px; cursor: pointer;"></i>--> <i class="fa-solid fa-paperclip" onclick="document.getElementById('attachment-reply').click();" style="color:#1F51FF; margin-left:10px; font-size:23px; cursor: pointer;"></i>
<input type="file" id="attachment" name="attachment" accept=".pdf,.doc,.docx,.txt"> <input type="file" id="attachment-reply" name="attachment" accept=".pdf,.doc,.docx,.txt" style="display: none;" onchange="showReplyFileName()">
<span id="file-name-reply" style="font-size: 14px; color: black; margin-left: 10px;"></span>
</div> </div>
</form> </form>
`; `;
@ -928,6 +924,28 @@ document.getElementById("closeComposeBtn").addEventListener("click", function()
if (element) { element.focus();} if (element) { element.focus();}
} }
function showReplyFileName() {
var input = document.getElementById("attachment-reply");
var fileNameDisplay = document.getElementById("file-name-reply");
if (input.files.length > 0) {
var fullFileName = input.files[0].name;
var maxLength = 40; // Maximum characters before truncating
if (fullFileName.length > maxLength) {
var truncatedFileName = fullFileName.substring(0, maxLength) + "...";
fileNameDisplay.textContent = truncatedFileName;
} else {
fileNameDisplay.textContent = fullFileName;
}
} else {
fileNameDisplay.textContent = ""; // Clear if no file is selected
}
}
function renderReplies(replies, container) { function renderReplies(replies, container) {
console.log(replies); console.log(replies);
@ -1090,7 +1108,7 @@ console.log(recipients);
const subject = document.getElementById('subject').value; // Fetch subject const subject = document.getElementById('subject').value; // Fetch subject
const message = document.getElementById('message').value; // Fetch message const message = document.getElementById('message').value; // Fetch message
const attachment = document.getElementById('attachment').files[0]; const attachment = document.getElementById('attachment-reply').files[0];
console.log(attachment); console.log(attachment);
// If both subject and message are empty, confirm whether to send the message // If both subject and message are empty, confirm whether to send the message
@ -1104,6 +1122,8 @@ console.log(recipients);
const old_message_id = id; const old_message_id = id;
console.log(old_message_id); console.log(old_message_id);
const userId = document.getElementById('user_id').value;
// Append dynamic recipient information to the form data // Append dynamic recipient information to the form data
const formData = new FormData(form); const formData = new FormData(form);
formData.append('toField', recipients); // Use dynamically gathered recipients formData.append('toField', recipients); // Use dynamically gathered recipients
@ -1148,7 +1168,6 @@ console.log(recipients);
} }
repliesContainer.innerHTML = ''; // Clear existing replies repliesContainer.innerHTML = ''; // Clear existing replies
const userId = document.getElementById('user_id').value;
fetch(`/fetch_replies/${parentMessageId}/?user_id=${userId}`) fetch(`/fetch_replies/${parentMessageId}/?user_id=${userId}`)
.then(response => response.json()) .then(response => response.json())
@ -1161,6 +1180,8 @@ console.log(recipients);
.catch(error => { .catch(error => {
console.error('Error fetching replies:', error); console.error('Error fetching replies:', error);
}); });
updateMessageNotification();
} else { } else {
alert('Failed to send message. Please try again.'); alert('Failed to send message. Please try again.');
} }
@ -1171,6 +1192,23 @@ console.log(recipients);
}); });
} }
function updateMessageNotification() {
const userId = document.getElementById('user_id').value;
fetch(`/unread_message_count/?user_id=${userId}`)
.then(response => response.json())
.then(data => {
console.log('unread_count:',data.unread_count);
const notificationBadge = document.getElementById('messageNotificationBadge');
if (data.unread_count > 0) {
notificationBadge.textContent = data.unread_count ;
notificationBadge.style.display = 'inline-flex'; // Show badge if there are unread messages
} else {
notificationBadge.style.display = 'none'; // Hide badge if no unread messages
}
})
.catch(error => console.error('Error fetching unread message count:', error));
}
function forwardMessage(index) { function forwardMessage(index) {
const message = window.Messages[index]; const message = window.Messages[index];
@ -1450,6 +1488,25 @@ function renderInbox() {
} }
function showFileName() {
var input = document.getElementById("attachment-input");
var fileNameDisplay = document.getElementById("file-name");
if (input.files.length > 0) {
var fullFileName = input.files[0].name;
var maxLength = 40; // Max characters before truncating
if (fullFileName.length > maxLength) {
var truncatedFileName = fullFileName.substring(0, maxLength) + "...";
fileNameDisplay.textContent = truncatedFileName;
} else {
fileNameDisplay.textContent = fullFileName;
}
} else {
fileNameDisplay.textContent = ""; // Clear if no file is selected
}
}
function sendMessage(event) { function sendMessage(event) {
event.preventDefault(); event.preventDefault();
@ -1458,7 +1515,8 @@ function sendMessage(event) {
const toField = document.getElementById('toField').value; // Fetch 'to' field value const toField = document.getElementById('toField').value; // Fetch 'to' field value
const subject = document.getElementById('subject').value; // Fetch subject const subject = document.getElementById('subject').value; // Fetch subject
const message = document.getElementById('Message').value; // Fetch message const message = document.getElementById('Message').value; // Fetch message
const attachment = document.getElementById('attachment').value; const attachmentInput = document.getElementById('attachment-input');
const fileNameDisplay = document.getElementById('file-name');
const recipients = toField.split(',').map(email => email.trim()).filter(email => email !== ''); const recipients = toField.split(',').map(email => email.trim()).filter(email => email !== '');
console.log(recipients); console.log(recipients);
@ -1495,6 +1553,7 @@ function sendMessage(event) {
if (data.status === 'success') { if (data.status === 'success') {
alert('Message sent successfully!'); alert('Message sent successfully!');
form.reset(); form.reset();
fileNameDisplay.innerHTML= '';
document.getElementById('ComposeContainer').style.display = 'none'; document.getElementById('ComposeContainer').style.display = 'none';
<!-- reloadMessages();--> <!-- reloadMessages();-->
@ -1505,6 +1564,7 @@ function sendMessage(event) {
.catch(error => { .catch(error => {
console.error('Error:', error); console.error('Error:', error);
}); });
} }

@ -2,7 +2,7 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('user/', views.home, name='home'), path('home/', views.home, name='home'),
path('create_user/', views.create_user, name='create_user'), # URL for creating user path('create_user/', views.create_user, name='create_user'), # URL for creating user
path('user_login/', views.user_login, name='user_login'), # URL for login path('user_login/', views.user_login, name='user_login'), # URL for login

@ -545,7 +545,6 @@ def send_message(request):
subject = request.POST.get('subject') subject = request.POST.get('subject')
body = request.POST.get('message') body = request.POST.get('message')
attachment = request.FILES.get('attachment') # Using .get() to avoid KeyError attachment = request.FILES.get('attachment') # Using .get() to avoid KeyError
attachment_url = None attachment_url = None
if attachment: if attachment:
myfile = request.FILES['attachment'] myfile = request.FILES['attachment']

Loading…
Cancel
Save