Changeset - 539fa2dfdd2b
[Not reviewed]
make_dev_container.sh
Show inline comments
 
#!/bin/bash -x
 

	
 
IMAGE_NAME=${1:-symposion_app}
 

	
 
if [ -e ./symposion-tools ]; then
 
    pushd ./symposion-tools
 
    ./save_db_from_docker.sh
 
    popd
 
fi
 

	
 
docker image build -f docker/Dockerfile -t ${IMAGE_NAME} --target symposion_dev .
 
docker container stop symposion
 
docker container rm symposion
 
docker container create --env-file docker/laptop-mode-env -p 28000:8000 -v $(pwd):/app/symposion_app --name symposion ${IMAGE_NAME}
 
docker container start symposion
 
## When we started the container and mounted . into /app/symposion_app, it hides the static/build directory
 
## As a kludge, re-run collectstatic to recreate it
 
## Possible alternative here: don't mount all of ., just mount the bits that we'd live to have update live
 
docker exec symposion ./manage.py collectstatic --noinput -v 0
 
docker exec symposion ./manage.py migrate
 
docker exec symposion ./manage.py loaddata ./fixtures/{conference,sites,sitetree,flatpages}.json
 
docker exec symposion ./manage.py create_review_permissions
 
docker exec symposion ./manage.py loaddata ./fixtures/????/*.json
 
#docker exec symposion ./manage.py populate_inventory
 
docker exec symposion ./manage.py populate_inventory
 

	
 
if [ -e ./symposion-tools ]; then
 
    pushd ./symposion-tools
 
    ./fixture_to_docker.sh fixtures/dev_dummy_superuser.json
 
    ./fixture_to_docker.sh fixtures/????_*.json
 
    popd
 
else
 
    echo Now creating a Django superuser. Please enter a
 
    docker exec -it symposion ./manage.py createsuperuser --username admin1 --email root@example.com
 
fi
 

	
 
set +x
 
echo "Now you can log into http://localhost:28000/admin"
 
echo "Username: admin1      Password: the one you just typed twice"
 
echo "If you need to test as a non-admin user, create one at"
 
echo "http://localhost:28000/admin/auth/user/add/ - then log out"
 
echo "and log back in at http://localhost:28000"
 

	
pinaxcon/registrasion/management/commands/populate_inventory.py
Show inline comments
 
from collections import namedtuple
 
from datetime import timedelta
 
from decimal import Decimal
 
from django.conf import settings
 
from django.contrib.auth.models import Group
 
from django.core.exceptions import ObjectDoesNotExist
 
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 tickets and product inventory models'
 
    count = 0
 

	
 
    def add_arguments(self, parser):
 
        pass
 

	
 
    def handle(self, *args, **options):
 

	
 
        kinds = []
 
        for i in ("Talk", "Tutorial", "Miniconf"):
 
            kinds.append(proposals.models.ProposalKind.objects.get(name=i))
 
        self.main_conference_proposals = kinds
 

	
 
        self.populate_groups()
 
        self.populate_inventory()
 
        self.populate_restrictions()
 
        self.populate_discounts()
 

	
 
    def populate_groups(self):
 
        self.group_team = self.find_or_make(
 
            Group,
 
            ("name", ),
 
            name="Conference organisers",
 
        )
 
        self.group_volunteers = self.find_or_make(
 
            Group,
 
            ("name", ),
 
            name="Conference volunteers",
 
        )
 
        self.group_unpublish = self.find_or_make(
 
            Group,
 
            ("name", ),
 
            name="Can see unpublished products",
 
        )
 
        self.group_prepurchase = self.find_or_make(
 
            Group,
 
            ("name", ),
 
            name="Pre-purchase",
 
        )
 

	
 
    def populate_inventory(self):
 
        # Categories
 

	
 
        self.ticket = self.find_or_make(
 
            inv.Category,
 
            ("name",),
 
            name="Ticket",
 
            description="Each type of ticket has different included products. "
 
                        "For details of what products are included, see our "
 
                        "<a href='https://linux.conf.au/attend/tickets/'>registration page</a>",
 
                        "<a href='https://linux.conf.au/attend/tickets/'>registration page</a>.",
 
            required=True,
 
            render_type=inv.Category.RENDER_TYPE_RADIO,
 
            limit_per_user=1,
 
            order=1,
 
        )
 
        self.terms = self.find_or_make(
 
            inv.Category,
 
            ("name",),
 
            name="Terms, Conditions, and Code of Conduct Acceptance",
 
            description="I agree to the "
 
                        "<a href=\"https://linux.conf.au/attend/terms-and-conditions\"> "
 
                        "terms and conditions of attendance</a>, and I have read, "
 
                        "understood, and agree to act according to the standards set "
 
                        "forth in our <a href=\"https://linux.conf.au/attend/code-of-conduct\">"
 
                        "Code of Conduct</a>.",
 
            required=True,
 
            render_type=inv.Category.RENDER_TYPE_CHECKBOX,
 
            order=10,
 
        )
 
        self.penguin_dinner = self.find_or_make(
 
            inv.Category,
 
            ("name",),
 
            name="Penguin Dinner Ticket",
 
            description="Tickets to our conference dinner on the evening of "
 
                        f"{settings.PENGUIN_DINNER_TICKET_DATE: %A %d %B}. "
 
                        "All attendees may purchase "
 
                        "seats at the dinner, even if a dinner ticket is not "
 
                        "included in your conference ticket price.",
 
            required=False,
 
            render_type=inv.Category.RENDER_TYPE_QUANTITY,
 
            limit_per_user=10,
 
            order=20,
 
        )
 
        self.speakers_dinner_ticket = self.find_or_make(
 
            inv.Category,
 
            ("name",),
 
            name="Speakers' Dinner Ticket",
 
            description="Tickets to our exclusive Speakers' Dinner on the "
 
                        "evening of "
 
                        f"{settings.SPEAKER_DINNER_TICKET_DATE: %A %d %B}. "
 
                        "You may purchase up "
 
                        "to 5 tickets in total, for significant others and "
 
                        "family members.",
 
                        f"{settings.SPEAKER_DINNER_TICKET_DATE: %A %d %B}.",
 
            required=False,
 
            render_type=inv.Category.RENDER_TYPE_QUANTITY,
 
            limit_per_user=5,
 
            limit_per_user=1,
 
            order=30,
 
        )
 
        self.pdns_category = self.find_or_make(
 
            inv.Category,
 
            ("name",),
 
            name="Professional Delegates Networking Session Ticket",
 
            description="Tickets to our Professional Delegates Networking session. "
 
                        "This event will be held on the evening of "
 
                        f"{settings.PDNS_TICKET_DATE: %A %d %B} "
 
                        "and is restricted to Professional Ticket "
 
                        "holders, speakers, miniconf organisers, and invited "
 
                        "guests.",
 
            required=False,
 
            render_type=inv.Category.RENDER_TYPE_RADIO,
 
            limit_per_user=1,
 
            order=40,
 
        )
 
        self.t_shirt = self.find_or_make(
 
            inv.Category,
 
            ("name",),
 
            name="Shirt",
 
            description="Commemorative conference polo shirts, featuring the "
 
                        f"linux.conf.au {settings.LCA_START.year} artwork.",
 
            description="Commemorative conference shirts, featuring the "
 
                        f"linux.conf.au {settings.LCA_START.year} artwork. "
 
                        "View the <a href=\"https://linux.conf.au/attend/shirts\">"
 
                        "sizing guide</a>.",
 
            required=False,
 
            render_type=inv.Category.RENDER_TYPE_ITEM_QUANTITY,
 
            order=50,
 
        )
 
        # self.accommodation = self.find_or_make(
 
        #     inv.Category,
 
        #     ("name",),
 
        #     name="Accommodation at University of Tasmania",
 
        #     description="Accommodation at the University of Tasmania colleges "
 
        #                 "and apartments. You can come back and book your "
 
        #                 "accommodation at a later date, provided rooms remain "
 
        #                 "available. Rooms may only be booked from Sunday 15 "
 
        #                 "January--Saturday 21 January. If you wish to stay "
 
        #                 "for only a part of the 6-day period, you must book "
 
        #                 "accommodation for the full 6-day period. Rooms at "
 
        #                 "other hotels, including Wrest Point can be booked "
 
        #                 "elsewhere. For full details, see [LINK]our "
 
        #                 "accommodation page.[/LINK]",
 
        #     required=False,
 
        #     render_type=inv.Category.RENDER_TYPE_RADIO,
 
        #     limit_per_user=1,
 
        #     order=50,
 
        # )
 
        self.extras = self.find_or_make(
 
            inv.Category,
 
            ("name",),
 
            name="Extras",
 
            description="Other items that can improve your conference "
 
                        "experience.",
 
            required=False,
 
            render_type=inv.Category.RENDER_TYPE_QUANTITY,
 
            order=60,
 
        )
 

	
 
        # Tickets
 

	
 
        self.ticket_contributor = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.CONTRIBUTOR.name,
 
            price=settings.CONTRIBUTOR.regular_price,
 
            reservation_duration=hours(24),
 
            order=1,
 
        )
 
        self.ticket_professional = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.PROFESSIONAL.name,
 
            price=settings.PROFESSIONAL.regular_price,
 
            reservation_duration=hours(24),
 
            order=10,
 
        )
 
        self.ticket_hobbyist = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.HOBBYIST.name,
 
            price=settings.HOBBYIST.regular_price,
 
            reservation_duration=hours(24),
 
            order=20,
 
        )
 
        self.ticket_student = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.STUDENT.name,
 
            price=settings.STUDENT.regular_price,
 
            reservation_duration=hours(24),
 
            order=30,
 
        )
 
        self.ticket_miniconfs_mt = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.MINICONF_MT.name,
 
            price=settings.MINICONF_MT.regular_price,
 
            reservation_duration=hours(24),
 
            order=40,
 
        )
 
        self.ticket_miniconfs_mon = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.MINICONF_M.name,
 
            price=settings.MINICONF_M.regular_price,
 
            reservation_duration=hours(24),
 
            order=42,
 
        )
 
        self.ticket_miniconfs_tue = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.MINICONF_MT.name,
 
            price=settings.MINICONF_MT.regular_price,
 
            reservation_duration=hours(24),
 
            order=44,
 
        )
 
        self.ticket_speaker = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.SPEAKER.name,
 
            price=settings.SPEAKER.regular_price,
 
            reservation_duration=hours(24),
 
            order=50,
 
        )
 
        self.ticket_media = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.MEDIA.name,
 
            price=settings.MEDIA.regular_price,
 
            reservation_duration=hours(24),
 
            order=60,
 
        )
 
        self.ticket_sponsor = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.SPONSOR.name,
 
            price=settings.SPONSOR.regular_price,
 
            reservation_duration=hours(24),
 
            order=70,
 
        )
 
        self.ticket_team = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.CONFERENCE_ORG.name,
 
            price=settings.CONFERENCE_ORG.regular_price,
 
            reservation_duration=hours(24),
 
            order=80,
 
        )
 
        self.ticket_volunteer = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.ticket,
 
            name=settings.CONFERENCE_VOL.name,
 
            price=settings.CONFERENCE_VOL.regular_price,
 
            reservation_duration=hours(24),
 
            order=90,
 
        )
 

	
 
        # Agreements
 
        self.accept_terms = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.terms,
 
            name="I Accept",
 
            price=Decimal("00.00"),
 
            reservation_duration=hours(24),
 
            order=10,
 
            limit_per_user=1,
 
        )
 

	
 
        for t in settings.PENGUIN_DINNER.tickets:
 
            self.find_or_make(
 
                inv.Product,
 
                ("name", "category",),
 
                category=self.penguin_dinner,
 
                name=t.name,
 
                description=t.description,
 
                price=t.price,
 
                reservation_duration=t.reservation,
 
                order=t.order()
 
            )
 

	
 
        for t in settings.SPEAKERS_DINNER.tickets:
 
            self.find_or_make(
 
                inv.Product,
 
                ("name", "category",),
 
                category=self.speakers_dinner_ticket,
 
                name=t.name,
 
                description=t.description,
 
                price=t.price,
 
                reservation_duration=t.reservation,
 
                order=t.order()
 
            )
 

	
 
        # PDNS
 

	
 
        self.pdns = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.pdns_category,
 
            name="Conference Attendee",
 
            price=Decimal("00.00"),
 
            reservation_duration=hours(1),
 
            limit_per_user=1,
 
            order=10,
 
        )
 

	
 
        # # Accommodation
 

	
 
        # self.accommodation_week = self.find_or_make(
 
        #     inv.Product,
 
        #     ("name", "category",),
 
        #     category=self.accommodation,
 
        #     name="Single Bedroom with Shared Bathrooms, includes full "
 
        #          "breakfast, Sunday 15 January 2017--Saturday 21 January 2017",
 
        #     price=Decimal("396.00"),
 
        #     reservation_duration=hours(24),
 
        #     limit_per_user=1,
 
        #     order=10,
 
        # )
 

	
 
        # Extras
 

	
 
        self.carbon_offset = self.find_or_make(
 
            inv.Product,
 
            ("name", "category",),
 
            category=self.extras,
 
            name="Offset the carbon pollution generated by your attendance, "
 
                 "thanks to fifteen trees.",
 
            price=Decimal("5.00"),
 
            reservation_duration=hours(1),
 
            order=10,
 
        )
 

	
 
        # Shirts
 
        ShirtGroup = namedtuple("ShirtGroup", ("prefix", "sizes"))
 
        shirt_names = {
 
            "mens": ShirtGroup(
 
                "Men's/Straight Cut",
 
                ("S", "M", "L", "XL", "2XL", "3XL", "4XL"),
 
            "straight": ShirtGroup(
 
                "Straight Cut",
 
                ("S", "M", "L", "XL", "2XL", "3XL", "4XL", "5XL"),
 
            ),
 
            "semi_fitted": ShirtGroup(
 
                "Semi-Fitted",
 
                ("XS", "S", "M", "L", "XL", "2XL"),
 
            ),
 
            "womens": ShirtGroup(
 
                "Women's Classic Fit",
 
                ("8", "10", "12", "14", "16", "18"),
 
            "fitted": ShirtGroup(
 
                "Fitted",
 
                ("XS", "S", "M", "L", "XL", "2XL"),
 
            ),
 
        }
 

	
 
        self.shirts = {}
 
        order = 0
 
        for name, group in shirt_names.items():
 
            self.shirts[name] = {}
 
            prefix = group.prefix
 
            for size in group.sizes:
 
                product_name = "%s %s" % (prefix, size)
 
                order += 10
 
                self.shirts[name][size] = self.find_or_make(
 
                    inv.Product,
 
                    ("name", "category",),
 
                    name=product_name,
 
                    category=self.t_shirt,
 
                    price=settings.TSHIRT_PRICE,
 
                    reservation_duration=hours(1),
 
                    order=order,
 
                )
 

	
 
    def populate_restrictions(self):
 

	
 
        # Hide the products that will eventually need a voucher
 
        hide_voucher_products = self.find_or_make(
 
            cond.GroupMemberFlag,
 
            ("description", ),
 
            description="Can see hidden products",
 
            condition=cond.FlagBase.ENABLE_IF_TRUE,
 
        )
 
        hide_voucher_products.group.set([self.group_unpublish])
 
        hide_voucher_products.products.set([
 
            self.ticket_media,
 
            self.ticket_sponsor,
 
            self.ticket_miniconfs_mt,
 
            self.ticket_miniconfs_mon,
 
            self.ticket_miniconfs_tue,
 
        ])
 

	
 
        hide_all_tickets = self.find_or_make(
 
            cond.GroupMemberFlag,
 
            ("description", ),
 
            description="Can pre-purchase tickets",
 
            condition=cond.FlagBase.ENABLE_IF_TRUE,
 
        )
 
        hide_all_tickets.group.set([self.group_prepurchase])
 
        hide_all_tickets.products.set([
 
            self.ticket_contributor,
 
            self.ticket_professional,
 
            self.ticket_hobbyist,
 
            self.ticket_student,
 
        ])
 

	
 
        # Set limits.
 
        public_ticket_cap = self.find_or_make(
 
            cond.TimeOrStockLimitFlag,
 
            ("description", ),
 
            description="Public ticket cap",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            limit=600,
 
        )
 
        public_ticket_cap.products.set([
 
            self.ticket_contributor,
 
            self.ticket_professional,
 
            self.ticket_hobbyist,
 
            self.ticket_student,
 
        ])
 

	
 
        student_ticket_cap = self.find_or_make(
 
            cond.TimeOrStockLimitFlag,
 
            ("description", ),
 
            description="Student ticket cap",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            limit=100,
 
        )
 

	
 
        student_ticket_cap.products.set([
 
            self.ticket_student,
 
        ])
 

	
 
        public_ticket_cap.products.set([
 
            self.ticket_contributor,
 
            self.ticket_professional,
 
            self.ticket_hobbyist,
 
            self.ticket_student,
 
        ])
 

	
 
        sponsor_ticket_cap = self.find_or_make(
 
            cond.TimeOrStockLimitFlag,
 
            ("description", ),
 
            description="Reserved for sponsors",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            limit=70,
 
        )
 
        sponsor_ticket_cap.products.set([
 
            self.ticket_sponsor,
 
        ])
 

	
 
        volunteer_ticket_cap = self.find_or_make(
 
            cond.TimeOrStockLimitFlag,
 
            ("description", ),
 
            description="Reserrved for volunteers and organizers",
 
            description="Reserved for volunteers and organisers",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            limit=62,
 
        )
 
        volunteer_ticket_cap.products.set([
 
            self.ticket_team,
 
            self.ticket_volunteer,
 
        ])
 

	
 
        media_ticket_cap = self.find_or_make(
 
            cond.TimeOrStockLimitFlag,
 
            ("description", ),
 
            description="Reserved for media",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            limit=10,
 
        )
 
        media_ticket_cap.products.set([
 
            self.ticket_media,
 
        ])
 

	
 
        speaker_ticket_cap = self.find_or_make(
 
            cond.TimeOrStockLimitFlag,
 
            ("description", ),
 
            description="Reserved for speakers (and miniconf organisers)",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            limit=104,
 
        )
 
        speaker_ticket_cap.products.set([
 
            self.ticket_speaker,
 
        ])
 

	
 
        penguin_dinner_cap = self.find_or_make(
 
            cond.TimeOrStockLimitFlag,
 
            ("description", ),
 
            description="Penguin dinner ticket cap",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            limit=900,
 
        )
 
        penguin_dinner_cap.categories.set([
 
            self.penguin_dinner,
 
        ])
 

	
 
        speakers_dinner_cap = self.find_or_make(
 
            cond.TimeOrStockLimitFlag,
 
            ("description", ),
 
            description="Speakers dinner ticket cap",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            limit=135,
 
        )
 
        speakers_dinner_cap.categories.set([
 
            self.speakers_dinner_ticket,
 
        ])
 

	
 
        pdns_cap = self.find_or_make(
 
            cond.TimeOrStockLimitFlag,
 
            ("description", ),
 
            description="PDNS ticket cap",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            limit=400,
 
        )
 
        pdns_cap.categories.set([
 
            self.pdns_category,
 
        ])
 

	
 
        # Volunteer tickets are for volunteers only
 
        volunteers = self.find_or_make(
 
            cond.GroupMemberFlag,
 
            ("description", ),
 
            description="Volunteer tickets",
 
            condition=cond.FlagBase.ENABLE_IF_TRUE,
 
        )
 
        volunteers.group.set([self.group_volunteers])
 
        volunteers.products.set([
 
            self.ticket_volunteer,
 
        ])
 

	
 
        # Team tickets are for team members only
 
        team = self.find_or_make(
 
            cond.GroupMemberFlag,
 
            ("description", ),
 
            description="Team tickets",
 
            condition=cond.FlagBase.ENABLE_IF_TRUE,
 
        )
 
        team.group.set([self.group_team])
 
        team.products.set([
 
            self.ticket_team,
 
        ])
 

	
 
        # Speaker tickets are for primary speakers only
 
        speaker_tickets = self.find_or_make(
 
            cond.SpeakerFlag,
 
            ("description", ),
 
            description="Speaker tickets",
 
            condition=cond.FlagBase.ENABLE_IF_TRUE,
 
            is_presenter=True,
 
            is_copresenter=False,
 
        )
 
        speaker_tickets.proposal_kind.set(self.main_conference_proposals)
 
        speaker_tickets.products.set([self.ticket_speaker, ])
 

	
 
        # Speaker dinner tickets are for primary and secondary speakers
 
        # Speaker dinner tickets are for primary speakers only
 
        speaker_dinner_tickets = self.find_or_make(
 
            cond.SpeakerFlag,
 
            ("description", ),
 
            description="Speaker dinner tickets",
 
            condition=cond.FlagBase.ENABLE_IF_TRUE,
 
            is_presenter=True,
 
            is_copresenter=True,
 
            is_copresenter=False,
 
        )
 
        speaker_dinner_tickets.proposal_kind.set(self.main_conference_proposals)
 
        speaker_dinner_tickets.categories.set([self.speakers_dinner_ticket, ])
 

	
 
        # PDNS tickets are complicated.
 
        # They can be enabled by tickets
 
        pdns_by_ticket = self.find_or_make(
 
            cond.ProductFlag,
 
            ("description", ),
 
            description="PDNS available by ticket",
 
            condition=cond.FlagBase.ENABLE_IF_TRUE,
 
        )
 
        pdns_by_ticket.enabling_products.set([
 
            self.ticket_professional,
 
            self.ticket_contributor,
 
            self.ticket_media,
 
            self.ticket_sponsor,
 
        ])
 
        pdns_by_ticket.categories.set([self.pdns_category, ])
 

	
 
        # They are available to speakers
 
        pdns_by_speaker = self.find_or_make(
 
            cond.SpeakerFlag,
 
            ("description", ),
 
            description="PDNS available to speakers",
 
            condition=cond.FlagBase.ENABLE_IF_TRUE,
 
            is_presenter=True,
 
            is_copresenter=True,
 

	
 
        )
 
        pdns_by_speaker.proposal_kind.set(self.main_conference_proposals)
 
        pdns_by_speaker.categories.set([self.pdns_category, ])
 

	
 
        # They are available to staff
 
        pdns_by_staff = self.find_or_make(
 
            cond.GroupMemberFlag,
 
            ("description", ),
 
            description="PDNS available to staff",
 
            condition=cond.FlagBase.ENABLE_IF_TRUE,
 
        )
 
        pdns_by_staff.group.set([
 
            self.group_team,
 
        ])
 
        pdns_by_staff.categories.set([self.pdns_category, ])
 

	
 
        # Don't allow people to get anything if they don't have a ticket first
 
        needs_a_ticket = self.find_or_make(
 
            cond.CategoryFlag,
 
            ("description", ),
 
            description="GottaGettaTicketFirst",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            enabling_category=self.ticket
 
        )
 
        needs_a_ticket.categories.set([
 
            self.extras,
 
            self.t_shirt,
 
            self.penguin_dinner,
 
            self.pdns_category,
 
        ])
 
        # Require attendees to accept the T&Cs and Code of Conduct
 
        needs_agreement = self.find_or_make(
 
            cond.CategoryFlag,
 
            ("description", ),
 
            description="Must Accept Terms",
 
            condition=cond.FlagBase.DISABLE_IF_FALSE,
 
            enabling_category=self.terms,
 
        )
 
        needs_agreement.categories.set([
 
            self.extras,
 
            self.t_shirt,
 
            self.penguin_dinner,
 
            self.pdns_category,
 
            self.speakers_dinner_ticket,
 
        ])
 

	
 
    def populate_discounts(self):
 
        def add_early_birds(discount):
 
            self.find_or_make(
 
                cond.DiscountForProduct,
 
                ("discount", "product"),
 
                discount=discount,
 
                product=self.ticket_contributor,
 
                price=settings.CONTRIBUTOR.earlybird_discount(),
 
                quantity=1,  # Per user
 
            )
 
            self.find_or_make(
 
                cond.DiscountForProduct,
 
                ("discount", "product"),
 
                discount=discount,
 
                product=self.ticket_professional,
 
                price=settings.PROFESSIONAL.earlybird_discount(),
 
                quantity=1,  # Per user
 
            )
 

	
 
        def free_category(parent_discount, category, quantity=1):
 
            self.find_or_make(
 
                cond.DiscountForCategory,
 
                ("discount", "category",),
 
                discount=parent_discount,
 
                category=category,
 
                percentage=Decimal("100.00"),
 
                quantity=quantity,
 
            )
 

	
 
        # Early Bird Discount (general public)
 
        early_bird_hobbyist_discount = self.find_or_make(
 
            cond.TimeOrStockLimitDiscount,
 
            ("description", ),
 
            description="Early Bird Discount - Hobbyist",
 
            end_time=settings.EARLY_BIRD_DEADLINE,
 
            limit=150,  # Across all users
 
        )
 
        self.find_or_make(
 
                cond.DiscountForProduct,
 
                ("discount", "product"),
 
                discount=early_bird_hobbyist_discount,
 
                product=self.ticket_hobbyist,
 
                price=settings.HOBBYIST.earlybird_discount(),
 
                quantity=1,  # Per user
 
        )
 

	
 
        early_bird = self.find_or_make(
 
            cond.TimeOrStockLimitDiscount,
 
            ("description", ),
 
            description="Early Bird Discount - Professional",
 
            end_time=settings.EARLY_BIRD_DEADLINE,
 
            limit=200,  # Across professionals and fairy sponsors
 
        )
 
        add_early_birds(early_bird)
 

	
 
        # Early bird rates for speakers
 
        speaker_ticket_discounts = self.find_or_make(
 
            cond.SpeakerDiscount,
 
            ("description", ),
 
            description="Speaker Ticket Discount",
 
            is_presenter=True,
 
            is_copresenter=True,
 
        )
 
        speaker_ticket_discounts.proposal_kind.set(
 
            self.main_conference_proposals,
 
        )
 
        add_early_birds(speaker_ticket_discounts)
 

	
 
        # Primary speaker gets a free speaker dinner ticket
 
        primary_speaker = self.find_or_make(
 
            cond.SpeakerDiscount,
 
            ("description", ),
 
            description="Complimentary for primary proposer",
 
            is_presenter=True,
 
            is_copresenter=False,
 
        )
 
        primary_speaker.proposal_kind.set(self.main_conference_proposals)
 
        free_category(primary_speaker, self.speakers_dinner_ticket)
 

	
 
        # Professional-Like ticket inclusions
 
        ticket_prolike_inclusions = self.find_or_make(
 
            cond.IncludedProductDiscount,
 
            ("description", ),
 
            description="Complimentary for ticket holder (Professional-level)",
 
        )
 
        ticket_prolike_inclusions.enabling_products.set([
 
            self.ticket_contributor,
 
            self.ticket_professional,
 
            self.ticket_media,
 
            self.ticket_sponsor,
 
            self.ticket_speaker,
 
        ])
 
        free_category(ticket_prolike_inclusions, self.penguin_dinner)
 
        free_category(ticket_prolike_inclusions, self.t_shirt)
 

	
 
        # Hobbyist ticket inclusions
 
        ticket_hobbyist_inclusions = self.find_or_make(
 
            cond.IncludedProductDiscount,
 
            ("description", ),
 
            description="Complimentary for ticket holder (Hobbyist-level)",
 
        )
 
        ticket_hobbyist_inclusions.enabling_products.set([
 
            self.ticket_hobbyist,
 
        ])
 
        free_category(ticket_hobbyist_inclusions, self.t_shirt)
 

	
 
        # Student ticket inclusions
 
        ticket_student_inclusions = self.find_or_make(
 
            cond.IncludedProductDiscount,
 
            ("description", ),
 
            description="Complimentary for ticket holder (Student-level)",
 
        )
 
        ticket_student_inclusions.enabling_products.set([
 
            self.ticket_student,
 
        ])
 
        free_category(ticket_student_inclusions, self.t_shirt)
 

	
 
        # Team ticket inclusions
 
        ticket_staff_inclusions = self.find_or_make(
 
            cond.IncludedProductDiscount,
 
            ("description", ),
 
            description="Complimentary for ticket holder staff)",
 
            description="Complimentary for ticket holder (Staff)",
 
        )
 
        ticket_staff_inclusions.enabling_products.set([
 
            self.ticket_team,
 
        ])
 
        free_category(ticket_staff_inclusions, self.penguin_dinner)
 

	
 
        # Team & volunteer shirts, regardless of ticket type
 
        staff_t_shirts = self.find_or_make(
 
            cond.GroupMemberDiscount,
 
            ("description", ),
 
            description="Shirts complimentary for staff and volunteers",
 
        )
 
        staff_t_shirts.group.set([
 
            self.group_team,
 
            self.group_volunteers,
 
        ])
 
        free_category(staff_t_shirts, self.t_shirt, quantity=5)
 

	
 
        print(f"{self.count} categories found/made")
 

	
 
    def find_or_make(self, model, search_keys, **k):
 
        ''' Either makes or finds an object of type _model_, with the given
 
        kwargs.
 

	
 
        Arguments:
 
            search_keys ([str, ...]): A sequence of keys that are used to search
 
            for an existing version in the database. The remaining arguments are
 
            only used when creating a new object.
 
        '''
 
        self.count += 1
 
        try:
 
            keys = dict((key, k[key]) for key in search_keys)
 
            a = model.objects.get(**keys)
 
            self.stdout.write("FOUND  : " + str(keys))
 
            model.objects.filter(id=a.id).update(**k)
 
            a.refresh_from_db()
 
            return a
 
        except ObjectDoesNotExist:
 
            a = model.objects.create(**k)
 
            self.stdout.write("CREATED: " + str(k))
 
            return a
 

	
 

	
 
def hours(n):
 
    return timedelta(hours=n)
pinaxcon/settings.py
Show inline comments
 
from decimal import Decimal
 
import os
 
import sys
 

	
 
import django
 
import dj_database_url
 
import saml2
 
import saml2.saml
 

	
 
from datetime import date, datetime, timedelta
 

	
 
from dataclasses import dataclass
 

	
 
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
 
PACKAGE_ROOT = os.path.abspath(os.path.dirname(__file__))
 
DJANGO_ROOT = os.path.abspath(os.path.dirname(django.__file__))
 
BASE_DIR = PACKAGE_ROOT
 
sys.path.append(os.path.join(PROJECT_ROOT, 'vendor'))
 

	
 

	
 
### USER SETTINGS
 
DEV_MODE = os.environ.get("SYMPOSION_DEV_MODE", None)
 
DEBUG = os.environ.get('SYMPOSION_APP_DEBUG', '0')
 
if isinstance(DEBUG, str):
 
    try:
 
        i = int(DEBUG)
 
        if not i in [0, 1]:
 
            raise ValueError("not 0 or 1")
 
        DEBUG = bool(i)
 
    except ValueError:
 
        sys.exit('DEBUG env var must be set to string value of a 0 or 1')
 
else:
 
    sys.exit('DEBUG env var is in unexpected format.  Should be a string'
 
             'containing either a 0 or a 1 - Got type %s' % type(DEBUG))
 

	
 
DATABASES = {}
 
DATABASES['default'] = dj_database_url.config(conn_max_age=600)
 
if DATABASES['default']['ENGINE'] == 'django.db.backends.mysql':
 
    DATABASES['default']['OPTIONS'] = {'charset': 'utf8mb4'}
 

	
 
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
 
EMAIL_HOST = os.environ.get('EMAIL_HOST', None)
 
EMAIL_PORT = os.environ.get('EMAIL_PORT', 25)
 
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER', None)
 
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD', None)
 
DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', 'webmaster@localhost')
 
EMAIL_USE_SSL = False
 
EMAIL_USE_TLS = False
 
_EMAIL_SSL_FLAVOR=os.environ.get('EMAIL_SSL_FLAVOR', None)
 
if _EMAIL_SSL_FLAVOR == "TLS":
 
    EMAIL_USE_TLS = True
 
elif _EMAIL_SSL_FLAVOR == "SSL":
 
    EMAIL_USE_SSL = True
 

	
 
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', None)
 

	
 
PINAX_STRIPE_PUBLIC_KEY = os.environ.get('STRIPE_PUBLIC_KEY', None)
 
PINAX_STRIPE_SECRET_KEY = os.environ.get('STRIPE_SECRET_KEY', None)
 
PINAX_STRIPE_SEND_EMAIL_RECEIPTS = False
 

	
 
ANALYTICS_KEY = os.environ.get('ANALYTICS_KEY', None)
 

	
 
saml2_entityid = os.environ.get('SAML2_ENTITYID', None)
 
saml2_sp_name = os.environ.get('SAML2_SP_NAME', None)
 
saml2_sp_assertion_service = os.environ.get('SAML2_SP_ASSERTION_SERVICE', None)
 
saml2_sp_slo_rdir = os.environ.get('SAML2_SP_SLO_RDIR', None)
 
saml2_sp_slo_post = os.environ.get('SAML2_SP_SLO_POST', None)
 

	
 
saml2_idp_metadata = {
 
    'local': [os.environ.get('SAML2_IDP_METADATA_FILE', None)],
 
    }
 
saml2_signing_key = os.environ.get('SAML2_SIGNING_KEY', None)
 
saml2_signing_crt = os.environ.get('SAML2_SIGNING_CRT', None)
 
saml2_encr_key = os.environ.get('SAML2_ENCRYPTION_KEY', None)
 
saml2_encr_crt = os.environ.get('SAML2_ENCRYPTION_CRT', None)
 
saml2_contact = {
 
    'given_name': os.environ.get("META_GIVEN_NAME", 'Bastard'),
 
    'sur_name': os.environ.get('META_FAM_NAME', 'Operator'),
 
    'company': os.environ.get('META_COMPANY', 'Corp1'),
 
    'email_address': os.environ.get('META_EMAIL', 'op@example.com'),
 
    'contact_type': 'technical'},
 

	
 
fail = False
 

	
 
BADGER_DEFAULT_SVG = 'registrasion/badge.svg'
 
BADGER_DEFAULT_FORM = "registrasion/badge_form.html"
 

	
 
if SECRET_KEY is None:
 
    print("FAILURE: You need to supply a DJANGO_SECRET_KEY "
 
          "environment variable")
 
    fail = True
 

	
 
if PINAX_STRIPE_PUBLIC_KEY is None:
 
    print("FAILURE: You need to supply a STRIPE_PUBLIC_KEY "
 
          "environment variable")
 
    fail = True
 

	
 
if PINAX_STRIPE_SECRET_KEY is None:
 
    print("FAILURE: You need to supply a STRIPE_SECRET_KEY "
 
          "environment variable")
 
    fail = True
 

	
 
if fail:
 
    sys.exit('FAILURE: Missing environment variables.')
 

	
 
### Standard settings
 

	
 
ADMIN_USERNAMES = []
 

	
 
CACHES = {
 
    'default': {
 
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
 
        'LOCATION': 'unique-snowflake',
 
    }
 
}
 

	
 

	
 
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '*']
 

	
 
TIME_ZONE = "Pacific/Auckland"
 
DATE_FORMAT = "j F Y"
 
LANGUAGE_CODE = "en-au"
 

	
 
SITE_ID = int(os.environ.get("SITE_ID", 1))
 
USE_I18N = True
 
USE_L10N = True
 
USE_TZ = True
 

	
 
MEDIA_ROOT = os.path.join(PACKAGE_ROOT, "site_media", "media")
 
MEDIA_URL = "/site_media/media/"
 

	
 
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static/build')
 
STATIC_URL = '/static/build/'
 

	
 
STATICFILES_DIRS = [
 
    os.path.join(PROJECT_ROOT, 'static/src'),
 
]
 

	
 
STATICFILES_FINDERS = [
 
    "django.contrib.staticfiles.finders.FileSystemFinder",
 
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
 
    "sass_processor.finders.CssFinder",
 
]
 

	
 
TEMPLATES = [
 
    {
 
        "BACKEND": "django.template.backends.django.DjangoTemplates",
 
        "DIRS": [
 
            os.path.join(PACKAGE_ROOT, "templates"),
 
            os.path.join(DJANGO_ROOT, 'forms/templates')
 
        ],
 
        "APP_DIRS": True,
 
        "OPTIONS": {
 
            "debug": DEBUG,
 
            "context_processors": [
 
                "django.contrib.auth.context_processors.auth",
 
                "django.template.context_processors.debug",
 
                "django.template.context_processors.i18n",
 
                "django.template.context_processors.media",
 
                "django.template.context_processors.static",
 
                "django.template.context_processors.tz",
 
                "django.template.context_processors.request",
 
                "django.contrib.messages.context_processors.messages",
 
                "pinax_theme_bootstrap.context_processors.theme",
 
                "symposion.reviews.context_processors.reviews",
 
                "django_settings_export.settings_export",
 
            ],
 
        },
 
    },
 
]
 

	
 
MIDDLEWARE_CLASSES = [
 
    "django.contrib.sessions.middleware.SessionMiddleware",
 
    "django.middleware.common.CommonMiddleware",
 
    "django.middleware.csrf.CsrfViewMiddleware",
 
    "django.contrib.auth.middleware.AuthenticationMiddleware",
 
    "django.contrib.auth.middleware.SessionAuthenticationMiddleware",
 
    "django.contrib.messages.middleware.MessageMiddleware",
 
    "debug_toolbar.middleware.DebugToolbarMiddleware",
 
    "reversion.middleware.RevisionMiddleware",
 
    "waffle.middleware.WaffleMiddleware",
 
    "django.middleware.clickjacking.XFrameOptionsMiddleware",
 
    "django.contrib.flatpages.middleware.FlatpageFallbackMiddleware",
 
    'pinaxcon.monkey_patch.MonkeyPatchMiddleware',
 
]
 

	
 
if DEV_MODE and DEV_MODE == "LAPTOP":
 
    ROOT_URLCONF = "pinaxcon.devmode_urls"
 
else:
 
    ROOT_URLCONF = "pinaxcon.urls"
 

	
 
# Python dotted path to the WSGI application used by Django's runserver.
 
WSGI_APPLICATION = "pinaxcon.wsgi.application"
 

	
 
INSTALLED_APPS = [
 
    "django.contrib.admin",
 
    "django.contrib.auth",
 
    "django.contrib.contenttypes",
 
    "django.contrib.flatpages",
 
    "django.contrib.messages",
 
    "django.contrib.sessions",
 
    "django.contrib.sites",
 
    "django.contrib.staticfiles",
 
    "django.contrib.humanize",
 
    "debug_toolbar",
 

	
 
    'djangosaml2',
 

	
 
    # theme
 
    "bootstrapform",
 
    "pinax_theme_bootstrap",
 
    "sass_processor",
 

	
 
    # external
 
    "easy_thumbnails",
 
    "taggit",
 
    "reversion",
 
    "sitetree",
 
    "pinax.eventlog",
 

	
 
    # symposion
 
    "symposion",
 
    "symposion.conference",
 
    "symposion.proposals",
 
    "symposion.reviews",
 
    "symposion.schedule",
 
    "symposion.speakers",
 
    "symposion.teams",
 

	
 
    # Registrasion
 
    "registrasion",
 

	
 
    # Registrasion-stripe
 
    "pinax.stripe",
 
    "django_countries",
 
    "registripe",
 

	
 
    #registrasion-desk
 
    "regidesk",
 

	
 
    # admin - required by registrasion ??
 
    "nested_admin",
 

	
 
    # project
 
    "pinaxcon",
 
    "pinaxcon.proposals",
 
    "pinaxcon.registrasion",
 
    "pinaxcon.raffle",
 
    "jquery",
 
    "djangoformsetjs",
 

	
 
    # testing and rollout
 
    "django_nose",
 
    "waffle",
 

	
 
    "crispy_forms",
 
]
 

	
 
CRISPY_TEMPLATE_PACK = "bootstrap4"
 

	
 
DEBUG_TOOLBAR_PANELS = [
 
    'debug_toolbar.panels.versions.VersionsPanel',
 
    'debug_toolbar.panels.timer.TimerPanel',
 
    'debug_toolbar.panels.settings.SettingsPanel',
 
    'debug_toolbar.panels.headers.HeadersPanel',
 
    'debug_toolbar.panels.request.RequestPanel',
 
    'debug_toolbar.panels.sql.SQLPanel',
 
    'debug_toolbar.panels.staticfiles.StaticFilesPanel',
 
    'debug_toolbar.panels.cache.CachePanel',
 
    'debug_toolbar.panels.signals.SignalsPanel',
 
    'debug_toolbar.panels.logging.LoggingPanel',
 
    'debug_toolbar.panels.templates.TemplatesPanel',
 
    'debug_toolbar.panels.redirects.RedirectsPanel',
 
]
 

	
 
DEBUG_TOOLBAR_CONFIG = {
 
    'INTERCEPT_REDIRECTS': False,
 
    'SHOW_TOOLBAR_CALLBACK': lambda x: DEBUG,
 
}
 

	
 
LOGGING = {
 
    'version': 1,
 
    'disable_existing_loggers': False,
 
    'formatters': {
 
        'verbose': {
 
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
 
        },
 
        'simple': {
 
            'format': '%(asctime)s %(levelname)s $(module)s %(message)s'
 
        },
 
    },
 
    'filters': {
 
        'require_debug_false': {
 
            '()': 'django.utils.log.RequireDebugFalse'
 
        }
 
    },
 
    'handlers': {
 
        'console': {
 
            'level': 'DEBUG',
 
            'class': 'logging.StreamHandler',
 
            'formatter': 'simple'
 
        },
 
        'mail_admins': {
 
            'level': 'ERROR',
 
            'filters': ['require_debug_false'],
 
            'class': 'django.utils.log.AdminEmailHandler',
 
            'include_html': True,
 
        }
 
    },
 
    'loggers': {
 
        'django.request': {
 
            'handlers': ['mail_admins'],
 
            'level': 'DEBUG',
 
            'propagate': True,
 
        },
 
        'symposion.request': {
 
            'handlers': ['mail_admins'],
 
            'level': 'DEBUG',
 
            'propagate': True,
 
        },
 
    },
 
    'root': {
 
        'handlers': ['console'],
 
        'level': 'DEBUG'
 
    },
 
}
 
FIXTURE_DIRS = [
 
    os.path.join(PROJECT_ROOT, "fixtures"),
 
]
 

	
 
AUTHENTICATION_BACKENDS = [
 
    'symposion.teams.backends.TeamPermissionsBackend',
 
    'django.contrib.auth.backends.ModelBackend',
 
    'djangosaml2.backends.Saml2Backend',
 
]
 

	
 
LOGIN_URL = '/saml2/login/'
 
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
 

	
 
CONFERENCE_ID = 1
 
PROPOSAL_FORMS = {
 
    "talk": "pinaxcon.proposals.forms.TalkProposalForm",
 
    "tutorial": "pinaxcon.proposals.forms.TutorialProposalForm",
 
    "miniconf": "pinaxcon.proposals.forms.MiniconfProposalForm",
 
    ### LCA2020 Miniconfs
 
    "containers-miniconf": "pinaxcon.proposals.forms.ContainersProposalForm",
 
    "creative-arts-miniconf": "pinaxcon.proposals.forms.CreativeArtsProposalForm",
 
    "docs-miniconf": "pinaxcon.proposals.forms.DocsProposalForm",
 
    "freebsd-miniconf": "pinaxcon.proposals.forms.FreeBsdProposalForm",
 
    "games-miniconf": "pinaxcon.proposals.forms.GamesProposalForm",
 
    "glam-miniconf": "pinaxcon.proposals.forms.GlamProposalForm",
 
    "kernel-miniconf": "pinaxcon.proposals.forms.KernelProposalForm",
 
    "open-education-miniconf": "pinaxcon.proposals.forms.OpenEducationProposalForm",
 
    "open-hardware-miniconf": "pinaxcon.proposals.forms.OpenHardwareProposalForm",
 
    "open-isa-miniconf": "pinaxcon.proposals.forms.OpenIsaProposalForm",
 
    "security-miniconf": "pinaxcon.proposals.forms.SecurityProposalForm",
 
    "sysadmin-miniconf": "pinaxcon.proposals.forms.SysAdminProposalForm",
 
}
 

	
 
# Registrasion bits:
 
ATTENDEE_PROFILE_MODEL = "pinaxcon.registrasion.models.AttendeeProfile"
 
ATTENDEE_PROFILE_FORM = "pinaxcon.registrasion.forms.ProfileForm"
 
INVOICE_CURRENCY = "NZD"
 
INVOICE_CURRENCY = "AUD"
 
TICKET_PRODUCT_CATEGORY = 1
 
TERMS_PRODUCT_CATEGORY = 2
 
ATTENDEE_PROFILE_FORM = "pinaxcon.registrasion.forms.ProfileForm"
 

	
 
#REGIDESK
 
REGIDESK_BOARDING_GROUP = "Ready For Boarding"
 

	
 
# CSRF custom error screen
 
CSRF_FAILURE_VIEW = "pinaxcon.csrf_view.csrf_failure"
 

	
 
# Use nose to run all tests
 
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
 

	
 
# Tell nose to measure coverage on the 'foo' and 'bar' apps
 
NOSE_ARGS = [
 
    '--with-coverage',
 
    '--cover-package=registrasion.controllers,registrasion.models',
 
]
 

	
 
SASS_PROCESSOR_INCLUDE_DIRS = [
 
    os.path.join(PROJECT_ROOT, 'static/src/bootstrap/scss'),
 
    os.path.join(PROJECT_ROOT, 'static/src/scss'),
 
]
 

	
 
xmlsec_binary = '/usr/bin/xmlsec1'
 
if not os.path.isfile(xmlsec_binary):
 
        sys.exit('ERROR: xmlsec1 binary missing, EXITING')
 

	
 
SAML_ATTRIBUTE_MAPPING = {
 
    'uid': ('username', ),
 
    'mail': ('email', ),
 
    'givenName': ('first_name', ),
 
    'sn': ('last_name', ),
 
}
 
SAML_CONFIG = {
 
    'xmlsec_binary': xmlsec_binary,
 
    'entityid': saml2_entityid,
 
    'attribute_map_dir': os.path.join(PACKAGE_ROOT, 'saml2/attribute-maps'),
 
    'service': {
 
        'sp': {
 
            'name': saml2_sp_name,
 
            'endpoints': {
 
                'assertion_consumer_service': [
 
                    saml2_sp_assertion_service,
 
                    ],
 
                'single_logout_service': [
 
                    (saml2_sp_slo_rdir, saml2.BINDING_HTTP_REDIRECT),
 
                    (saml2_sp_slo_post, saml2.BINDING_HTTP_POST),
 
                    ],
 
                },
 
            'logout_requests_signed': True,
 
            'required_attributes': ['uid', 'mail', 'givenName', 'sn'],
 
            },
 
        },
 
    'metadata': saml2_idp_metadata,
 
    'debug': 0,
 
    'key_file': saml2_signing_key,
 
    'cert_file': saml2_signing_crt,
 
    'encryption_keypairs': [{
 
        'key_file': saml2_encr_key,
 
        'cert_file': saml2_encr_crt,
 
    }],
 
    'contact_person': saml2_contact,
 
    'valid_for': 10,
 
}
 

	
 
if 'SAML_CONFIG_LOADER' in os.environ:
 
    SAML_CONFIG_LOADER = os.environ.get('SAML_CONFIG_LOADER')
 

	
 
DEFAULT_FILE_STORAGE = 'gapc_storage.storage.GoogleCloudStorage'
 
GAPC_STORAGE = {
 
    'num_retries': 2,
 
}
 

	
 
SETTINGS_EXPORT = [
 
    'DEBUG',
 
    'ANALYTICS_KEY',
 
]
 

	
 
if DEV_MODE and DEV_MODE == "LAPTOP":
 
    print("ENABLING LAPTOP MODE")
 
    from .devmode_settings import *
 

	
 

	
 
class Category(object):
 
    tickets = []
 

	
 
    @classmethod
 
    def order(cls, ticket) -> int:
 
        return (cls.tickets.index(ticket) + 1) * 10
 

	
 

	
 
@dataclass(frozen=True)
 
class Ticket:
 
    name: str
 
    regular_price: Decimal
 
    earlybird_price: Decimal
 

	
 
    def earlybird_discount(self):
 
        return self.regular_price - self.earlybird_price
 

	
 

	
 
@dataclass(frozen=True)
 
class DinnerTicket:
 
    name: str
 
    price: Decimal
 
    description: str
 
    reservation: timedelta
 
    cat: Category
 

	
 
    def order(self):
 
        return self.cat.order(self)
 

	
 

	
 
class PenguinDinnerTicket(DinnerTicket):
 
    pass
 

	
 

	
 
class SpeakersDinnerTicket(DinnerTicket):
 
    pass
 

	
 

	
 
class SpeakersDinnerCat(Category):
 
    @classmethod
 
    def create(cls, name: str, price: Decimal, description: str, reservation: timedelta) -> SpeakersDinnerTicket:
 
        t = SpeakersDinnerTicket(name, price, description, reservation, cls)
 
        cls.tickets.append(t)
 
        return t
 

	
 

	
 
class PenguinDinnerCat(Category):
 
    @classmethod
 
    def create(cls, name: str, price: Decimal, description: str, reservation: timedelta) -> PenguinDinnerTicket:
 
        t = PenguinDinnerTicket(name, price, description, reservation, cls)
 
        cls.tickets.append(t)
 
        return t
 

	
 

	
 
LCA_START = datetime(2020, 1, 13)
 
LCA_END = datetime(2020, 1, 17)
 
EARLY_BIRD_DEADLINE = datetime(2019, 11, 1)
 
PENGUIN_DINNER_TICKET_DATE = date(2020, 1, 15)
 
SPEAKER_DINNER_TICKET_DATE = date(2020, 1, 14)
 
PDNS_TICKET_DATE = date(2020, 1, 16)
 

	
 
TSHIRT_PRICE = Decimal("25.00")
 

	
 
CONTRIBUTOR = Ticket("Contributor", Decimal("1999.00"), Decimal("1849.00"))
 
PROFESSIONAL = Ticket("Professional", Decimal("1099.00"), Decimal("949.00"))
 
HOBBYIST = Ticket("Hobbyist", Decimal("549.00"), Decimal("399.00"))
 
STUDENT = Ticket("Student", Decimal("199.00"), None)
 

	
 
MINICONF_MT = Ticket("Monday and Tuesday Only", Decimal("198.00"), None)
 
MINICONF_M = Ticket("Monday Only", Decimal("99.00"), None)
 
MINICONF_T = Ticket("Tuesday Only", Decimal("99.00"), None)
 

	
 
MEDIA = Ticket("Media", Decimal("0.0"), None)
 
SPEAKER = Ticket("Speaker", Decimal("0.0"), None)
 
SPONSOR = Ticket("Sponsor", Decimal("0.0"), None)
 

	
 
CONFERENCE_ORG = Ticket("Conference Organiser", Decimal("0.0"), None)
 
CONFERENCE_VOL = Ticket("Conference Volunteer", Decimal("0.0"), None)
 

	
 
PENGUIN_DINNER = PenguinDinnerCat
 
PENGUIN_DINNER_ADULT = PenguinDinnerCat.create(
 
    "Adult", Decimal("95.00"),
 
    "Includes an adult's meal and full beverage service.",
 
    timedelta(hours=1))
 
PENGUIN_DINNER_CHILD = PenguinDinnerCat.create(
 
    "Child", Decimal("50.00"),
 
    "Children 14 and under. "
 
    "Includes a child's meal and soft drink service.",
 
    timedelta(hours=1))
 
PENGUIN_DINNER_INFANT = PenguinDinnerCat.create(
 
    "Infant", Decimal("0.0"),
 
    "Includes no food or beverage service.",
 
    timedelta(hours=1))
 

	
 
SPEAKERS_DINNER = SpeakersDinnerCat
 

	
 
SPEAKERS_DINNER_ADULT = SpeakersDinnerCat.create(
 
    "Adult", Decimal("100.00"),
 
    "Includes an adult's meal and full beverage service.",
 
    timedelta(hours=1))
 

	
 
SPEAKERS_DINNER_CHILD = SpeakersDinnerCat.create(
 
    "Child", Decimal("60.00"),
 
    "Children 14 and under. "
 
    "Includes a child's meal and soft drink service.",
 
    timedelta(hours=1))
 

	
 
SPEAKERS_DINNER_INFANT = SpeakersDinnerCat.create(
 
    "Infant", Decimal("00.00"),
 
    "Infant must be seated in an adult's lap. "
 
    "No food or beverage service.",
 
    timedelta(hours=1))
 
# SPEAKERS_DINNER_CHILD = SpeakersDinnerCat.create(
 
#     "Child", Decimal("60.00"),
 
#     "Children 14 and under. "
 
#     "Includes a child's meal and soft drink service.",
 
#     timedelta(hours=1))
 

	
 
# SPEAKERS_DINNER_INFANT = SpeakersDinnerCat.create(
 
#     "Infant", Decimal("00.00"),
 
#     "Infant must be seated in an adult's lap. "
 
#     "No food or beverage service.",
 
#     timedelta(hours=1))
pinaxcon/templates/_form_snippet.html
Show inline comments
 
{% load lca2018_tags %}
 
{% load lca2019_tags %}
 
{% load bootstrap %}
 
{% load crispy_forms_tags %}
 

	
 
{% if form.non_field_errors %}
 
  <div class="has-errors">
 
    {{ form.non_field_errors }}
 
  </div>
 
  <br/>
 
{% endif %}
 

	
 
<p>
 
{% if form|has_required_fields %}
 
<blockquote>
 
  Fields marked with a * are required
 
</blockquote>
 
Fields marked with a * are required.
 
{% endif %}
 
{% if form|has_price_fields %}
 
<strong>Item prices are before any discount.</strong>
 
{% endif %}
 
</p>
 

	
 
{{ form|crispy }}
pinaxcon/templates/registrasion/_invoice_details.html
Show inline comments
 
{% load registrasion_tags %}
 
{% load lca2018_tags %}
 

	
 
<h2>Tax Invoice/Statement</h2>
 
<h3>Linux Australia</h3>
 
<h4>GST #90-792-369</h4>
 
<h4>ABN 56 987 117 479</h4>
 

	
 
<p>
 
  Enquiries: please e-mail <a href="mailto:contact@lca2019.org">contact@lca2019.org</a>
 
  Enquiries: please e-mail <a href="mailto:contact@lca2020.linux.org.au">contact@lca2020.linux.org.au</a>
 
</p>
 

	
 
<ul class="list-unstyled">
 
  <li><strong>Invoice number:</strong> {{ invoice.id }}
 
  <li><strong>Invoice status:</strong> {{ invoice.get_status_display }}</li>
 
  <li><strong>Issue date:</strong> {{ invoice.issue_time|date:"DATE_FORMAT" }}
 
  {% if not invoice.is_void %}
 
    <li><strong>Due:</strong> {{ invoice.due_time|date:"DATETIME_FORMAT"}}</li>
 
  {% endif %}
 
</ul>
 

	
 
<div>
 
<h4>Attention:</h4>
 
  {{ invoice.recipient|linebreaksbr}}
 
</div>
 

	
 
<p>This invoice has been issued as a result of an application to attend {% conference_name %}. All amounts are in New Zealand Dollars (NZD).</p>
 
<p>This invoice has been issued as a result of an application to attend {% conference_name %}. All amounts are in Australian Dollars (AUD).</p>
 

	
 
<table class="table table-striped my-4">
 
  <thead>
 
    <tr>
 
      <th>Description</th>
 
      <th class="text-right">Quantity</th>
 
      <th class="text-right">Price/Unit</th>
 
      <th class="text-right">Total</th>
 
    </tr>
 
  </thead>
 
  <tbody>
 
    {% for line_item in invoice.lineitem_set.all %}
 
      <tr>
 
        <td>{{ line_item.description }}</td>
 
        <td class="text-right">{{ line_item.quantity }}</td>
 
        <td class="text-right">${{ line_item.price }}</td>
 
        <td class="text-right">${{ line_item.total_price }}</td>
 
      </tr>
 
    {% endfor %}
 

	
 
    <tr><th colspan="4"></th></tr>
 

	
 
    <tr>
 
      <th colspan="3">Includes 15% New Zealand Goods and Services Tax</th>
 
      <th colspan="3">Includes 10% Australian Goods and Services Tax</th>
 
      <td class="text-right">${{ invoice.value|gst}}</td>
 
    </tr>
 

	
 
    <tr>
 
      <th colspan="3">Total</th>
 
      <td class="text-right">${{ invoice.value }}</td>
 
    </tr>
 

	
 
    <tr><th colspan="4"></th></tr>
 

	
 
    <tr>
 
      <th colspan="3">Total payments received:</th>
 
      <td class="text-right">${{ invoice.total_payments }}</td>
 
    </tr>
 
    {% if invoice.is_unpaid or invoice.is_paid %}
 
      <tr>
 
        <th colspan="3">Balance due:</th>
 
        <td class="text-right">${{ invoice.balance_due }}</td>
 
      </tr>
 
    {% endif %}
 
  </tbody>
 
</table>
 

	
 
{% if invoice.paymentbase_set.all %}
 
  <div class="page-break"></div>
 
  <h3 class="pt-4">Payments received</h3>
 
  {% include "registrasion/payment_list.html" with payments=invoice.paymentbase_set.all %}
 
{% endif %}
 

	
 

	
 
<hr />
 

	
 
<p>{% conference_name %} is a project of Linux Australia, Inc.</p>
 

	
 
<p>
 
  GPO Box 4788 <br />
 
  Sydney NSW 2001 <br />
 
  Australia <br />
 
  ABN 56 987 117 479 <br />
 
  NZ GST #90-792-369
 
<p>
pinaxcon/templates/registrasion/base.html
Show inline comments
 
{% extends "utility_page.html" %}
 
{% extends "site_base.html" %}
 
{% load staticfiles %}
 
{% load lca2018_tags %}
 
{% load i18n %}
 

	
 
{% block head_title %}{% block page_title %}{% endblock %}{% endblock %}
 

	
 
{% block utility_body %}
 
  {% block proposals_body %}
 
  {% endblock %}
 
{% block content_base %}
 
{% block content %}
 
  <div class="jumbotron rego-content">
 
    {% block proposals_body %}
 
    {% endblock %}
 
  </div>
 
{% endblock content %}
 
{% endblock %}
 

	
pinaxcon/templates/registrasion/discount_list.html
Show inline comments
 
{% if discounts %}
 
<div class="my-4 py-4 px-4">
 
  <h4>Discounts and Complimentary Items</h4>
 
  <p>The following discounts and complimentary items are available to you. If you wish to take advantage of this offer, you must choose your items below. The discounts will be applied automatically when you check out.</p>
 
<div class="alert alert-danger my-4 pb-4 text-center">
 
  <h4 class="alert-heading">Discounts and Complimentary Items</h4>
 
  <p>The following discounts and complimentary items are available to you:</p>
 
  {% regroup discounts by discount.description as discounts_grouped %}
 
  <ul class="d-inline-block text-left">
 
  {% for discount_type in discounts_grouped %}
 
  <strong>{{ discount_type.grouper }}</strong>
 
  <ul>
 
    {% for discount in discount_type.list %}
 
    <li>{{ discount.quantity }} &times; {{ discount.clause }}</li>
 
    {% endfor %}
 
  </ul>
 
    <li>
 
      <strong>{{ discount_type.grouper }}</strong>
 
      <ul>
 
        {% for discount in discount_type.list %}
 
        <li>{{ discount.quantity }} &times; {{ discount.clause }}</li>
 
        {% endfor %}
 
      </ul>
 
    </li>
 
  {% endfor %}
 
  </ul>
 
  <p>
 
    <strong>
 
    Please ensure you enter a value in the form below to take advantage of this discount.<br>
 
    The discounts will be applied automatically when you check out.
 
    </strong>
 
  </p>
 
  <p class="mb-0">
 
    <strong>
 
    If you do not enter anything, you will not receive anything from this category.
 
    </strong>
 
  </p>
 
</div>
 

	
 
{% endif %}
pinaxcon/templates/registrasion/guided_registration.html
Show inline comments
 
{% extends "registrasion/base.html" %}
 
{% load lca2018_tags %}
 

	
 
{% block header_title %}Buy Your Ticket{% endblock %}
 
{% block header_paragraph %}Step {{ current_step }} of {{ total_steps|add:1 }} &ndash; {{ title }} {% endblock %}
 
{% block page_title %}Buy Your Ticket{% endblock %}
 
{% block page_lead %}Step {{ current_step }} of {{ total_steps|add:1 }} &ndash; {{ title }} {% endblock %}
 

	
 
{% block scripts_extra %}
 
  {% for section in sections %}
 
    {{ section.form.media.js }}
 
  {% endfor %}
 
<script type="text/javascript">
 
  <script type="text/javascript">
 
    postcode_label = $("label[for='id_profile-state']");
 
    postcode_help = $("#id_profile-state + p");
 
      $('#id_profile-country').change(function () {
 
        if ($(this).val() == 'AU' )  {
 
          postcode_label.addClass('label-required');
 
          postcode_help.show();
 
        } else {
 
          postcode_label.removeClass('label-required');
 
          postcode_help.hide();
 
        } });
 
        $("#id_profile-country").change();
 

	
 
      </script>
 

	
 
  </script>
 
{% endblock %}
 

	
 
{% block proposals_body %}
 

	
 
  <form class="form-horizontal" method="POST" action="" enctype="multipart/form-data">
 
    {% csrf_token %}
 

	
 
    {% for section in sections %}
 
    <h2>{{ section.title }}</h2>
 

	
 
    {% if section.description %}
 
    <blockquote>{{ section.description|safe }}</blockquote>
 
    {% endif %}
 

	
 
    <fieldset>
 
        {% if section.discounts %}
 
          {% include "registrasion/discount_list.html" with discounts=section.discounts %}
 
        {% endif %}
 
      {% if section.discounts %}
 
        {% include "registrasion/discount_list.html" with discounts=section.discounts %}
 
      {% endif %}
 

	
 
        {% include "_form_snippet.html" with form=section.form %}
 
      {% include "_form_snippet.html" with form=section.form %}
 

	
 
        <br />
 
      </fieldset>
 
        {% endfor %}
 
      <br />
 
    </fieldset>
 
    {% endfor %}
 

	
 
      {% if current_step > 1 %}
 
      <a class="btn btn-primary" role="button" href="{{ previous_step }}">Back</a>
 
      {% endif %}
 
      <input class="btn btn-primary" type="submit" value="Next Step" />
 
    {% if current_step > 1 %}
 
    <a class="btn btn-secondary" role="button" href="{{ previous_step }}">Back</a>
 
    {% endif %}
 
    <input class="btn btn-primary" type="submit" value="Next Step" />
 
  </form>
 

	
 

	
 
{% endblock %}
pinaxcon/templates/registrasion/invoice.html
Show inline comments
 
{% extends "registrasion/base.html" %}
 
{% load registrasion_tags %}
 
{% load lca2018_tags %}
 
{% load staticfiles %}
 

	
 
{% block header_title %}{% conference_name %}{% endblock %}
 
{% block head_title %}Tax Invoice/Statement #{{ invoice.id }}{% endblock %}
 
{% block page_title %}{% conference_name %}{% endblock %}
 

	
 
{% block proposals_body %}
 
{% include "registrasion/_invoice_details.html" %}
 
<div class="hidden-print mb-4 pb-4">
 
<div class="d-print-none mb-4 pb-4">
 
  {% if invoice.is_unpaid %}
 
  <p>
 
    <strong>NOTICE:</strong> The above invoice is automatically generated, and
 
    will be voided if you amend your selections before payment, or if discounts
 
    or products contained in the invoice become unavailable. The products and
 
    discounts are only reserved until the invoice due time, please pay before then
 
    to guarantee your selection. Late payments are accepted only if the products
 
    and discounts are still available.</p>
 

	
 
  {% url "invoice_access" invoice.user.attendee.access_code as access_url %}
 
  <p>Your most recent unpaid invoice will be available at
 
    <a href="{{ access_url }}">{{ request.scheme }}://{{ request.get_host }}{{ access_url }}</a>
 
    You can print that page for your records, or give this URL to your accounts department to pay for this invoice
 
  </p>
 

	
 
  <a class="btn btn-primary" href='{% url "registripe_card" invoice.id invoice.user.attendee.access_code %}'>Pay this invoice by card</a>
 

	
 
  {% if user.is_staff %}
 
  <a class="btn btn-primary" href="{% url "manual_payment" invoice.id %}">Apply manual payment</a>
 
  <a class="btn btn-secondary" href="{% url "manual_payment" invoice.id %}">Apply manual payment</a>
 
  {% endif %}