Artteiv AnhLedger commited on
Commit
27dbc87
1 Parent(s): 9b87900

Upload 17 files (#6)

Browse files

- Upload 17 files (081e2ac8500e63dff89222744cce7091e1388ac0)


Co-authored-by: Nguyen Nguyen Anh <[email protected]>

users/__init__.py ADDED
File without changes
users/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (203 Bytes). View file
 
users/__pycache__/admin.cpython-311.pyc ADDED
Binary file (258 Bytes). View file
 
users/__pycache__/apps.cpython-311.pyc ADDED
Binary file (572 Bytes). View file
 
users/__pycache__/models.cpython-311.pyc ADDED
Binary file (255 Bytes). View file
 
users/__pycache__/urls.cpython-311.pyc ADDED
Binary file (715 Bytes). View file
 
users/__pycache__/views.cpython-311.pyc ADDED
Binary file (2.41 kB). View file
 
users/admin.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.contrib import admin
2
+
3
+ # Register your models here.
users/apps.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class UsersConfig(AppConfig):
5
+ default_auto_field = 'django.db.models.BigAutoField'
6
+ name = 'users'
users/migrations/__init__.py ADDED
File without changes
users/migrations/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (214 Bytes). View file
 
users/templates/users/index.html ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Login V1</title>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1">
7
+
8
+ </head>
9
+ <body>
10
+
11
+ <div class="limiter">
12
+ <div class="container-login100">
13
+ <div class="wrap-login100">
14
+ <div class="login100-pic js-tilt" data-tilt>
15
+ <img src="images/img-01.png" alt="IMG">
16
+ </div>
17
+
18
+ <form class="login100-form validate-form">
19
+ <span class="login100-form-title">
20
+ Member Login
21
+ </span>
22
+
23
+ <div class="wrap-input100 validate-input" data-validate = "Valid email is required: [email protected]">
24
+ <input class="input100" type="text" name="email" placeholder="Email">
25
+ <span class="focus-input100"></span>
26
+ <span class="symbol-input100">
27
+ <i class="fa fa-envelope" aria-hidden="true"></i>
28
+ </span>
29
+ </div>
30
+
31
+ <div class="wrap-input100 validate-input" data-validate = "Password is required">
32
+ <input class="input100" type="password" name="pass" placeholder="Password">
33
+ <span class="focus-input100"></span>
34
+ <span class="symbol-input100">
35
+ <i class="fa fa-lock" aria-hidden="true"></i>
36
+ </span>
37
+ </div>
38
+
39
+ <div class="container-login100-form-btn">
40
+ <button class="login100-form-btn">
41
+ Login
42
+ </button>
43
+ </div>
44
+
45
+ <div class="text-center p-t-12">
46
+ <span class="txt1">
47
+ Forgot
48
+ </span>
49
+ <a class="txt2" href="#">
50
+ Username / Password?
51
+ </a>
52
+ </div>
53
+
54
+ <div class="text-center p-t-136">
55
+ <a class="txt2" href="#">
56
+ Create your Account
57
+ <i class="fa fa-long-arrow-right m-l-5" aria-hidden="true"></i>
58
+ </a>
59
+ </div>
60
+ </form>
61
+ </div>
62
+ </div>
63
+ </div>
64
+
65
+
66
+
67
+
68
+ <!--===============================================================================================-->
69
+ <script src="vendor/jquery/jquery-3.2.1.min.js"></script>
70
+ <!--===============================================================================================-->
71
+ <script src="vendor/bootstrap/js/popper.js"></script>
72
+ <script src="vendor/bootstrap/js/bootstrap.min.js"></script>
73
+ <!--===============================================================================================-->
74
+ <script src="vendor/select2/select2.min.js"></script>
75
+ <!--===============================================================================================-->
76
+ <script src="vendor/tilt/tilt.jquery.min.js"></script>
77
+ <script >
78
+ $('.js-tilt').tilt({
79
+ scale: 1.1
80
+ })
81
+ </script>
82
+ <!--===============================================================================================-->
83
+ <script src="js/main.js"></script>
84
+
85
+ </body>
86
+ </html>
users/templates/users/login.html ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>User Login</title>
7
+ <style>
8
+ /* CSS Styles for the form */
9
+ body {
10
+ background-color: #f2f2f2; /* Set the background color to light grey */
11
+ font-family: Arial, sans-serif; /* Use a common font */
12
+ display: flex;
13
+ justify-content: center;
14
+ align-items: center;
15
+ height: 100vh;
16
+ margin: 0;
17
+ }
18
+ .form-container {
19
+ background-color: #fff; /* White background for the form */
20
+ padding: 40px;
21
+ border-radius: 10px;
22
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); /* Add shadow for depth */
23
+ }
24
+ .form-with-validation input[type="text"],
25
+ .form-with-validation input[type="password"] {
26
+ width: 100%;
27
+ padding: 10px;
28
+ margin: 8px 0;
29
+ border: 1px solid #ccc;
30
+ border-radius: 5px;
31
+ box-sizing: border-box;
32
+ transition: border-color 0.3s ease;
33
+ }
34
+ .form-with-validation input[type="text"]:focus,
35
+ .form-with-validation input[type="password"]:focus {
36
+ border-color: #4CAF50; /* Green border on focus */
37
+ }
38
+ .form-submit {
39
+ background-color: #4CAF50; /* Green button */
40
+ border: none;
41
+ color: white;
42
+ padding: 15px 32px;
43
+ text-align: center;
44
+ text-decoration: none;
45
+ display: inline-block;
46
+ font-size: 16px;
47
+ border-radius: 5px;
48
+ cursor: pointer;
49
+ transition: background-color 0.3s ease;
50
+ }
51
+ .form-submit:hover {
52
+ background-color: #45a049; /* Darker green on hover */
53
+ }
54
+ h1 {
55
+ text-align: center;
56
+ color: #333; /* Dark grey for the heading */
57
+ }
58
+ </style>
59
+ </head>
60
+ <body>
61
+ <div class="form-container">
62
+ <h1>User Login</h1>
63
+ <form class="form-with-validation" action="{% url 'users:login' %}" method="post">
64
+ {% csrf_token %}
65
+ {{ form }}
66
+ {% if request.GET.next %}
67
+ <input type="hidden" name="next" value="{{ request.GET.next }}" />
68
+ {% endif %}
69
+ <button class="form-submit">Submit</button>
70
+ </form>
71
+ </div>
72
+ </body>
73
+ </html>
users/templates/users/register.html ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ {% block content %}
4
+ <!-- Inside your CSS file or <style> tag -->
5
+ <style>
6
+ body {
7
+ font-family: Arial, sans-serif;
8
+ background-color: #f9f9f9;
9
+ margin: 0;
10
+ padding: 0;
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ height: 100vh;
15
+ }
16
+
17
+ .form-container {
18
+ background-color: #fff;
19
+ border-radius: 10px;
20
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
21
+ padding: 40px;
22
+ width: 320px;
23
+ }
24
+
25
+ .form-group {
26
+ margin-bottom: 20px;
27
+ }
28
+
29
+ .form-group label {
30
+ display: block;
31
+ margin-bottom: 8px;
32
+ font-weight: bold;
33
+ }
34
+
35
+ .form-group input[type="text"],
36
+ .form-group input[type="password"] {
37
+ width: 100%;
38
+ padding: 10px;
39
+ border: 1px solid #ccc;
40
+ border-radius: 5px;
41
+ box-sizing: border-box;
42
+ }
43
+
44
+ .form-submit {
45
+ background-color: #4CAF50;
46
+ border: none;
47
+ color: #fff;
48
+ padding: 15px 20px;
49
+ text-align: center;
50
+ text-decoration: none;
51
+ display: block;
52
+ width: 100%;
53
+ border-radius: 5px;
54
+ cursor: pointer;
55
+ transition: background-color 0.3s ease;
56
+ }
57
+
58
+ .form-submit:hover {
59
+ background-color: #45a049;
60
+ }
61
+
62
+ h1 {
63
+ text-align: center;
64
+ color: #333;
65
+ margin-bottom: 30px;
66
+ }
67
+ </style>
68
+
69
+ <div class="form-container">
70
+ <h1>Register a New User</h1>
71
+ <form class="form-with-validation" action="{% url 'users:register' %}" method="post">
72
+ {% csrf_token %}
73
+ <div class="form-group">
74
+ <label for="id_username">Username:</label>
75
+ {{ form.username }}
76
+ </div>
77
+ <div class="form-group">
78
+ <label for="id_password1">Password:</label>
79
+ {{ form.password1 }}
80
+ </div>
81
+ <div class="form-group">
82
+ <label for="id_password2">Confirm Password:</label>
83
+ {{ form.password2 }}
84
+ </div>
85
+ <button class="form-submit" type="submit">Register</button>
86
+ </form>
87
+ </div>
88
+ {% endblock %}
users/tests.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.test import TestCase
2
+
3
+ # Create your tests here.
users/urls.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.urls import path
2
+ from . import views
3
+
4
+ app_name = 'users'
5
+
6
+ urlpatterns = [
7
+ path('register/', views.register_view, name="register"),
8
+ path('login/', views.login_view, name="login"),
9
+ path('logout/', views.logout_view, name="logout"),
10
+ # path('', views.index_view, name = "index")
11
+ ]
users/views.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.shortcuts import render, redirect
2
+ from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
3
+ from django.contrib.auth import login, logout
4
+ from chat.models import Chat, User
5
+ # Create your views here.
6
+ def register_view(request):
7
+ if request.method == "POST":
8
+ form = UserCreationForm(request.POST)
9
+ if form.is_valid():
10
+ login(request, form.save())
11
+ return redirect("chat:room")
12
+ else:
13
+ form = UserCreationForm()
14
+ return render(request, "users/register.html", { "form": form })
15
+
16
+ def login_view(request):
17
+ if request.user.is_authenticated:
18
+ return redirect("chat:room")
19
+ if request.method == "POST":
20
+ form = AuthenticationForm(data=request.POST)
21
+ if form.is_valid():
22
+ login(request, form.get_user())
23
+ #Get chat history of user
24
+
25
+ if 'next' in request.POST:
26
+ return redirect(request.POST.get('next'))
27
+ else:
28
+ return redirect("chat:room")
29
+ else:
30
+ form = AuthenticationForm()
31
+ return render(request, "users/login.html", { "form": form })
32
+
33
+ def logout_view(request):
34
+ if request.method == "POST":
35
+ logout(request)
36
+ return redirect("chat:room")
37
+
38
+ def index_view(request):
39
+ return render(request, "users/index.html")