Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dealer wifi configurable, form tweaks. Update pre-commit #333

Merged
merged 7 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,24 @@ default_language_version:
exclude: venv/|static/

repos:
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.3
hooks:
- id: seed-isort-config

- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
rev: v5.0.0
hooks:
- id: check-builtin-literals
- id: trailing-whitespace
- id: end-of-file-fixer
#- id: flake8
- id: check-ast
- id: mixed-line-ending
args: [--fix=lf]

# - repo: https://github.com/pre-commit/mirrors-autopep8
# rev: "v1.4.4"
# hooks:
# - id: autopep8

- repo: https://github.com/ambv/black
rev: 22.10.0
rev: 24.10.0
hooks:
- id: black

Expand All @@ -40,4 +30,4 @@ repos:
# rev: "2.7.1"
# files: \.(js|css)$
# hooks:
# - id: prettier
## - id: prettier
11 changes: 11 additions & 0 deletions registration/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,17 @@ class EventAdmin(admin.ModelAdmin):
),
},
),
(
"Dealers Configuration",
{
"classes": ("collapse",),
"fields": (
"dealerWifi",
"dealerWifiPrice",
"dealerPartnerPrice",
),
},
),
)


Expand Down
28 changes: 28 additions & 0 deletions registration/migrations/0102_event_dealer_wifi_partner_price.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 3.2.25 on 2024-10-17 07:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("registration", "0101_auto_20240630_0045"),
]

operations = [
migrations.AddField(
model_name="event",
name="dealerPartnerPrice",
field=models.DecimalField(decimal_places=2, default=55, max_digits=6),
),
migrations.AddField(
model_name="event",
name="dealerWifi",
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name="event",
name="dealerWifiPrice",
field=models.DecimalField(decimal_places=2, default=50, max_digits=6),
),
]
11 changes: 11 additions & 0 deletions registration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,17 @@ class Event(LookupTable):
default=0,
help_text="External donations to add to metrics ",
)
dealerWifi = models.BooleanField(
default=True,
verbose_name="Dealer Wifi",
help_text="Include option to purchase Wifi on dealers form",
)
dealerWifiPrice = models.DecimalField(
decimal_places=2, max_digits=6, default=50, verbose_name="Wifi Price"
)
dealerPartnerPrice = models.DecimalField(
decimal_places=2, max_digits=6, default=55, verbose_name="Partner Price"
)


class TableSize(LookupTable):
Expand Down
10 changes: 10 additions & 0 deletions registration/static/admin/js/jquery.init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*global jQuery:false*/
'use strict';
/* Puts the included jQuery into our own namespace using noConflict and passing
* it 'true'. This ensures that the included jQuery doesn't pollute the global
* namespace (i.e. this preserves pre-existing values for both window.$ and
* window.jQuery).
*/
window.django = {jQuery: jQuery.noConflict(true)};
window.jQuery = window.django.jQuery;
window.$ = jQuery;
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h3>Your Order</h3>
{% if dealer.getUnpaidPartnerCount > 0 %}
<div class="row">
<div class="col-sm-6 col-sm-offset-1">Partners x{{ dealer.getUnpaidPartnerCount }}</div>
<div class="col-sm-2">${{ dealer.getUnpaidPartnerCount|mul:55 }}.00</div>
<div class="col-sm-2">${{ dealer.getUnpaidPartnerCount|mul:event.dealerPartnerPrice }}</div>
<div class="col-sm-2">
</div>
</div>
Expand All @@ -36,7 +36,7 @@ <h3>Your Order</h3>
{% if dealer.needWifi %}
<div class="row">
<div class="col-sm-6 col-sm-offset-1">Wifi</div>
<div class="col-sm-2">$50.00</div>
<div class="col-sm-2">${{ event.dealerWifiPrice }}</div>
<div class="col-sm-2"></div>
</div>
{% endif %}
Expand Down Expand Up @@ -222,7 +222,7 @@ <h3>Billing Information</h3>
data-error="City is required."/>
</div>
<div class="col-sm-4">
<select class="form-control bfh-states" id="state" data-country="US" data-state="VA"
<select class="form-control bfh-states" id="state" data-country="US" data-state="{{ event.venue.state }}"
name="state"></select>
</div>
<div class="col-sm-offset-3 help-block with-errors" style=" padding-left:15px;"></div>
Expand Down
12 changes: 8 additions & 4 deletions registration/templates/registration/dealer/dealer-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,19 @@ <h2>Business Information</h2>
<h2>Placement Options</h2>
<p>The options below may limit where you can be placed in our Marketplace.</p>
<hr/>
{% if event.dealerWifi %}
<div class="form-group">
<label for="wifi" class="col-sm-3 control-label">I need Wi-Fi</label>
<div class="col-sm-9">
<input type="checkbox" id="wifi" name="wifi" class="form-control form-control-checkbox"/>
</div>
<div class="col-sm-9 col-sm-offset-3 small">This option adds $50 to your table price. You will receive
<div class="col-sm-9 col-sm-offset-3 small">This option adds ${{ event.dealerWifiPrice }} to your table price. You will receive
Wi-Fi access details in your welcome packet at the con.
</div>
</div>
{% else %}
<input type="hidden" id="wifi" name="wifi" value="unchecked">
{% endif %}
<div class="form-group">
<label for="switch" class="col-sm-3 control-label">I will consider different table types</label>
<div class="col-sm-9">
Expand Down Expand Up @@ -209,7 +213,7 @@ <h2>Placement Options</h2>
}
$("#partnerList").empty();
if (item.partnerMax > 0) {
for (var i = item.partnerMin; i <= item.partnerMax; i++) {
for (var i = item.partnerMin; i < item.partnerMax; i++) {
var partner = '<div class="partnerGroup"><input type="text" id="name_' + i + '" maxlength="400" class="form-control form-control-text" placeholder="Partner Name" />' +
'<input type="email" id="email_' + i + '" maxlength="200" class="form-control form-control-text" placeholder="Partner Email" />' +
'<input type="text" id="license_' + i + '" maxlength="50" placeholder="Partner Tax License" class="form-control form-control-text" />' +
Expand All @@ -219,7 +223,7 @@ <h2>Placement Options</h2>
$("#partnerList").append("<br/>");
}
}
$("#partnerList").append("<span class='small'>If any partner will be selling their own merchandice, they must provide their license number or request a temporary license from the convention.</span>");
$("#partnerList").append("<span class='small'>If any partner will be selling their own merchandise, they must provide their license number or request a temporary license from the convention.</span>");
$(".partnerLicense").click(partnerLicense);
}
}
Expand Down Expand Up @@ -326,7 +330,7 @@ <h2>Placement Options</h2>
'chairs': $("#chairs").val(), 'partners': getPartners(), 'tables': $("#tables").val(),
'reception': false, 'artShow': false,
'charityRaffle': $("#charityRaffle").val(), 'agreeToRules': $("#agreeToRules").is(':checked'),
'breakfast': $('#breakfast').is(':checked'), 'switch': $('#switch').is(':checked'),
'breakfast': false, 'switch': $('#switch').is(':checked'),
'asstbreakfast': false
},
'event': '{{event}}'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ <h1>Dealer Registration - {{ event }}</h1>
<script type="text/javascript" src="{% static "js/main.js" %}"></script>
{% if dealer %}
<script type="text/javascript" src="{% static "js/templates/price-types.js" %}"></script>
<script type="text/javascript" src="{% static "js/date-entry.js" %}"></script>
<script type="text/javascript">
let dealer = {{ jsonDealer|safe }};
let attendee = {{ jsonAttendee|safe }};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ <h1>Javascript is required to use this form.</h1>
<div id="billingInfo">
<h3>Charges</h3>

<div class='form-group' style='margin-left:30px;'>You will be charged $55 for each new partner added via
<div class='form-group' style='margin-left:30px;'>You will be charged ${{ event.dealerPartnerPrice }} for each new partner added via
this form.
</div>
<div class='form-group' style='margin-left:30px;'><span style='color:red'><b>Important!</b></span> Do
Expand Down
21 changes: 17 additions & 4 deletions registration/templates/templatetags/basic_attendee_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,16 @@
required type="text" value="{{attendee.city}}"/>
</div>
<div class="col-sm-5">
<select autocomplete="address-level3" class="form-control bfh-states" data-country="country" data-state="VA" id="state"
name="state" required></select>
<select autocomplete="address-level3" class="form-control bfh-states"
{% if event.venue %}
data-country="{{attendee.country|default:event.venue.country }}"
data-state="{{attendee.state|default:event.venue.state }}"
{% else %}
data-country="{{ attendee.country }}"
data-state="{{ attendee.state }}"
{% endif %}

id="state" name="state" required></select>
</div>
<div class="col-sm-offset-3 help-block with-errors" style="padding-left:15px;"></div>
</div>
Expand All @@ -94,8 +102,13 @@
value="{{attendee.postalCode}}"/>
</div>
<div class="col-sm-6">
<select autocomplete="country" class="form-control bfh-countries" data-country="US" id="country" name="country"
required></select>
<select autocomplete="country" class="form-control bfh-countries"
{% if event.venue %}
data-country="{{ attendee.country|default:event.venue.country }}"
{% else %}
data-country="{{ attendee.country }}"
{% endif %}
id="country" name="country" required></select>
</div>
<div class="col-sm-offset-3 help-block with-errors" style="padding-left:15px;"></div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions registration/templatetags/registration_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ def selected_if_month(date, value):
@register.simple_tag
def subtract_years(date, years):
return date.replace(year=date.year - years).strftime("%B %e, %Y")


@register.simple_tag
def venue_country(event):
if event.venue:
return event.venue.country
else:
return ""
5 changes: 4 additions & 1 deletion registration/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
eventEnd=now + ten_days,
)

TEST_SIGNATURE_SVG = "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm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ZHRoPSIyIiBzdHJva2U9InJnYig4NSwgODUsIDg1KSIgZmlsbD0ibm9uZSIgZD0iTSAyMDUgMzggYyAwLjI1IDAgOS4zOCAwLjQ5IDE0IDAgYyA4LjAyIC0wLjg0IDE1LjgzIC0zLjIzIDI0IC00IGMgMTMuNDQgLTEuMjYgMjYuMjEgLTEuODQgNDAgLTIgYyA0NC4wOCAtMC41MiA4NC44OCAtMS43NSAxMjggMCBjIDIzLjQgMC45NSA0NS41NiA0LjMgNjkgOCBjIDI4LjUzIDQuNSA1NS4wMyAxMC4xNyA4MyAxNiBjIDQuNSAwLjk0IDguNTMgMy4xNSAxMyA0IGMgMTYuNjMgMy4xNyA1MCA4IDUwIDgiLz48L3N2Zz4="

TEST_ATTENDEE_ARGS = dict(
firstName="Test",
lastName="Testerson",
Expand Down Expand Up @@ -287,7 +289,7 @@ def setUp(self):
"volunteer": "false",
"volDepts": "",
"surveyOk": "false",
"signature_svg": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+PCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmVyc2lvbj0iMS4xIiB3aWR0aD0iNjI3IiBoZWlnaHQ9IjkwIj48cGF0aCBzdHJva2UtbGluZWpvaW49InJvdW5kIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlPSJyZ2IoODUsIDg1LCA4NSkiIGZpbGw9Im5vbmUiIGQ9Ik0gMSA1NSBjIDAuMDUgLTAuMjEgMS4yIC04LjU5IDMgLTEyIGMgNC4yIC03Ljk1IDEwLjE2IC0xNi41NSAxNiAtMjQgYyAzLjc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AwLjk0IDguNTMgMy4xNSAxMyA0IGMgMTYuNjMgMy4xNyA1MCA4IDUwIDgiLz48L3N2Zz4=",
"signature_svg": TEST_SIGNATURE_SVG,
}
self.attendee_form_2 = {
"firstName": "Bea",
Expand All @@ -307,6 +309,7 @@ def setUp(self):
"volunteer": "false",
"volDepts": "",
"surveyOk": "false",
"signature_svg": TEST_SIGNATURE_SVG,
}

self.attendee_form_upgrade = self.attendee_form_1
Expand Down
15 changes: 11 additions & 4 deletions registration/views/dealers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def new_dealer(request):
if event.dealerRegStart <= today <= event.dealerRegEnd:
return render(request, "registration/dealer/dealer-form.html", context)
elif event.dealerRegStart >= today:
context["message"] = "is not yet open. Please stay tuned to our social media for updates!"
context["message"] = (
"is not yet open. Please stay tuned to our social media for updates!"
)
return render(request, "registration/dealer/dealer-closed.html", context)
elif event.dealerRegEnd <= today:
context["message"] = "has ended."
Expand Down Expand Up @@ -406,7 +408,12 @@ def add_dealer(request):

attendee.save()

badge = Badge.objects.get(attendee=attendee, event=event)
badge = Badge.objects.get(
attendee=attendee,
event=event,
signature_svg=pda.get("signature_svg"),
signature_bitmap=pda.get("signature_bitmap"),
)
badge.badgeName = pda["badgeName"]

badge.save()
Expand Down Expand Up @@ -659,15 +666,15 @@ def get_dealer_total(orderItems, discount, dealer):
wifi = 0
power = 0
if dealer.needWifi:
wifi = 50
wifi = dealer.event.dealerWifiPrice
if dealer.needPower:
power = 0
paidTotal = dealer.paidTotal()
if discount:
itemSubTotal = get_discount_total(discount, itemSubTotal)
total = (
itemSubTotal
+ 55 * unpaidPartnerCount
+ dealer.event.dealerPartnerPrice * unpaidPartnerCount
+ partnerBreakfast
+ dealer.tableSize.basePrice
+ wifi
Expand Down