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)
@csrf_exempt
def admin_login(request):
if request.method == 'POST':
phone = request.POST.get('phone')
@ -122,6 +122,7 @@ def admin_login(request):
return JsonResponse({'error': 'Incorrect password.'}, status=401)
return JsonResponse(
{'success': 'Login successful', 'redirect_url': f'/skyonnadmin/admin/dashboard/{admin.admin_id}'})
return JsonResponse({'success': 'Phone number is valid.'}, status=200)
@ -138,7 +139,6 @@ def admin_dashboard(request, admin_id):
print(full_name)
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):

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

@ -107,12 +107,12 @@
<input type="text" id="last_name" name="last_name" required>
</div>
<div class="input-group">
<label for="phone">Phone no.*:</label>
<input type="text" id="phone" name="phone" required>
<label for="phone" >Phone no.*:</label>
<input type="text" id="phone" name="phone" required maxlength="10" pattern="\d{10}">
</div>
<div class="input-group">
<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 class="input-group">
<label for="company_email">Company Email*:</label>
@ -270,7 +270,7 @@
passwordField.reportValidity();
}
} else if (data.success) {
window.location.href = data.redirect_url;
window.location.href = data.redirect_url;
}
})
.catch(error => {

@ -417,12 +417,12 @@ cursor:pointer;
<span class="material-icons">notifications</span>
<span class="material-icons">account_circle</span>
</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
</button>
<!-- 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()">
<span class="material-icons" style="color:black;">inbox</span>
<h3>Inbox</h3>
@ -442,14 +442,15 @@ cursor:pointer;
<div id="InboxContainer" style="display:block;margin-left: 0px; top:100px; "></div>
<div id="SentContainer" style="display: none;">
<!-- Sent Messages -->
<div id="SentContainer" style="display: none;">
Sent Messages
</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;">
<button id="BackToInboxButton" onclick="backToInbox(event)">
<i class="fa fa-arrow-left"></i> <!-- Back arrow icon -->
<span id="BackToInboxText">Back to Inbox</span> <!-- Text to show on hover -->
</button>
<button id="BackToInboxButton" onclick="backToInbox(event)">
<i class="fa fa-arrow-left"></i>
<!-- <span id="BackToInboxText">Back to Inbox</span>-->
</button>
<div id="MessageDetails" style="height: auto;"></div>
<div id="ConversationThread" style="height:auto;"></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>
<!-- <i class="fa-solid fa-paperclip" onclick="document.getElementById('attachment').click();" style="color: #1F51FF; margin-right:90px; font-size:23px; cursor: pointer;"></i>-->
<input type="file" id="attachment" name="attachment" style="margin-left:150px;" accept=".pdf,.doc,.docx,.txt">
<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-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>

@ -630,7 +630,7 @@ function showMessageDetails(message_id) {
fetch(`/unread_message_count/?user_id=${userId}`)
.then(response => response.json())
.then(data => {
console.log(data.unread_count);
console.log('unread_count:',data.unread_count);
const notificationBadge = document.getElementById('messageNotificationBadge');
if (data.unread_count > 0) {
notificationBadge.textContent = data.unread_count ;
@ -789,8 +789,6 @@ function HideMessageDetails() {
messageDetailsContainer.style.display = 'none';
}
function backToInbox(event) {
event.preventDefault();
const inboxContainer = document.getElementById('InboxContainer');
@ -801,8 +799,6 @@ function backToInbox(event) {
messageDetailsContainer.style.display = 'none';
}
function replyMessage(event, message_id, type) {
event.preventDefault();
console.log(message_id);
@ -904,11 +900,11 @@ emailList.forEach((email, index) => {
&times;
</button>
<div id="emailBars">${emailBarsHtml}</div> <!-- Dynamic email bars -->
<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>
<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>
<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>-->
<input type="file" id="attachment" name="attachment" accept=".pdf,.doc,.docx,.txt">
<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-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>
</form>
`;
@ -928,6 +924,28 @@ document.getElementById("closeComposeBtn").addEventListener("click", function()
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) {
console.log(replies);
@ -1090,7 +1108,7 @@ console.log(recipients);
const subject = document.getElementById('subject').value; // Fetch subject
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);
// 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;
console.log(old_message_id);
const userId = document.getElementById('user_id').value;
// Append dynamic recipient information to the form data
const formData = new FormData(form);
formData.append('toField', recipients); // Use dynamically gathered recipients
@ -1148,7 +1168,6 @@ console.log(recipients);
}
repliesContainer.innerHTML = ''; // Clear existing replies
const userId = document.getElementById('user_id').value;
fetch(`/fetch_replies/${parentMessageId}/?user_id=${userId}`)
.then(response => response.json())
@ -1161,6 +1180,8 @@ console.log(recipients);
.catch(error => {
console.error('Error fetching replies:', error);
});
updateMessageNotification();
} else {
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) {
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) {
event.preventDefault();
@ -1458,7 +1515,8 @@ function sendMessage(event) {
const toField = document.getElementById('toField').value; // Fetch 'to' field value
const subject = document.getElementById('subject').value; // Fetch subject
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 !== '');
console.log(recipients);
@ -1495,6 +1553,7 @@ function sendMessage(event) {
if (data.status === 'success') {
alert('Message sent successfully!');
form.reset();
fileNameDisplay.innerHTML= '';
document.getElementById('ComposeContainer').style.display = 'none';
<!-- reloadMessages();-->
@ -1505,6 +1564,7 @@ function sendMessage(event) {
.catch(error => {
console.error('Error:', error);
});
}

@ -2,7 +2,7 @@ from django.urls import path
from . import views
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('user_login/', views.user_login, name='user_login'), # URL for login

@ -545,7 +545,6 @@ def send_message(request):
subject = request.POST.get('subject')
body = request.POST.get('message')
attachment = request.FILES.get('attachment') # Using .get() to avoid KeyError
attachment_url = None
if attachment:
myfile = request.FILES['attachment']
@ -1182,4 +1181,4 @@ def unread_message_count(request):
'unread_count': unread_count,
'unread_messages': list(unread_not_in_status) # Convert set to list for JSON response
})
return JsonResponse({'status': 'error', 'message': 'Invalid request method'}, status=400)
return JsonResponse({'status': 'error', 'message': 'Invalid request method'}, status=400)

Loading…
Cancel
Save