-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meta tag description changes (#1712)
- Loading branch information
Showing
11 changed files
with
234 additions
and
2 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class EmailServiceConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'email_service' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
{% extends "wagtailusers/users/index.html" %} | ||
{% load wagtailadmin_tags i18n %} | ||
|
||
{% block content %} | ||
{% trans "Users" as users_str %} | ||
{% url "wagtailusers_users:add" as add_link %} | ||
|
||
{% include "wagtailadmin/shared/header.html" with subtitle=group.name title=users_str action_url=add_link action_text="Add a user" icon="user" search_url="wagtailusers_users:index" %} | ||
|
||
{# <div class="nice-padding">#} | ||
{# <div class="action-buttons">#} | ||
{# <button id="invite-admin-button" class="button button--icon" style="margin-left: 10px;">#} | ||
{# {% icon name="plus" wrapped=1 %} Invite Admin User#} | ||
{# </button>#} | ||
{# </div>#} | ||
{# </div>#} | ||
|
||
<!-- Modal for Inviting Admin User --> | ||
<div id="invite-admin-modal" class="modal"> | ||
<div class="modal-content"> | ||
<span class="close-button" id="close-modal">×</span> | ||
<h2>Invite Admin User</h2> | ||
<form id="invite-admin-form"> | ||
<label for="first_name">First Name:</label> | ||
<input type="text" id="first_name" name="first_name" placeholder="Enter First Name"> | ||
<span class="error-message" id="first_name_error" style="color: red; display: none;"></span> | ||
|
||
<label for="last_name">Last Name:</label> | ||
<input type="text" id="last_name" name="last_name" placeholder="Enter Last Name"> | ||
<span class="error-message" id="last_name_error" style="color: red; display: none;"></span> | ||
|
||
<label for="email">Email Address:</label> | ||
<input type="text" id="email" name="email" placeholder="Enter Email" title="Please enter a valid email address"> | ||
<span class="error-message" id="email_error" style="color: red; display: none;"></span> | ||
|
||
<button type="submit" class="button button--icon" style="margin-left: 10px;">Send Invite</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.modal { | ||
display: none; | ||
position: fixed; | ||
z-index: 1000; | ||
left: 0; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
overflow: auto; | ||
background-color: rgba(0, 0, 0, 0.4); | ||
} | ||
.modal-content { | ||
background-color: #fefefe; | ||
margin: 15% auto; | ||
padding: 20px; | ||
border: 1px solid #888; | ||
width: 80%; | ||
} | ||
.close-button { | ||
color: #aaa; | ||
float: right; | ||
font-size: 28px; | ||
font-weight: bold; | ||
} | ||
.close-button:hover, | ||
.close-button:focus { | ||
color: black; | ||
text-decoration: none; | ||
cursor: pointer; | ||
} | ||
.error-message { | ||
display: block; | ||
color: red; | ||
} | ||
</style> | ||
|
||
{% endblock %} | ||
|
||
{% block extra_js %} | ||
{{ block.super }} | ||
<script> | ||
document.addEventListener('DOMContentLoaded', function() { | ||
document.getElementById('invite-admin-button').onclick = function() { | ||
document.getElementById('invite-admin-modal').style.display = 'block'; | ||
resetErrorMessages(); | ||
}; | ||
|
||
document.getElementById('close-modal').onclick = function() { | ||
document.getElementById('invite-admin-modal').style.display = 'none'; | ||
}; | ||
|
||
document.getElementById('invite-admin-form').onsubmit = function(event) { | ||
event.preventDefault(); | ||
resetErrorMessages(); | ||
|
||
const firstName = document.getElementById('first_name').value; | ||
const lastName = document.getElementById('last_name').value; | ||
const email = document.getElementById('email').value; | ||
|
||
let isValid = true; | ||
|
||
if (firstName.trim() === "") { | ||
document.getElementById('first_name_error').textContent = "First Name is required."; | ||
document.getElementById('first_name_error').style.display = 'block'; | ||
isValid = false; | ||
} | ||
if (lastName.trim() === "") { | ||
document.getElementById('last_name_error').textContent = "Last Name is required."; | ||
document.getElementById('last_name_error').style.display = 'block'; | ||
isValid = false; | ||
} | ||
if (!validateEmail(email)) { | ||
document.getElementById('email_error').textContent = "Please enter a valid email address."; | ||
document.getElementById('email_error').style.display = 'block'; | ||
isValid = false; | ||
} | ||
|
||
if (isValid) { | ||
const formData = new FormData(this); | ||
|
||
fetch("{% url 'invite_admin_user' %}", { | ||
method: 'POST', | ||
body: formData, | ||
headers: { | ||
'X-Requested-With': 'XMLHttpRequest' | ||
} | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
if (data.success) { | ||
document.getElementById('invite-admin-modal').style.display = 'none'; | ||
this.reset(); | ||
} else { | ||
for (const [key, value] of Object.entries(data.errors)) { | ||
document.getElementById(key + '_error').textContent = value; | ||
document.getElementById(key + '_error').style.display = 'block'; | ||
} | ||
} | ||
}) | ||
.catch(error => console.error('Error:', error)); | ||
} | ||
}; | ||
|
||
function validateEmail(email) { | ||
const re = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/; | ||
return re.test(String(email).toLowerCase()); | ||
} | ||
|
||
function resetErrorMessages() { | ||
document.getElementById('first_name_error').textContent = ''; | ||
document.getElementById('last_name_error').textContent = ''; | ||
document.getElementById('email_error').textContent = ''; | ||
} | ||
}); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from django.urls import path | ||
from iogt_users.views import UserDetailEditView, UserDetailView | ||
from iogt_users.views import UserDetailEditView, UserDetailView, InviteAdminUserView | ||
|
||
urlpatterns = [ | ||
path('profile/', UserDetailView.as_view(), name='user_profile'), | ||
path('profile/edit', UserDetailEditView.as_view(), name='user_profile_edit'), | ||
path('invite-admin-user/', InviteAdminUserView.as_view(), name='invite_admin_user'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters