Skip to content

Commit df40a68

Browse files
authored
Merge pull request #79 from HackAssistant/fixes
Fixed issues
2 parents c614985 + d87aa69 commit df40a68

File tree

10 files changed

+40
-25
lines changed

10 files changed

+40
-25
lines changed

Diff for: app/mixins.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ def get_fields(self):
108108
if name in api_fields:
109109
field['api'] = api_fields[name]
110110
if field['api'].get('restrict', False):
111-
field['field'].help_text += _("Please select one of the dropdown options or write 'Others'.")
111+
field['field'].help_text += _("Please select one of the autocomplete options "
112+
"or write 'Others'.")
112113
if not visible[field['field'].auto_id]:
113114
del visible[field['field'].auto_id]
114115
list_fields['visible'] = visible

Diff for: app/tables.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import django_tables2 as tables
2+
3+
4+
class FloatColumn(tables.Column):
5+
def __init__(self, float_digits=None, *args, **kwargs):
6+
self.float_digits = float_digits
7+
super().__init__(*args, **kwargs)
8+
9+
def render(self, value):
10+
if isinstance(value, float) and self.float_digits is not None:
11+
value = round(value, self.float_digits)
12+
return value

Diff for: app/templates/components/bootstrap5_form.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
field.removeClass('is-valid').addClass('is-invalid')
6464
let div_field = $('.mb-3').has('#{{ field.field.auto_id }}')
6565
div_field.find('.valid-feedback, .invalid-feedback').remove()
66-
field.after('<div class="invalid-feedback">{% translate 'Please select one of the dropdown options or write: Others' %}.</div>')
66+
field.after('<div class="invalid-feedback">{% translate 'Please select one of the autocomplete options or write: Others' %}.</div>')
6767
$([document.documentElement, document.body]).animate({
6868
scrollTop: div_field.offset().top
6969
}, 100)

Diff for: application/forms/base.py

-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ class Meta:
122122
'gender': _('This is for demographic purposes. You can skip this question if you want.'),
123123
'other_diet': _('Please fill here in your dietary requirements. '
124124
'We want to make sure we have food for you!'),
125-
'origin': "Please select one of the dropdown options or write 'Others'. If the dropdown doesn't show up,"
126-
" type following this schema: <strong>city, nation, country</strong>"
127125
}
128126
labels = {
129127
'gender': _('What gender do you identify as?'),

Diff for: application/templates/application_form.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% load perms %}
55
{% block subtitle %}{% if edit %}{% blocktrans %}{{ full_name }}'s {{ application_type }} application{% endblocktrans %}{% else %}{% blocktrans %}Applying as {{ application_type }}{% endblocktrans %}{% endif %}{% endblock %}
66
{% block content %}
7-
{% if edit or public %}
7+
{% if request.user.is_authenticated %}
88
<div class="row justify-content-between mb-3">
99
<div class="col-12 col-lg-2 d-grid d-md-block">
1010
<a href="{% if request.user.is_organizer and edit %}{% url 'application_detail' application_form.instance.get_uuid %}{% else %}{% url 'apply_home' %}{% endif %}" class="btn btn-secondary col-12"><i class="bi bi-caret-left-fill"></i> {% trans 'Back' %}</a>

Diff for: requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cryptography==38.0.3
88
defusedxml==0.7.1
99
Deprecated==1.2.13
1010
Django==4.0.8
11-
django-admin-honeypot @ https://github.com/dmpayton/django-admin-honeypot/archive/refs/heads/develop.zip
11+
django-admin-honeypot @ https://github.com/dmpayton/django-admin-honeypot/archive/a840496d183df89965eeb33c9a5dd9ea3919dfff.zip
1212
django-allauth==0.51.0
1313
django-appconf==1.0.5
1414
django-axes==5.39.0

Diff for: review/tables.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import django_tables2 as tables
22
from django.db.models import Avg, F, Count
33

4+
from app.tables import FloatColumn
45
from application.models import Application
56

67

@@ -11,8 +12,8 @@ class ApplicationTable(tables.Table):
1112
last_modified = tables.TemplateColumn(template_code='{{ record.last_modified|timesince }}',
1213
order_by='last_modified')
1314
votes = tables.Column(accessor='vote_count', verbose_name='Votes')
14-
1515
status = tables.TemplateColumn(template_name='tables/status.html')
16+
vote_avg = FloatColumn(float_digits=3)
1617

1718
@staticmethod
1819
def get_queryset(queryset):

Diff for: review/templates/application_detail.html

+10-10
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,34 @@ <h1 {% if application.user.under_age %}class="text-danger"{% endif %}>{% if vote
4343
</div>
4444
{% endif %}
4545
<div class="row">
46-
<div class="col-lg-3 fw-bold pb-3 text-lg-end">{% translate 'Full name' %}</div>
47-
<div class="col-lg-9 pb-3">{{ application.user.get_full_name }}</div>
46+
<div class="col-lg-3 fw-bold pb-3 text-lg-end text-break">{% translate 'Full name' %}</div>
47+
<div class="col-lg-9 pb-3 text-break">{{ application.user.get_full_name }}</div>
4848
</div>
4949
{% if not vote %}
5050
<div class="row">
51-
<div class="col-lg-3 fw-bold pb-3 text-lg-end">{% translate 'Email' %}</div>
52-
<div class="col-lg-9 pb-3">{{ application.user.email }}</div>
51+
<div class="col-lg-3 fw-bold pb-3 text-lg-end text-break">{% translate 'Email' %}</div>
52+
<div class="col-lg-9 pb-3 text-break">{{ application.user.email }}</div>
5353
</div>
5454
{% endif %}
5555
<div class="row">
56-
<div class="col-lg-3 fw-bold pb-3 text-lg-end">{% translate 'Status' %}</div>
57-
<div class="col-lg-9 pb-3">
56+
<div class="col-lg-3 fw-bold pb-3 text-lg-end text-break">{% translate 'Status' %}</div>
57+
<div class="col-lg-9 pb-3 text-break">
5858
{% include 'tables/status.html' with record=application %}
5959
</div>
6060
</div>
6161
{% if application.promotional_code %}
6262
<div class="row">
63-
<div class="col-lg-3 fw-bold pb-3 text-lg-end">{% translate 'Promotion' %}</div>
64-
<div class="col-lg-9 pb-3">
63+
<div class="col-lg-3 fw-bold pb-3 text-lg-end text-break">{% translate 'Promotion' %}</div>
64+
<div class="col-lg-9 pb-3 text-break">
6565
{% include 'tables/promotional_code.html' with record=application %}
6666
</div>
6767
</div>
6868
{% endif %}
6969
{% for name, data in details.items %}
7070
{% if name not in icons.keys and data != '' %}
7171
<div class="row">
72-
<div class="col-lg-3 fw-bold pb-3 text-lg-end">{{ name }}</div>
73-
<div class="col-lg-9 pb-3">{{ data }}</div>
72+
<div class="col-lg-3 fw-bold pb-3 text-lg-end text-break">{{ name }}</div>
73+
<div class="col-lg-9 pb-3 text-break">{{ data }}</div>
7474
</div>
7575
{% endif %}
7676
{% endfor %}

Diff for: user/forms.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class LoginForm(BootstrapFormMixin, forms.Form):
4242
bootstrap_field_info = {'': {'fields': [{'name': 'email', 'space': 12}, {'name': 'password', 'space': 12}]}}
4343

4444
email = forms.EmailField(label=_('Email'), max_length=100)
45-
password = forms.CharField(widget=forms.PasswordInput, label=_('Password'), max_length=100)
45+
password = forms.CharField(widget=forms.PasswordInput, label=_('Password'), max_length=128)
4646

4747
def clean_email(self):
4848
email = self.cleaned_data.get('email')
@@ -61,8 +61,8 @@ class UserCreationForm(BootstrapFormMixin, forms.ModelForm):
6161
{'name': 'email', 'space': 12}, {'name': 'password1', 'space': 12},
6262
{'name': 'password2', 'space': 12}]}}
6363

64-
password1 = forms.CharField(label=_('Password'), widget=forms.PasswordInput)
65-
password2 = forms.CharField(label=_('Password confirmation'), widget=forms.PasswordInput,
64+
password1 = forms.CharField(label=_('Password'), widget=forms.PasswordInput, max_length=128)
65+
password2 = forms.CharField(label=_('Password confirmation'), widget=forms.PasswordInput, max_length=128,
6666
help_text=password_validation.password_validators_help_text_html())
6767

6868
class Meta:
@@ -196,8 +196,6 @@ class Meta:
196196
'gender': _('This is for demographic purposes. You can skip this question if you want.'),
197197
'other_diet': _('Please fill here in your dietary requirements. '
198198
'We want to make sure we have food for you!'),
199-
'origin': "Please select one of the dropdown options or write 'Others'. If the dropdown doesn't show up,"
200-
" type following this schema: <strong>city, nation, country</strong>"
201199
}
202200
labels = {
203201
'gender': _('What gender do you identify as?'),

Diff for: user/views.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,14 @@ class Login(AuthTemplateViews):
7777
def add_axes_context(self, context):
7878
if not AxesProxyHandler.is_allowed(self.request):
7979
ip_address = get_client_ip_address(self.request)
80-
attempt = AccessAttempt.objects.get(ip_address=ip_address)
81-
time_left = (attempt.attempt_time + get_cool_off()) - timezone.now()
82-
minutes_left = int((time_left.total_seconds() + 59) // 60)
80+
attempt = AccessAttempt.objects\
81+
.filter(ip_address=ip_address, failures_since_start__gte=getattr(settings, 'AXES_FAILURE_LIMIT'))\
82+
.first()
83+
if attempt is not None:
84+
time_left = (attempt.attempt_time + get_cool_off()) - timezone.now()
85+
minutes_left = int((time_left.total_seconds() + 59) // 60)
86+
else:
87+
minutes_left = 5
8388
axes_error_message = _('Too many login attempts. Please try again in %s minutes.') % minutes_left
8489
context.update({'blocked_message': axes_error_message})
8590

0 commit comments

Comments
 (0)