Skip to content

Commit 4a23373

Browse files
authored
Merge pull request #15 from HackAssistant/review
Review
2 parents fdcffb6 + ec6ae45 commit 4a23373

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1512
-228
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[flake8]
2-
exclude = build,.git,.tox,./django/utils/six.py,./django/conf/app_template/*,./tests/.env,./env,./app/settings.py,./*/migrations,./app/hackathon_variables.py,./venv
2+
exclude = build,.git,.tox,./django/utils/six.py,./django/conf/app_template/*,./tests/.env,./env,./app/settings.py,./*/migrations,./app/hackathon_variables.py,./venv,./*/apps.py
33
ignore = W601,F403,W504,F405
44
max-line-length = 120

app/emails.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pathlib import Path
33

44
from django.conf import settings
5-
from django.core.mail import send_mail
5+
from django.core.mail import EmailMultiAlternatives
66
from django.template.loader import render_to_string
77
from django.utils.html import strip_tags
88

@@ -12,23 +12,25 @@
1212
# Author Arnau Casas Saez
1313
class Email:
1414

15-
def __init__(self, name, context, list_mails) -> None:
15+
def __init__(self, name, context, to, request, **kwargs) -> None:
1616
super().__init__()
17+
self.kwargs = kwargs
1718
self.name = name
18-
self.list_mails = list_mails
19+
self.list_mails = [to, ] if isinstance(to, str) else to
20+
self.request = request
1921
self.context = context
2022
self.__get_subject__()
2123
self.__get_content__()
2224

2325
# Private method that renders and save the subject of the mail
2426
def __get_subject__(self):
2527
file_template = 'mails/%s.txt' % self.name
26-
self.subject = render_to_string(template_name=file_template, context=self.context)
28+
self.subject = render_to_string(template_name=file_template, context=self.context, request=self.request)
2729

2830
# Private method that renders and save the HTML content of the mail
2931
def __get_content__(self):
3032
file_template = 'mails/%s.html' % self.name
31-
self.html_message = render_to_string(template_name=file_template, context=self.context)
33+
self.html_message = render_to_string(template_name=file_template, context=self.context, request=self.request)
3234
self.plain_message = strip_tags(self.html_message)
3335

3436
# Public method that sends the mail to [list_mails] if not debug else saves the file at mails folder
@@ -48,8 +50,8 @@ def send(self):
4850
with open(final_path, "w", encoding='utf-8') as text_file:
4951
text_file.write(self.html_message)
5052
else:
51-
send_mail(subject=self.subject,
52-
message=self.plain_message,
53-
from_email=email_from,
54-
recipient_list=self.list_mails,
55-
html_message=self.html_message)
53+
msg = EmailMultiAlternatives(subject=self.subject, body=self.plain_message, from_email=email_from,
54+
to=self.list_mails, **self.kwargs)
55+
msg.attach_alternative(self.html_message, "text/html")
56+
msg.content_subtype = "html"
57+
msg.send()

app/hackathon_variables.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
HACKATHON_NAME = 'HackUPC'
22
HACKATHON_DESCRIPTION = 'Join us for BarcelonaTech\'s hackathon. 36h. 29th April - 1st May.'
33
HACKATHON_ORG = 'Hackers@UPC'
4-
HACKATHON_CONTACT_EMAIL = ''
5-
HACKATHON_SOCIALS = [('https://www.facebook.com/hackupc', 'bi-facebook'),
6-
('https://www.instagram.com/hackupc/', 'bi-instagram'),
7-
('https://twitter.com/hackupc', 'bi-twitter'),
8-
('https://www.youtube.com/channel/UCiiRorGg59Xd5Sjj9bjIt-g', 'bi-youtube'),
9-
('https://www.twitch.tv/hackersupc?lang=es', 'bi-twitch'),
10-
('mailto:[email protected]', 'bi-envelope'),
11-
('https://github.com/HackAssistant', 'bi-github'), ]
4+
5+
HACKATHON_CONTACT_EMAIL = '[email protected]'
6+
HACKATHON_SOCIALS = {'Facebook': ('https://www.facebook.com/hackupc', 'bi-facebook'),
7+
'Instagram': ('https://www.instagram.com/hackupc/', 'bi-instagram'),
8+
'Twitter': ('https://twitter.com/hackupc', 'bi-twitter'),
9+
'Youtube': ('https://www.youtube.com/channel/UCiiRorGg59Xd5Sjj9bjIt-g', 'bi-youtube'),
10+
'Twitch': ('https://www.twitch.tv/hackersupc?lang=es', 'bi-twitch'),
11+
'Github': ('https://github.com/HackAssistant', 'bi-github'), }
12+
if HACKATHON_CONTACT_EMAIL:
13+
HACKATHON_SOCIALS['Contact'] = ('mailto:' + HACKATHON_CONTACT_EMAIL, 'bi-envelope')
14+
1215
HACKATHON_LANDING = 'https://hackupc.com'
1316
REGEX_HACKATHON_ORGANIZER_EMAIL = "^.*@hackupc\.com$"
1417
HACKATHON_ORGANIZER_EMAILS = []

app/mixins.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ def get_back_url(self):
1414
return None
1515

1616
def get_context_data(self, **kwargs):
17-
c = super(TabsViewMixin, self).get_context_data(**kwargs)
18-
c.update({'tabs': self.get_current_tabs(), 'back': self.get_back_url()})
19-
return c
17+
context = super(TabsViewMixin, self).get_context_data(**kwargs)
18+
tabs = self.get_current_tabs()
19+
new_tabs = []
20+
for tab in tabs:
21+
new_tab = {'title': tab[0], 'url': tab[1], 'needs_action': tab[2] if len(tab) > 2 else None,
22+
'active': tab[3] if len(tab) > 3 else None}
23+
new_tabs.append(new_tab)
24+
context.update({'tabs': new_tabs, 'back': self.get_back_url()})
25+
return context
2026

2127

2228
class OverwriteOnlyModelFormMixin(object):

app/settings.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,15 @@
4747
'django.contrib.sessions',
4848
'django.contrib.messages',
4949
'django.contrib.staticfiles',
50+
'django_tables2',
51+
'django_filters',
5052
'django_jwt',
5153
'django_jwt.server',
5254
'django_bootstrap5',
5355
'corsheaders',
5456
'user',
5557
'application',
58+
'review',
5659
]
5760

5861
MIDDLEWARE = [
@@ -79,6 +82,7 @@
7982
'django.template.context_processors.request',
8083
'django.contrib.auth.context_processors.auth',
8184
'django.contrib.messages.context_processors.messages',
85+
'django.template.context_processors.request',
8286
'app.template.app_variables',
8387
],
8488
'libraries': {
@@ -170,6 +174,8 @@
170174
'JWT_EXPIRATION_TIME': 14400 # Optional
171175
}
172176

177+
DJANGO_TABLES2_TEMPLATE = 'django_tables2/bootstrap-responsive.html'
178+
173179
# Toast styles
174180
MESSAGE_TAGS = {
175181
message_constants.DEBUG: 'info text-dark',
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.br-theme-bars-square .br-widget {
2+
height: 15px;
3+
white-space: nowrap;
4+
}
5+
.br-theme-bars-square .br-widget a {
6+
display: block;
7+
width: 40px;
8+
height: 40px;
9+
float: left;
10+
border: 2px solid;
11+
margin: 2px;
12+
text-decoration: none;
13+
font-size: 17px;
14+
line-height: 2;
15+
text-align: center;
16+
color: inherit;
17+
font-weight: 600;
18+
}
19+
.br-theme-bars-square .br-widget a.br-active,
20+
.br-theme-bars-square .br-widget a.br-selected {
21+
border: 2px solid;
22+
}
23+
.br-theme-bars-square .br-widget .br-current-rating {
24+
clear: both;
25+
width: 330px;
26+
text-align: center;
27+
font-weight: 600;
28+
display: block;
29+
padding: .5em 0;
30+
}
31+
.br-theme-bars-square .br-readonly a {
32+
cursor: default;
33+
}
34+
.br-theme-bars-square .br-readonly a.br-active,
35+
.br-theme-bars-square .br-readonly a.br-selected {
36+
border: 2px solid;
37+
}
38+
@media print {
39+
.br-theme-bars-square .br-widget a {
40+
border: 2px solid;
41+
}
42+
.br-theme-bars-square .br-widget a.br-active,
43+
.br-theme-bars-square .br-widget a.br-selected {
44+
border: 2px solid;
45+
}
46+
}

app/static/css/main.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,52 @@ body.light {
4141
.content {
4242
font-size: 15px;
4343
}
44+
4445
footer {
4546
margin-top: auto;
4647
}
48+
49+
.orderable > a {
50+
text-decoration: none;
51+
}
52+
53+
.orderable {
54+
position: relative;
55+
}
56+
57+
.orderable > a:before,
58+
.orderable > a:after {
59+
border: 4px solid transparent;
60+
content: "";
61+
display: block;
62+
height: 0;
63+
right: 10px;
64+
top: 50%;
65+
position: absolute;
66+
width: 0;
67+
}
68+
.orderable > a:before {
69+
margin-top: -9px;
70+
border-bottom-color: currentColor;
71+
}
72+
.orderable > a:after {
73+
margin-top: 1px;
74+
border-top-color: currentColor;
75+
}
76+
.orderable.desc > a:before {
77+
border-bottom-color: transparent;
78+
}
79+
.orderable.asc > a:after {
80+
border-top-color: transparent;
81+
}
82+
83+
.table-container {
84+
overflow-x: auto;
85+
-webkit-overflow-scrolling: touch;
86+
}
87+
88+
@media (max-width: 992px) { /* Bootstrap lg */
89+
.border-lg {
90+
border: 0 !important;
91+
}
92+
}

app/static/lib/jquery.barrating.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/template.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,19 @@
55

66

77
def get_main_nav(request):
8+
nav = []
89
if not request.user.is_authenticated:
9-
return []
10+
if getattr(settings, 'HACKATHON_LANDING', None) is not None:
11+
nav.append(('Landing page', getattr(settings, 'HACKATHON_LANDING')))
12+
return nav
1013
if not request.user.is_organizer():
11-
nav = []
1214
if getattr(settings, 'HACKATHON_LANDING', None) is not None:
1315
nav.append(('Landing page', getattr(settings, 'HACKATHON_LANDING')))
1416
return nav
15-
return [
16-
('Hacker', reverse('home')),
17-
('Event', [
18-
('Activities', '/'),
19-
('Meals', '/'),
20-
('HardwareLab', '/'),
21-
('Baggage', '/'),
22-
('CheckIn', '/'), ]
23-
)
24-
]
17+
if request.user.is_staff:
18+
nav.append(('Admin', reverse('admin:index')))
19+
nav.extend([('Review', reverse('application_review')), ])
20+
return nav
2521

2622

2723
def app_variables(request):
@@ -32,6 +28,7 @@ def app_variables(request):
3228
'app_author': getattr(settings, 'HACKATHON_ORG'),
3329
'app_name': getattr(settings, 'APP_NAME'),
3430
'app_socials': getattr(settings, 'HACKATHON_SOCIALS', []),
31+
'app_contact': getattr(settings, 'HACKATHON_CONTACT_EMAIL', ''),
3532
'app_theme': getattr(settings, 'THEME') == 'both',
3633
'app_landing': getattr(settings, 'HACKATHON_LANDING'),
3734
'theme': get_theme(request),

app/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{% include 'components/favicon.html' %}
1717
</head>
1818
<body class="{{ theme }}" style="min-height: 100%">
19-
<div class="background" style="display: flex; flex-direction: column;">
19+
<div class="background" style="display: flex; flex-direction: column; width: 100%">
2020
{% block navbar %}
2121
<nav class="navbar navbar-default navbar-fixed-top navbar-expand-xl bg-{{ theme }} navbar-{{ theme }}">
2222
<div class="container-lg">

0 commit comments

Comments
 (0)