-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# This is a combination of 11 commits.
# This is the 1st commit message: wooo Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com> # This is the commit message #2: moving computers Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com> # This is the commit message #3: v1 complete Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com> # This is the commit message #4: documentation Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com> # This is the commit message #5: code cleanup and minor bug fixes Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com> # This is the commit message #6: progress Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com> # This is the commit message #7: finish feature Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com> # This is the commit message #8: cleanup and help text Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com> # This is the commit message #9: working wiki integration Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com> # This is the commit message #10: wiki branding Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com> # This is the commit message #11: documentation Signed-off-by: Joe Kaufeld <joe.kaufeld@gmail.com>
- Loading branch information
Joe Kaufeld
committed
May 14, 2021
1 parent
f9917a9
commit cec5500
Showing
16 changed files
with
407 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,3 +106,4 @@ venv.bak/ | |
static/ | ||
.idea/* | ||
*/migrations/* | ||
*/media/wiki/* |
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,9 @@ | ||
POSTGRES_USER=blossom_app | ||
POSTGRES_PASSWORD=asdfasdfasdf | ||
POSTGRES_DB=blossom | ||
|
||
REDDIT_CLIENT_ID=jmeW7q3nt6NeSg | ||
REDDIT_SECRET=ebBPZ2RNDaVzbBHHuk4xpyJTffU | ||
REDDIT_USERNAME=blossom-app | ||
REDDIT_PASSWORD=60pNPq0E%J$htOC!49UZ | ||
REDDIT_USER_AGENT="Blossom:/r/transcribersofreddit. Contact /u/itsthejoker" |
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,78 @@ | ||
from django.contrib.auth import login, logout | ||
from django.shortcuts import render, HttpResponseRedirect | ||
from django.urls import resolve | ||
from django.urls.exceptions import Resolver404, NoReverseMatch | ||
from django.urls.resolvers import get_resolver | ||
from django.views.generic import TemplateView | ||
from django_hosts.resolvers import get_host_patterns, reverse | ||
|
||
from blossom.authentication.custom_auth import EmailBackend | ||
from blossom.website.forms import LoginForm | ||
|
||
|
||
class LoginView(TemplateView): | ||
|
||
def get_redirect(self, request, hosts): | ||
# work around a super obnoxious problem with django-hosts where if it | ||
# doesn't find the url that you're looking for in the default host, | ||
# it just gives up. This will allow us to cycle through the hosts and | ||
# try to find one that returns a ResolverMatch. | ||
|
||
# first let's see if the requested url DOES resolve in the base host. | ||
nextpath = request.GET['next'] | ||
try: | ||
match = resolve(nextpath) | ||
try: | ||
return reverse(match.view_name) | ||
except NoReverseMatch: | ||
pass | ||
except Resolver404: | ||
pass | ||
|
||
for h in hosts: | ||
try: | ||
match = get_resolver(h.urlconf).resolve(nextpath) | ||
try: | ||
return reverse(match.view_name, host=match.namespace) | ||
except NoReverseMatch: | ||
continue | ||
except Resolver404: | ||
continue | ||
|
||
# still haven't found a match? The only thing left is that it's really | ||
# borked or it's a full url to something like the wiki. | ||
if nextpath.endswith( | ||
request.get_host() | ||
) or nextpath.endswith( | ||
request.get_host() + '/' | ||
): | ||
return nextpath | ||
|
||
raise Resolver404 | ||
|
||
def get(self, request, *args, **kwargs): | ||
form = LoginForm() | ||
return render(request, 'website/generic_form.html', {'form': form}) | ||
|
||
def post(self, request, *args, **kwargs): | ||
form = LoginForm(request.POST) | ||
if form.is_valid(): | ||
data = form.cleaned_data | ||
if user := EmailBackend().authenticate( | ||
username=data.get('email'), password=data.get('password') | ||
): | ||
login(request, user) | ||
|
||
if request.GET.get('next', None): | ||
hosts = get_host_patterns() | ||
location = self.get_redirect(request, hosts) | ||
else: | ||
location = '/' | ||
|
||
return HttpResponseRedirect(location) | ||
return HttpResponseRedirect('/') | ||
|
||
|
||
def LogoutView(request): | ||
logout(request) | ||
return HttpResponseRedirect('/') |
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 @@ | ||
# This folder is used by the wiki to hold user-uploaded content. |
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,19 @@ | ||
{% extends "wiki/base_site.html" %} | ||
{% load hosts %} | ||
|
||
{% block wiki_site_title %} - Wiki{% endblock %} | ||
|
||
{% block wiki_header_branding %} | ||
<a class="navbar-brand" href="/">Grafeas Group, Ltd.</a> | ||
{% endblock %} | ||
|
||
{% block wiki_header_navlinks %} | ||
<ul class="nav navbar-nav"> | ||
<li class="active"><a href="{% url 'wiki:root' %}">Wiki</a></li> | ||
</ul> | ||
<ul class="nav navbar-nav"> | ||
<li> | ||
<a href="{% host_url 'homepage' host 'www' %}">Home</a> | ||
</li> | ||
</ul> | ||
{% 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
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.