Changeset - 39b556b7ac4f
[Not reviewed]
pinaxcon/csrf_view.py
Show inline comments
 
from django.conf import settings
 
from django.http import HttpResponseForbidden
 
from django.shortcuts import redirect
 
from django.template import Context, RequestContext, loader
 
from django.utils.translation import ugettext as _
 
from django.utils.version import get_docs_version
 

	
 

	
 
def csrf_failure(request, reason=""):
 

	
 
    from django.middleware.csrf import REASON_BAD_TOKEN, REASON_NO_REFERER, REASON_NO_CSRF_COOKIE
 
    t = loader.get_template("403_csrf.html")
 
    c = Context({
 
        'title': _("Forbidden"),
pinaxcon/disable_cscache.py
Show inline comments
 
from django.utils.cache import add_never_cache_headers
 

	
 

	
 
class DisableClientSideCachingMiddleware(object):
 
    def process_response(self, request, response):
 
        add_never_cache_headers(response)
 
        return response
 

	
pinaxcon/monkey_patch.py
Show inline comments
 
from django.conf import settings
 
from django.core.mail import EmailMultiAlternatives
 
from django.core.mail import EmailMultiAlternatives  # noqa: F401
 
from functools import wraps
 

	
 

	
 
class MonkeyPatchMiddleware(object):
 
    ''' Ensures that our monkey patching only gets called after it is safe to do so.'''
 

	
...
 
@@ -16,13 +16,13 @@ def do_monkey_patch():
 
    fix_sitetree_check_access_500s()
 
    never_cache_login_page()
 
    patch_stripe_payment_form()
 

	
 
    # Remove this function from existence
 
    global do_monkey_patch
 
    do_monkey_patch = lambda: None
 
    do_monkey_patch = lambda: None  # noqa: E731
 

	
 

	
 
def patch_speaker_profile_form():
 
    ''' Replaces textarea widgets with markdown editors. '''
 

	
 
    import widgets
...
 
@@ -31,13 +31,13 @@ def patch_speaker_profile_form():
 
    fields = SpeakerForm.base_fields
 
    fields["biography"].widget = widgets.AceMarkdownEditor()
 
    fields["experience"].widget = widgets.AceMarkdownEditor()
 
    fields["accessibility"].widget = widgets.AceMarkdownEditor()
 

	
 

	
 
def patch_mail_to_send_bcc():
 
def patch_mail_to_send_bcc():  # noqa: C901
 
    ''' Patches django.core.mail's message classes to send a BCC e-mail to
 
    the default BCC e-mail address. '''
 

	
 
    from django.core.mail import message
 

	
 
    ARG = "bcc"
...
 
@@ -77,13 +77,12 @@ def patch_mail_to_send_bcc():
 
            bcc = []
 

	
 
        bcc += bcc_email
 

	
 
        return tuple(a[:pos] + (bcc,) + a[pos + 1:])
 

	
 

	
 
    def patch_bcc_keyword(f, k):
 
        ''' Adds our BCC list to the BCC list in the keyword arguments, and
 
        returns the new version of the keyword arguments.
 

	
 
        Arguments:
 
            f (callable): The function that we're patching. It should have an
...
 
@@ -136,19 +135,20 @@ def fix_sitetree_check_access_500s():
 
            return old_check_access(self, *a, **k)
 
        except KeyError:
 
            return False
 

	
 
    SiteTree.check_access = check_access
 

	
 

	
 
def never_cache_login_page():
 
    from django.views.decorators.cache import never_cache
 
    from account.views import LoginView
 
    LoginView.get = never_cache(LoginView.get)
 

	
 

	
 
def patch_stripe_payment_form():
 
def patch_stripe_payment_form():  # noqa: C901
 

	
 
    import inspect  # Oh no.
 
    from django.http.request import HttpRequest
 
    from registripe.forms import CreditCardForm
 
    from pinaxcon.registrasion import models
 

	
pinaxcon/proposals/admin.py
Show inline comments
...
 
@@ -15,13 +15,12 @@ from symposion.proposals import models as symposion_models
 
@admin.register(models.KernelProposal)
 
@admin.register(models.GamesProposal)
 
@admin.register(models.TestingProposal)
 
@admin.register(models.KnowledgeProposal)
 
@admin.register(models.LawProposal)
 
@admin.register(models.OpenHardwareProposal)
 

	
 
class CategoryAdmin(admin.ModelAdmin):
 

	
 
    class AdditionalSpeakerInline(admin.TabularInline):
 
        model = symposion_models.AdditionalSpeaker
 

	
 
    inlines = [
pinaxcon/proposals/forms.py
Show inline comments
...
 
@@ -5,12 +5,13 @@ from pinaxcon import widgets
 
from .models import TalkProposal, TutorialProposal, MiniconfProposal
 
from .models import SysAdminProposal, WriteTheDocsProposal, WootconfProposal
 
from .models import KernelProposal, OpenRadioProposal, SecurityProposal
 
from .models import GamesProposal, TestingProposal, LawProposal, OpenHardwareProposal
 
from .models import KnowledgeProposal
 

	
 

	
 
class ProposalForm(forms.ModelForm):
 

	
 
    def clean_description(self):
 
        value = self.cleaned_data["description"]
 
        if len(value) > 400:
 
            raise forms.ValidationError(
...
 
@@ -81,12 +82,13 @@ class MiniconfProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class SysAdminProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = SysAdminProposal
 
        fields = [
 
            "title",
...
 
@@ -104,12 +106,13 @@ class SysAdminProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class WriteTheDocsProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = WriteTheDocsProposal
 
        fields = [
 
            "title",
...
 
@@ -127,12 +130,13 @@ class WriteTheDocsProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class RadioProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = OpenRadioProposal
 
        fields = [
 
            "title",
...
 
@@ -149,12 +153,13 @@ class RadioProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class KernelProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = KernelProposal
 
        fields = [
 
            "title",
...
 
@@ -171,12 +176,13 @@ class KernelProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class WootconfProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = WootconfProposal
 
        fields = [
 
            "title",
...
 
@@ -193,12 +199,13 @@ class WootconfProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class SecurityProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = SecurityProposal
 
        fields = [
 
            "title",
...
 
@@ -215,12 +222,13 @@ class SecurityProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class GamesProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = GamesProposal
 
        fields = [
 
            "title",
...
 
@@ -238,12 +246,13 @@ class GamesProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class TestingProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = TestingProposal
 
        fields = [
 
            "title",
...
 
@@ -260,12 +269,13 @@ class TestingProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class KnowledgeProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = KnowledgeProposal
 
        fields = [
 
            "title",
...
 
@@ -282,12 +292,13 @@ class KnowledgeProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class LawProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = LawProposal
 
        fields = [
 
            "title",
...
 
@@ -304,12 +315,13 @@ class LawProposalForm(ProposalForm):
 
        widgets = {
 
            "abstract": widgets.AceMarkdownEditor(),
 
            "private_abstract": widgets.AceMarkdownEditor(),
 
            "technical_requirements": widgets.AceMarkdownEditor(),
 
        }
 

	
 

	
 
class OpenHardwareProposalForm(ProposalForm):
 

	
 
    class Meta:
 
        model = OpenHardwareProposal
 
        fields = [
 
            "title",
pinaxcon/proposals/models.py
Show inline comments
...
 
@@ -42,38 +42,43 @@ class Proposal(ProposalBase):
 

	
 
class TalkProposal(Proposal):
 

	
 
    class Meta:
 
        verbose_name = "talk proposal"
 

	
 

	
 
class TutorialProposal(Proposal):
 

	
 
    class Meta:
 
        verbose_name = "tutorial proposal"
 

	
 

	
 
class MiniconfProposal(ProposalBase):
 

	
 
    class Meta:
 
        verbose_name = "miniconf proposal"
 

	
 

	
 
class SysAdminProposal(Proposal):
 

	
 
    TYPE_SHORT_PRESENTATION = 1
 
    TYPE_LIGHTNING_TALK = 2
 

	
 
    TALK_FORMATS = [
 
        (TYPE_SHORT_PRESENTATION, "Short Presentation (15-25 min)"),
 
        (TYPE_LIGHTNING_TALK, "Lightning Talk (5-10 min)"),
 
    ]
 

	
 
    talk_format = models.IntegerField(choices=TALK_FORMATS,
 
    talk_format = models.IntegerField(
 
        choices=TALK_FORMATS,
 
        help_text="Please indicate your preferred talk length in the private abstract field below.")
 

	
 
    class Meta:
 
        verbose_name = "System Administration Miniconf Proposal"
 

	
 

	
 
class WriteTheDocsProposal(Proposal):
 

	
 
    TYPE_LONG_PRESENTATION = 1
 
    TYPE_SHORT_PRESENTATION = 2
 

	
 
    TALK_FORMATS = [
...
 
@@ -83,32 +88,37 @@ class WriteTheDocsProposal(Proposal):
 

	
 
    talk_format = models.IntegerField(choices=TALK_FORMATS)
 

	
 
    class Meta:
 
        verbose_name = "WriteThe Docs Miniconf Proposal"
 

	
 

	
 
class OpenRadioProposal(Proposal):
 

	
 
    class Meta:
 
        verbose_name = "OpenRadio Miniconf Proposal"
 

	
 

	
 
class WootconfProposal(Proposal):
 

	
 
    class Meta:
 
        verbose_name = "WOOTCONF Miniconf Proposal"
 

	
 

	
 
class KernelProposal(Proposal):
 

	
 
    class Meta:
 
        verbose_name = "Kernel Miniconf Proposal"
 

	
 

	
 
class SecurityProposal(Proposal):
 

	
 
    class Meta:
 
        verbose_name = "Security/Privacy Miniconf Proposal"
 

	
 

	
 
class GamesProposal(Proposal):
 

	
 
    TYPE_PRESENTATION = 1
 
    TYPE_DEMONSTRATION = 2
 
    TYPE_OTHER = 3
 

	
...
 
@@ -120,27 +130,31 @@ class GamesProposal(Proposal):
 

	
 
    talk_format = models.IntegerField(choices=TALK_FORMATS)
 

	
 
    class Meta:
 
        verbose_name = "Games and FOSS Miniconf Proposal"
 

	
 

	
 
class TestingProposal(Proposal):
 

	
 
    class Meta:
 
        verbose_name = "Testing/Automation Miniconf Proposal"
 

	
 

	
 
class KnowledgeProposal(Proposal):
 

	
 
    class Meta:
 
        verbose_name = "Open Knowledge Australia Miniconf Proposal"
 

	
 

	
 
class LawProposal(Proposal):
 

	
 
    class Meta:
 
        verbose_name = "Open Law and Policy Miniconf Proposal"
 

	
 

	
 
class OpenHardwareProposal(Proposal):
 

	
 
    TYPE_NORMAL_PRESENTATION = 1
 
    TYPE_LIGHTNING_TALK = 2
 

	
 
    TALK_FORMATS = [
pinaxcon/registrasion/forms.py
Show inline comments
...
 
@@ -25,9 +25,8 @@ class ProfileForm(forms.ModelForm):
 
            "of_legal_age": YesNoField,
 
        }
 
        widgets = {
 
            "past_lca": forms.widgets.CheckboxSelectMultiple(),
 
        }
 

	
 

	
 
    class Media:
 
        js = ("lca2017/js/profile_form.js", )
pinaxcon/registrasion/management/commands/populate_inventory.py
Show inline comments
 
from collections import namedtuple
 
from datetime import datetime
 
from datetime import timedelta
 
from decimal import Decimal
 
from django.contrib.auth.models import Group
 
from django.core.exceptions import ObjectDoesNotExist
 
from django.core.management.base import BaseCommand, CommandError
 
from django.core.management.base import BaseCommand
 

	
 
from registrasion.models import inventory as inv
 
from registrasion.models import conditions as cond
 
from symposion import proposals
 

	
 

	
 
class Command(BaseCommand):
 

	
 
    help = 'Populates the inventory with the LCA2017 inventory model'
 

	
 
    def add_arguments(self, parser):
 
        pass
 

	
 
    def handle(self, *args, **options):
pinaxcon/registrasion/views.py
Show inline comments
 
from django.conf import settings
 
from django.contrib.auth.decorators import login_required
 
from django.contrib import messages
 
from django.core.exceptions import ObjectDoesNotExist
 
from django.core.exceptions import ValidationError
 
from django.http import Http404
 
from django.shortcuts import get_object_or_404
 
from django.shortcuts import redirect
 
from django.shortcuts import render
 

	
 
from registrasion import models as rego
 
from registrasion.controllers.invoice import InvoiceController
 

	
 
import models
 

	
pinaxcon/settings.py
Show inline comments
 
import os
 
import dj_database_url
 
from django.utils.crypto import get_random_string
 

	
 

	
 
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
 
PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__))
 
BASE_DIR = PACKAGE_ROOT
...
 
@@ -305,9 +304,9 @@ NOSE_ARGS = [
 

	
 
# Production settings have their own file to override stuff here
 
try:
 
    LOCAL_SETTINGS
 
except NameError:
 
    try:
 
        from local_settings import *
 
        from local_settings import *  # noqa: F401,F403
 
    except ImportError:
 
        pass
pinaxcon/templatetags/lca2017_tags.py
Show inline comments
 
import cms_pages
 
import hashlib
 
import urllib
 

	
 
from decimal import Decimal
 
from django import template
 
from django.conf import settings
 
from django.contrib.staticfiles.templatetags import staticfiles
 
from easy_thumbnails.files import get_thumbnailer
...
 
@@ -52,13 +51,15 @@ def speaker_photo(context, speaker, size):
 
        thumbnail_options = {'crop': True, 'size': (size, size)}
 
        thumbnail = thumbnailer.get_thumbnail(thumbnail_options)
 
        return thumbnail.url
 
    else:
 
        email = speaker.user.email.encode("utf-8")
 
        md5sum = hashlib.md5(email.strip().lower()).hexdigest()
 
        url = "https://secure.gravatar.com/avatar/%s?s=%d&d=%s" % (md5sum, size, "https://linux.conf.au/site_media/static/lca2017/images/speaker-fallback-devil.jpg")
 
        fallback_image = ("https://linux.conf.au/site_media/static/lca2017"
 
                          "/images/speaker-fallback-devil.jpg")
 
        url = "https://secure.gravatar.com/avatar/%s?s=%d&d=%s" % (md5sum, size, fallback_image)
 

	
 
        return url
 

	
 

	
 
@register.simple_tag()
 
def define(value):
...
 
@@ -91,12 +92,13 @@ def gst(amount):
 

	
 

	
 
@register.simple_tag()
 
def conference_name():
 
    return conference_models.Conference.objects.get(id=CONFERENCE_ID).title
 

	
 

	
 
@register.filter()
 
def trackname(room, day):
 
    try:
 
        track_name = room.track_set.get(day=day).name
 
    except Track.DoesNotExist:
 
        track_name = None
pinaxcon/templatetags/pyconau2017_tags.py
Show inline comments
 
import cms_pages
 
import hashlib
 
import urllib
 

	
 
import os
 

	
 
from decimal import Decimal
 
from django import template
 
from django.conf import settings
...
 
@@ -54,13 +53,15 @@ def speaker_photo(context, speaker, size):
 
        thumbnail_options = {'crop': True, 'size': (size, size)}
 
        thumbnail = thumbnailer.get_thumbnail(thumbnail_options)
 
        return thumbnail.url
 
    else:
 
        email = speaker.user.email.encode("utf-8")
 
        md5sum = hashlib.md5(email.strip().lower()).hexdigest()
 
        url = "https://secure.gravatar.com/avatar/%s?s=%d&d=%s" % (md5sum, size, "https://2017.pycon-au.org/site_media/static/pyconau23017/images/speaker-fallback-devil.jpg")
 
        fallback_image = ("https://2017.pycon-au.org/site_media/static"
 
                          "/pyconau23017/images/speaker-fallback-devil.jpg")
 
        url = "https://secure.gravatar.com/avatar/%s?s=%d&d=%s" % (md5sum, size, fallback_image)
 

	
 
        return url
 

	
 

	
 
@register.simple_tag()
 
def define(value):
...
 
@@ -93,22 +94,23 @@ def gst(amount):
 

	
 

	
 
@register.simple_tag()
 
def conference_name():
 
    return conference_models.Conference.objects.get(id=CONFERENCE_ID).title
 

	
 

	
 
@register.filter()
 
def trackname(room, day):
 
    try:
 
        track_name = room.track_set.get(day=day).name
 
    except Track.DoesNotExist:
 
        track_name = None
 
    return track_name
 

	
 

	
 
@register.simple_tag()
 
def sponsor_thumbnail(sponsor_logo):
 
    if sponsor_logo is not None:
 
        if sponsor_logo.upload:
 
            logo_file = os.path.join(settings.MEDIA_URL, str(sponsor_logo.upload))
 
            return logo_file
 

	
 
    return ""
pinaxcon/urls.py
Show inline comments
 
from django.conf import settings
 
from django.conf.urls import patterns, include, url
 
from django.conf.urls import include, url
 
from django.conf.urls.static import static
 
from django.views.generic import TemplateView
 

	
 
from wagtail.wagtailadmin import urls as wagtailadmin_urls
 
from wagtail.wagtailcore import urls as wagtail_urls
 

	
 
from django.contrib import admin
 

	
 
import symposion.views
 

	
 

	
 

	
 
import sys
 

	
 
urlpatterns = [
 
    url(r"^admin/", include(admin.site.urls)),
 

	
 
    url(r"^account/", include("account.urls")),
 

	
 
    url(r"^dashboard/", symposion.views.dashboard, name="dashboard"),
pinaxcon/widgets.py
Show inline comments
 
from django import forms
 

	
 

	
 
class AceMarkdownEditor(forms.Textarea):
 

	
 
    def render(self, name, value, attrs):
 
        original = super(AceMarkdownEditor, self).render(name, value, attrs)
 
        ret = '''
 
                %s
0 comments (0 inline, 0 general)