Tuesday & Wednesday work (#30)

* Fixes an incorrect link in dashboard

* Disables the symposion sponsors app

* Adds redirect links for login/logout; adds THEME_CONTACT_EMAIL value

* Re-adds colophon/copyright message.

* Adds AceMarkdownEditor widget

* Tidies up the generated HTML

* Tidies up form snippet behaviour

* Proposals forms now use the markdown editor

* Monkey patches the markdown editor into the speaker form.

* Adds missing field to proposal details

* Fixes #10 — adds a link to random unreviewed proposals

* Minor tweaks
This commit is contained in:
Christopher Neugebauer 2016-06-29 23:17:15 +10:00 committed by Scott Bragg
parent feed83f517
commit 2cdb554623
15 changed files with 172 additions and 20 deletions

25
pinaxcon/monkey_patch.py Normal file
View file

@ -0,0 +1,25 @@
class MonkeyPatchMiddleware(object):
''' Ensures that our monkey patching only gets called after it is safe to do so.'''
def process_request(self, request):
do_monkey_patch()
def do_monkey_patch():
patch_speaker_profile_form()
# Remove this function from existence
global do_monkey_patch
do_monkey_patch = lambda: None
def patch_speaker_profile_form():
''' Replaces textarea widgets with markdown editors. '''
import widgets
from symposion.speakers.forms import SpeakerForm
fields = SpeakerForm.base_fields
fields["biography"].widget = widgets.AceMarkdownEditor()
fields["experience"].widget = widgets.AceMarkdownEditor()
fields["accessibility"].widget = widgets.AceMarkdownEditor()

View file

@ -1,5 +1,7 @@
from django import forms
from pinaxcon import widgets
from .models import TalkProposal, TutorialProposal, MiniconfProposal
@ -31,6 +33,13 @@ class TalkProposalForm(ProposalForm):
"materials_release",
]
widgets = {
"abstract" : widgets.AceMarkdownEditor(),
"private_abstract" : widgets.AceMarkdownEditor(),
"technical_requirements" : widgets.AceMarkdownEditor(),
}
class TutorialProposalForm(ProposalForm):
class Meta:
@ -48,6 +57,13 @@ class TutorialProposalForm(ProposalForm):
"materials_release",
]
widgets = {
"abstract" : widgets.AceMarkdownEditor(),
"private_abstract" : widgets.AceMarkdownEditor(),
"technical_requirements" : widgets.AceMarkdownEditor(),
}
class MiniconfProposalForm(ProposalForm):
class Meta:
@ -58,3 +74,9 @@ class MiniconfProposalForm(ProposalForm):
"private_abstract",
"technical_requirements",
]
widgets = {
"abstract" : widgets.AceMarkdownEditor(),
"private_abstract" : widgets.AceMarkdownEditor(),
"technical_requirements" : widgets.AceMarkdownEditor(),
}

View file

@ -114,6 +114,7 @@ MIDDLEWARE_CLASSES = [
"django.middleware.clickjacking.XFrameOptionsMiddleware",
'wagtail.wagtailcore.middleware.SiteMiddleware',
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
'pinaxcon.monkey_patch.MonkeyPatchMiddleware',
]
ROOT_URLCONF = "pinaxcon.urls"
@ -224,11 +225,13 @@ EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
ACCOUNT_OPEN_SIGNUP = True
ACCOUNT_EMAIL_UNIQUE = True
ACCOUNT_EMAIL_CONFIRMATION_REQUIRED = False
ACCOUNT_LOGIN_REDIRECT_URL = "home"
ACCOUNT_LOGOUT_REDIRECT_URL = "home"
ACCOUNT_LOGIN_REDIRECT_URL = "dashboard"
ACCOUNT_LOGOUT_REDIRECT_URL = "/"
ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 2
ACCOUNT_USE_AUTH_AUTHENTICATE = True
THEME_CONTACT_EMAIL = "team@hobart.lca2017.org"
AUTHENTICATION_BACKENDS = [
"symposion.teams.backends.TeamPermissionsBackend",
"account.auth_backends.UsernameAuthenticationBackend",

View file

@ -3,6 +3,7 @@
{% for field in form %}
{% if not field.is_hidden %}
<div class="fieldWrapper">
<div>
{% classname field.field.widget as widget %}
{% if widget != "CheckboxInput" %}
<h4><label for="{{ field.id_for_label }}">{{ field.label }}</label></h4>
@ -13,11 +14,9 @@
{{ field }}
{{ field.errors }}
{% endif %}
</div>
{% if field.help_text %}
{% if widget != "CheckboxInput" or not field.errors %}
<br />
{% endif %}
<span class="help_text">{{ field.help_text|safe }}</span>
{% endif %}

View file

@ -140,7 +140,7 @@
{% available_teams as available_teams %}
{% if user.memberships.exists or available_teams %}
<div class="panel panel__compact panel__bg">
<div style="background-image: url('{% static "lca2017/images/hobart_bg.jpg" %}');" class="panel--bg"></div>
<div style="background-image: url('{% static "lca2017/images/hobart_bg_optimised.jpg" %}');" class="panel--bg"></div>
<div class="panel--content">
<div class="panel--2-3">
<h2>{% trans "Teams" %}</h2>

View file

@ -46,7 +46,7 @@
<header role="banner" class="l-header">
<div class="l-header--logo">
{% block site_brand %}
<img src="{% static 'lca2017/images/svgs/lca2017-website-logo.svg' %}" width="300px" />
<img src="{% static 'lca2017/images/svgs/lca2017-website-logo.svg' %}" width="100%"/>
{% endblock %}
</div>
{% block nav %}
@ -94,6 +94,9 @@
<div class="l-footer--logos">
<img src="{% static 'lca2017/images/HPE.jpg' %}" role="presentation">
<img src="{% static 'lca2017/images/IBM.jpg' %}" role="presentation"></div>
<p class="lede">© 2016 linux.conf.au 2017 and Linux Australia. Linux is a registered trademark of Linus Torvalds. Site design by <a href="http://takeflight.com.au" >Takeflight</a>. Image credits can be found on our <a href="/about/colophon">Colophon</a>.</p>
{% endblock %}
</footer>
{% endblock %}

View file

@ -13,4 +13,7 @@
{% block scripts %}
<script src="{% static 'lca2017/js/app.js' %}" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script src="{% static 'lca2017/js/load_editors.js' %}" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ace/1.2.3/ace.js"></script>
{% endblock %}

View file

@ -46,6 +46,9 @@
<h4>{% trans "Speaker Experience" %}</h4>
<div class="biography">{{ proposal.speaker.experience_html|safe }}&nbsp;</div>
<h4>{% trans "Speaker Accessibility Requirements" %}</h4>
<div class="biography">{{ proposal.speaker.accessibility_html|safe }}&nbsp;</div>
<h4>{% trans "Documents" %}</h4>
<div>
{% if proposal.supporting_documents.exists %}

View file

@ -76,9 +76,15 @@
</a>
</li>
{% endcomment %}
<a class="list-group-item user-reviewed" href="{% url "user_reviewed" section.section.slug %}">
{% trans "Reviewed by you" %}
</a>
<a class="list-group-item user-not-reviewed" href="{% url "user_not_reviewed" section.section.slug %}">
{% trans "Unreviewed by you" %}
</a>
<a class="list-group-item user-random" href="{% url "user_random" section.section.slug %}">
{% trans "Random unreviewed proposal" %}
</a>
<a class="list-group-item voting-status" href="{% url "review_status" section.section.slug %}">
{% trans "Voting Status" %}
</a>

View file

@ -6,6 +6,13 @@
{% block body %}
<div>
<a class="btn btn-primary" href="{% url "user_random" proposal.section.slug %}">
{% trans "Jump to a random unreviewed proposal" %}
</a>
</div>
{% if is_manager %}
<div class="pull-right">
<form class="result-form form-inline" method="POST" action="">
@ -165,6 +172,13 @@
</div>
</div>
</div>
<div>
<a class="btn btn-primary" href="{% url "user_random" proposal.section.slug %}">
{% trans "Jump to a random unreviewed proposal" %}
</a>
</div>
{% endblock %}
{% block extra_script %}

View file

@ -1,7 +1,11 @@
{% extends "symposion/reviews/base.html" %}
{% block body_class %}{{ block.super }} review-list{% endblock %}
{% block body_class %}{{ block.super }}
{% if reviewed == "all_reviews" %}
review-list
{% endif %}
{% endblock %}
{% block body %}
<h3>{{ section }}</h3>

View file

@ -21,7 +21,7 @@ urlpatterns = [
url(r"^speaker/", include("symposion.speakers.urls")),
url(r"^proposals/", include("symposion.proposals.urls")),
url(r"^sponsors/", include("symposion.sponsorship.urls")),
#url(r"^sponsors/", include("symposion.sponsorship.urls")),
url(r"^reviews/", include("symposion.reviews.urls")),
url(r"^schedule/", include("symposion.schedule.urls")),

16
pinaxcon/widgets.py Normal file
View file

@ -0,0 +1,16 @@
from django import forms
class AceMarkdownEditor(forms.Textarea):
def render(self, name, value, attrs):
original = super(AceMarkdownEditor, self).render(name, value, attrs)
ret = '''
%s
<script>
window.addEventListener("load", () => {
editor = loadEditor("%s");
}, 0);
</script>
''' % (original, attrs["id"])
return ret

View file

@ -1187,6 +1187,7 @@ table.alt tr:not(:last-of-type) {
-ms-flex-item-align: start;
align-self: flex-start;
display: none;
margin-left: 1em;
}
.l-header--menu-opener {

View file

@ -0,0 +1,53 @@
function setupEditor(editor, textarea) {
const session = editor.getSession();
//editor.setTheme('ace/theme/tomorrow');
editor.$blockScrolling = Infinity;
editor.setOption('scrollPastEnd', false);
session.setMode('ace/mode/markdown');
session.setValue(textarea.val());
session.setUseWrapMode(true);
session.on('change', () => {
textarea.val(session.getValue());
});
editor.renderer.setShowGutter(true);
session.setTabSize(4);
session.setUseSoftTabs(true);
}
function setEditorSize(reportDiv, textArea)
{
var w = textArea.width();
var h = textArea.height();
var border = textArea.css("border");
reportDiv.width(w);
reportDiv.height(h);
reportDiv.css("position", "relative");
reportDiv.css("border", border);
textArea.css("display", "none");
}
function loadEditor(id) {
var i = id;
var el = `#${i}`;
const editorId = `markdown-editor-${i}`;
const reportDiv = $('<div>').attr('id', editorId);
const $formGroup = $(el).closest('.form-group');
const $textarea = $(el);
$textarea.after(reportDiv);
editor = ace.edit(editorId);
setupEditor(editor, $textarea);
$textarea.resize(() => {
setEditorSize(reportDiv, $textarea);
editor.resize();
});
$textarea.resize();
return editor;
}