forked from Bilgecrank/hindsite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/development' into development
- Loading branch information
Showing
19 changed files
with
516 additions
and
143 deletions.
There are no files selected for viewing
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
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
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,49 @@ | ||
""" | ||
Allows the user to search for other users and send invites, while displaying user cards | ||
for all users who belong to the current group. | ||
""" | ||
from app.hindsite.extensions import db | ||
from app.hindsite.common_model import get_user, get_group | ||
from app.hindsite.tables import User, Membership | ||
|
||
class UserSearchError(Exception): | ||
""" | ||
Definition for errors raised by the login function | ||
""" | ||
|
||
message = None | ||
|
||
def __init__(self, message): | ||
self.message = message | ||
|
||
def get_users(term: str): | ||
""" | ||
Gets a single user record. | ||
:param email: **str** Email to check against the database | ||
:returns: **User** or **None** | ||
""" | ||
users = None | ||
if term is not None: | ||
users = db.session.query(User) \ | ||
.filter(User.display_name.icontains(term) \ | ||
| User.email.icontains(term) \ | ||
| User.first_name.icontains(term) \ | ||
| User.last_name.icontains(term)) | ||
return users | ||
|
||
def send_invitation(group_id: int, email: str): | ||
""" | ||
Creates a Membership that signals an invitation to a user, by default the membership | ||
is not an ownership membership and will have <code>invitation_accepted</code> set to False | ||
:param group_id: The id of the group attached to the membership. | ||
:param email: The email of the user to be added to the membership. | ||
:returns: **Membership** A reference to the membership object. | ||
""" | ||
user = get_user(email) | ||
group = get_group(group_id) | ||
membership = Membership(user, group) | ||
db.session.add(membership) | ||
db.session.commit() | ||
return membership |
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,18 +1,24 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
|
||
<div class="card m-5"> | ||
<div class="card-body"> | ||
<h5 class="card-title">Hello Authenticated User</h5> | ||
<p class="card-text"> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. | ||
Fuga reprehenderit molestiae, vel corporis tempore ipsa mollitia! | ||
Consectetur officiis magni ullam dolores corrupti porro eaque esse. | ||
Illum repudiandae quidem commodi accusamus! | ||
</p> | ||
<a href="{{ url_for('group.group_page')}}" class="btn btn-primary">HOME</a> | ||
</div> | ||
<div class="container-fluid w-100 p-5"> | ||
<h5 class="h-5">Search for users to invite</h5> | ||
<input class="form-control-lg" type="search" | ||
name="search" placeholder="Begin Typing to Search..." | ||
hx-post="/search-users" | ||
hx-trigger="input changed delay:300ms, search" | ||
hx-target="#search-results" | ||
hx-indicator=".htmx-indicator"> | ||
</input> | ||
<div class="htmx-indicator text-dark"> | ||
<img alt="Loading..." | ||
src="{{url_for('static', filename='img/three-dots.svg')}}"> | ||
Searching... | ||
</div> | ||
</div> | ||
<div id="search-results" class="container-sm"> | ||
</div> | ||
<div class="container-sm" id="invite-code"> | ||
|
||
</div> | ||
{% 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div class="container-fluid m-0 dropdown-center" id="content"> | ||
<button class="btn btn-secondary container-fluid m-0 dropdown-toggle" | ||
type="button" | ||
id="groupDropDown" | ||
data-bs-toggle="dropdown" | ||
aria-expanded="false"> | ||
{{ selected }} | ||
</button> | ||
<ul id="group-dropdown" class="dropdown-menu dropdown-menu-dark container-sm text-center" aria-labelledby="groupDropDown"> | ||
{% for group in groups %} | ||
<li> | ||
<form> | ||
<a class="dropdown-item" | ||
href="#" | ||
hx-post="/home?groupname={{ group.name }}" | ||
hx-target="#content"> | ||
{{ group.name }} | ||
</a> | ||
</form> | ||
</li> | ||
{% endfor %} | ||
|
||
<li> | ||
<span class="container-fluid d-flex align-items-center"> | ||
<a class="dropdown-item" | ||
href="#" | ||
hx-get="/modal" | ||
hx-target="#modal" | ||
hx-trigger="click" | ||
data-bs-toggle="modal" | ||
data-bs-target="#modal"> | ||
<img | ||
class="img-fluid" | ||
height="50" | ||
width="50" | ||
src="{{ url_for('static', filename='img/plus.svg') }}"> | ||
</img> | ||
</a> | ||
</span> | ||
</li> | ||
</ul> | ||
</div> |
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,27 @@ | ||
<div class="overflow-auto w-30 text-light"> | ||
{% if users != "" %} | ||
{% for user in users %} | ||
<div class="content-sm bg-secondary"> | ||
<div class="btn btn-secondary w-100 d-flex justify-content-between align-items-center"> | ||
<p class="px-5 py-1 text-align-center"> | ||
{{ user.email }} | ||
</p> | ||
<p class="px-5 py-1 text-align-center"> | ||
{{ user.display_name }} | ||
</p> | ||
<a href="#" class="px-5 py-1 btn btn-light" | ||
hx-post="/send-invite?user={{ user.email }}" | ||
hx-target="#invite-code"> | ||
Send Invite | ||
<img | ||
class="img-fluid" | ||
height="25" | ||
width="25" | ||
src="{{ url_for('static', filename='img/plus.svg') }}"> | ||
</img> | ||
</a> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
{% endif %} | ||
</div> |
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
Oops, something went wrong.