Skip to content

Commit ec0bf25

Browse files
committed
new logo
1 parent 917ad66 commit ec0bf25

File tree

9 files changed

+43
-33
lines changed

9 files changed

+43
-33
lines changed

templates/index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99
{% block content %}
1010

11-
<div class="blue lighten-5">
11+
<div class="white">
1212
<div class="row" style="margin-bottom: 0px">
1313
<div class="col m3">
1414
</div>
1515
<div class="col s12 m6">
1616
<div class="card">
1717
<div class="card-content" style="padding: 5px;">
18-
<h3 class="header center orange-text">Welcome to {{ ssid }}</h3>
18+
<h3 class="header center orange-text">Welcome to <b>{{ ssid }}</b></h3>
1919
</div>
2020

2121
</div>
@@ -37,8 +37,9 @@ <h4 class="header col s12 light">Connected!</h4>
3737

3838
<div class="col s12 m4">
3939
<div class="icon-block center">
40-
<img src="{% static 'img/unlock.png' %}">
41-
<h5 class="light">You've got a {{ timeout }} minutes of free navigation!</h5>
40+
<img src="{{ logo }}">
41+
<h5 class="light">You've got {{ timeout }} minutes of free navigation!</h5>
42+
<h5 class="light">Close this page and enjoy!</h5>
4243
</div>
4344
</div>
4445
<div class="col s12 m4">

templates/login.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
{% block formbody %}
1616

17-
{% include form.logo %}
17+
<p style="text-align:center"> <img src="{{ logo }}"> </p>
18+
<br>
1819

1920
<div style='text-align:center;margin-bottom: 30px'>
2021
<h6>Welcome to <b>{{ ssid }}</b> free WIFI</h6>

templates/registration.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
{% block formtitle %}{% endblock %}
1414

1515
{% block formbody %}
16-
{% include form.logo %}
16+
17+
<p style="text-align:center"> <img src="{{ logo }}"></p><br>
1718

1819
<div style='text-align:center;margin-bottom: 30px'>
1920
<h6>Register to <b>{{ ssid }}</b> free WIFI</h6>

unifi_portal/context_processor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
def unifi_context(request):
44
ctx = {
5+
'logo': settings.UNIFI_LOGO,
56
'ssid': settings.UNIFI_SSID,
67
'timeout': settings.UNIFI_TIMEOUT_MINUTES
78
}

unifi_portal/forms.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from django.template import Template
44
from django.contrib.auth.forms import User
55
from django.contrib.auth.forms import AuthenticationForm
6+
from django.conf import settings
67

7-
from material import Layout, Row, Column, Fieldset, Span2, Span3, Span5, Span6, Span10
8+
from material import Layout, Row, Fieldset
89
from . import form_mixin as forms
910

1011
class UnifiLoginForm(AuthenticationForm):
@@ -19,11 +20,6 @@ class UnifiLoginForm(AuthenticationForm):
1920
{% endform %}
2021
""")
2122

22-
logo = Template("""
23-
<p style="text-align:center"> <img src="/static/img/DjangoUnifi.png"> </p>
24-
<br>
25-
""")
26-
2723
social_buttons = Template("""
2824
<p style="text-align:center"><a href="/auth/login/facebook" class="waves-effect waves-light btn-large blue"><i class="fa fa-facebook" aria-hidden="true"></i> Sign in with facebook</a></p>
2925
<br>
@@ -69,11 +65,6 @@ class UnifiRegistrationForm(ModelForm):
6965
{% endform %}
7066
""")
7167

72-
logo = Template("""
73-
<p style="text-align:center"> <img src="/static/img/DjangoUnifi.png"> </p>
74-
<br>
75-
""")
76-
7768
buttons = Template("""
7869
<button class="waves-effect waves-light btn" type="submit">Submit</button>
7970
""")
-18.5 KB
Binary file not shown.

unifi_portal/static/img/logo.png

-16.3 KB
Binary file not shown.

unifi_portal/static/img/unlock.png

-38.6 KB
Binary file not shown.

unifi_portal/views.py

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from django.contrib.auth import REDIRECT_FIELD_NAME, login as auth_login, logout as auth_logout
1515
from django.contrib.auth.models import User
1616
from django.utils.decorators import method_decorator
17-
from django.views import View
17+
from django.views.generic import TemplateView
1818
from django.views.decorators.cache import never_cache
1919
from django.views.decorators.csrf import csrf_protect
2020
from django.views.decorators.debug import sensitive_post_parameters
@@ -26,7 +26,7 @@
2626
from unifi_portal.models import UnifiUser
2727

2828

29-
class UserAuthorizeView(SingleObjectMixin, View):
29+
class UserAuthorizeView(SingleObjectMixin, TemplateView):
3030
""" Authorize a guest based on parameters passed through the request. """
3131

3232
template_name = 'index.html'
@@ -40,26 +40,26 @@ def get_user_profile_inst(self):
4040
up = None;
4141
return up;
4242

43-
def post(self, request, *args, **kwargs):
44-
return HttpResponseForbidden();
43+
def get_context_data(self, **kwargs):
44+
"""Update view context."""
45+
#context = super(UserAuthorizeView, self).get_context_data(**kwargs)
46+
context={}
4547

46-
def get(self, request, *args, **kwargs):
47-
ctx = {}
4848
try:
49-
_mac = request.GET.get('id', '')
50-
_ap = request.GET.get('ap', '')
51-
_url = request.GET.get('url', '')
52-
# _t = request.GET.get('t', '')
49+
_mac = self.request.GET.get('id', '')
50+
_ap = self.request.GET.get('ap', '')
51+
_url = self.request.GET.get('url', '')
52+
# _t = self.request.GET.get('t', '')
5353
_t = settings.UNIFI_TIMEOUT_MINUTES
5454
_last_login = time.strftime("%c")
5555

56-
ctx = {
56+
context.update({
5757
'guest_mac': _mac,
5858
'ap_mac': _ap,
5959
'minutes': _t,
6060
'url': _url,
6161
'last_login': _last_login
62-
}
62+
})
6363

6464
# Saving info on userprofile Model
6565
userprofile = self.get_user_profile_inst()
@@ -71,12 +71,27 @@ def get(self, request, *args, **kwargs):
7171
unifi_client = UnifiClient()
7272
unifi_client.send_authorization(_mac, _ap, _t)
7373

74-
if _url:
75-
return HttpResponseRedirect(_url)
76-
except:
74+
#if _url:
75+
# return HttpResponseRedirect(_url)
76+
except Exception as exp_debug:
77+
print "EXCEPTION: " + str(exp_debug)
7778
pass
7879

79-
return render_to_response('index.html', ctx, RequestContext(request))
80+
return context
81+
82+
def post(self, request, *args, **kwargs):
83+
"""Deny post requests."""
84+
return HttpResponseForbidden();
85+
86+
def get(self, request, *args, **kwargs):
87+
"""Response with rendered html template."""
88+
context = self.get_context_data()
89+
90+
if '_url' in context:
91+
if context['_url']: #if i try to go on an url without wifi login
92+
return HttpResponseRedirect(context['_url'])
93+
94+
return self.render_to_response(context)
8095

8196
@method_decorator(login_required)
8297
def dispatch(self, request, *args, **kwargs):

0 commit comments

Comments
 (0)