-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
HYXC
committed
Sep 12, 2017
1 parent
14c1bf7
commit 8b8efca
Showing
11 changed files
with
221 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.http import HttpResponseRedirect | ||
import functools | ||
|
||
# Create your decorators here. | ||
def login_required(func): | ||
@functools.wraps(func) | ||
def wrapper(request,*args, **kw): | ||
user = request.session.get('username') | ||
if user is not None: | ||
return func(request,*args, **kw) | ||
else: | ||
return HttpResponseRedirect('/accounts/login/') | ||
return wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django import forms | ||
|
||
# Create your forms here. | ||
class UserForm(forms.Form): | ||
username = forms.CharField(max_length=30) | ||
password = forms.CharField(widget=forms.PasswordInput()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.conf.urls import url | ||
from . import views | ||
|
||
urlpatterns = [ | ||
url(r'^login/$', views.login, name='login'), | ||
url(r'^logout/$', views.logout, name='logout'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% extends 'base.html' %} | ||
{% block title %}DashBoard{% endblock %} | ||
|
||
{% block content %} | ||
<nav class="navbar navbar-inverse navbar-static-top" role="navigation" style="margin-bottom: 0"> | ||
<div class="navbar-header"> | ||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | ||
<span class="sr-only">Toggle navigation</span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
<a class="navbar-brand" href="#">Blackjack</a> | ||
</div> | ||
<!-- /.navbar-header --> | ||
|
||
<ul class="nav navbar-top-links navbar-right"> | ||
|
||
<!-- /.dropdown --> | ||
<li class="dropdown"> | ||
<label style="color: #C2C2C2">欢迎你,{{ request.session.username }}!</label> | ||
</li> | ||
<li class="dropdown"> | ||
<a class="dropdown-toggle" data-toggle="dropdown" href="#"> | ||
<i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i> | ||
</a> | ||
<ul class="dropdown-menu dropdown-user"> | ||
<li><a href="#"><i class="fa fa-user fa-fw"></i> User Profile</a> | ||
</li> | ||
<li><a href="#"><i class="fa fa-gear fa-fw"></i> Settings</a> | ||
</li> | ||
<li class="divider"></li> | ||
<li><a href="{% url 'logout' %}"><i class="fa fa-sign-out fa-fw"></i> Logout</a> | ||
</li> | ||
</ul> | ||
<!-- /.dropdown-user --> | ||
</li> | ||
<!-- /.dropdown --> | ||
</ul> | ||
<!-- /.navbar-top-links --> | ||
</nav> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{% extends 'base.html' %} | ||
{% block title %}BlackJack 平台{% endblock %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-4 col-md-offset-4"> | ||
<div class="login-panel panel panel-default"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">BlackJack用户登录</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<form method='post' role="form"> | ||
<fieldset> | ||
{% csrf_token %} | ||
<div class="form-group"> | ||
<input class="form-control" name="username" type="text" autofocus> | ||
</div> | ||
<div class="form-group"> | ||
<input class="form-control" placeholder="Password" name="password" type="password" value=""> | ||
</div> | ||
<div class="checkbox"> | ||
<label> | ||
<input name="remember" type="checkbox" value="Remember Me">Remember Me | ||
</label> | ||
</div> | ||
<!-- Change this to a button or input when using this as a form --> | ||
<button type="submit" class="btn btn-lg btn-success btn-block">登录</button> | ||
</fieldset> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
|
||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<meta name="description" content=""> | ||
<meta name="author" content=""> | ||
|
||
<title>{% block title %}blackjack{% endblock %}</title> | ||
{% load staticfiles %} | ||
|
||
<!-- Bootstrap Core CSS --> | ||
<link href="{% static "vendor/bootstrap/css/bootstrap.min.css" %}" rel="stylesheet"> | ||
|
||
<!-- MetisMenu CSS --> | ||
<link href="{% static "vendor/metisMenu/metisMenu.min.css" %}" rel="stylesheet"> | ||
|
||
<!-- Custom CSS --> | ||
<link href="{% static "dist/css/sb-admin-2.css" %}" rel="stylesheet"> | ||
|
||
<!-- Morris Charts CSS --> | ||
<link href="{% static "vendor/morrisjs/morris.css" %}" rel="stylesheet"> | ||
|
||
<!-- Custom Fonts --> | ||
<link href="{% static "vendor/font-awesome/css/font-awesome.min.css" %}" rel="stylesheet" type="text/css"> | ||
|
||
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> | ||
<!-- WARNING: Respond.js doesn't work if you view the page via file:// --> | ||
<!--[if lt IE 9]> | ||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> | ||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> | ||
<![endif]--> | ||
{% block style %} | ||
{% endblock %} | ||
|
||
</head> | ||
|
||
<body> | ||
|
||
<div id="wrapper"> | ||
{% block content %} | ||
{% endblock %} | ||
</div> | ||
<!-- /#wrapper --> | ||
|
||
<!-- jQuery --> | ||
<script src="{% static "vendor/jquery/jquery.min.js" %}"></script> | ||
|
||
<!-- Bootstrap Core JavaScript --> | ||
<script src="{% static "vendor/bootstrap/js/bootstrap.min.js" %}"></script> | ||
|
||
<!-- Metis Menu Plugin JavaScript --> | ||
<script src="{% static "vendor/metisMenu/metisMenu.min.js" %}"></script> | ||
|
||
<!-- Morris Charts JavaScript --> | ||
<script src="{% static "vendor/raphael/raphael.min.js" %}"></script> | ||
<script src="{% static "vendor/morrisjs/morris.min.js" %}"></script> | ||
<script src="{% static "data/morris-data.js" %}"></script> | ||
|
||
<!-- Custom Theme JavaScript --> | ||
<script src="{% static "dist/js/sb-admin-2.js" %}"></script> | ||
{% block jquery %} | ||
{% endblock %} | ||
|
||
</body> | ||
|
||
</html> |