Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some changes in code to avoid bug #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added base/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/forms.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added base/__pycache__/views.cpython-310.pyc
Binary file not shown.
Binary file added base/api/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added base/api/__pycache__/serializers.cpython-310.pyc
Binary file not shown.
Binary file added base/api/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added base/api/__pycache__/views.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added base/migrations/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class User(AbstractUser):

avatar = models.ImageField(null=True, default="avatar.svg")

USERNAME_FIELD = 'email'
USERNAME_FIELD = 'username'
REQUIRED_FIELDS = []


Expand Down
64 changes: 40 additions & 24 deletions base/templates/base/login_register.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{% extends 'main.html' %}

{% block content %}
{% extends 'main.html' %} {% block content %}
<main class="auth layout">

{% if page == 'login' %}
<div class="container">
<div class="layout__box">
Expand All @@ -17,24 +14,40 @@ <h2 class="auth__tagline">Find your study partner</h2>
<form class="form" action="" method="POST">
{% csrf_token %}
<div class="form__group form__group">
<label for="room_name">Email</label>
<input id="username" name="email" type="email" placeholder="e.g. [email protected] />
<label for="room_name">Username</label>
<input
id="username"
name="Username"
type="Username"
placeholder="e.g.
[email protected]"
/>
</div>
<div class=" form__group">
<div class="form__group">
<label for="password">Password</label>
<input id="password" name="password" type="password"
placeholder="&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;" />
<input
id="password"
name="password"
type="password"
placeholder="&bull;&bull;&bull;&bull;&bull;&bull;&bull;&bull;"
/>
</div>

<button class="btn btn--main" type="submit">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<svg
version="1.1"
xmlns="http://www.w3.org/2000/svg"
width="32"
height="32"
viewBox="0 0 32 32"
>
<title>lock</title>
<path
d="M27 12h-1v-2c0-5.514-4.486-10-10-10s-10 4.486-10 10v2h-1c-0.553 0-1 0.447-1 1v18c0 0.553 0.447 1 1 1h22c0.553 0 1-0.447 1-1v-18c0-0.553-0.447-1-1-1zM8 10c0-4.411 3.589-8 8-8s8 3.589 8 8v2h-16v-2zM26 30h-20v-16h20v16z">
</path>
d="M27 12h-1v-2c0-5.514-4.486-10-10-10s-10 4.486-10 10v2h-1c-0.553 0-1 0.447-1 1v18c0 0.553 0.447 1 1 1h22c0.553 0 1-0.447 1-1v-18c0-0.553-0.447-1-1-1zM8 10c0-4.411 3.589-8 8-8s8 3.589 8 8v2h-16v-2zM26 30h-20v-16h20v16z"
></path>
<path
d="M15 21.694v4.306h2v-4.306c0.587-0.348 1-0.961 1-1.694 0-1.105-0.895-2-2-2s-2 0.895-2 2c0 0.732 0.413 1.345 1 1.694z">
</path>
d="M15 21.694v4.306h2v-4.306c0.587-0.348 1-0.961 1-1.694 0-1.105-0.895-2-2-2s-2 0.895-2 2c0 0.732 0.413 1.345 1 1.694z"
></path>
</svg>

Login
Expand All @@ -60,25 +73,28 @@ <h3>Register</h3>
<h2 class="auth__tagline">Find your study partner</h2>

<form class="form" action="" method="POST">
{% csrf_token %}

{% for field in form %}
{% csrf_token %} {% for field in form %}
<div class="form__group form__group">
<label for="room_name">{{field.label}}</label>
{{field}}
</div>
{% endfor %}


<button class="btn btn--main" type="submit">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
<svg
version="1.1"
xmlns="http://www.w3.org/2000/svg"
width="32"
height="32"
viewBox="0 0 32 32"
>
<title>lock</title>
<path
d="M27 12h-1v-2c0-5.514-4.486-10-10-10s-10 4.486-10 10v2h-1c-0.553 0-1 0.447-1 1v18c0 0.553 0.447 1 1 1h22c0.553 0 1-0.447 1-1v-18c0-0.553-0.447-1-1-1zM8 10c0-4.411 3.589-8 8-8s8 3.589 8 8v2h-16v-2zM26 30h-20v-16h20v16z">
</path>
d="M27 12h-1v-2c0-5.514-4.486-10-10-10s-10 4.486-10 10v2h-1c-0.553 0-1 0.447-1 1v18c0 0.553 0.447 1 1 1h22c0.553 0 1-0.447 1-1v-18c0-0.553-0.447-1-1-1zM8 10c0-4.411 3.589-8 8-8s8 3.589 8 8v2h-16v-2zM26 30h-20v-16h20v16z"
></path>
<path
d="M15 21.694v4.306h2v-4.306c0.587-0.348 1-0.961 1-1.694 0-1.105-0.895-2-2-2s-2 0.895-2 2c0 0.732 0.413 1.345 1 1.694z">
</path>
d="M15 21.694v4.306h2v-4.306c0.587-0.348 1-0.961 1-1.694 0-1.105-0.895-2-2-2s-2 0.895-2 2c0 0.732 0.413 1.345 1 1.694z"
></path>
</svg>

Register
Expand All @@ -94,4 +110,4 @@ <h2 class="auth__tagline">Find your study partner</h2>
</div>
{% endif %}
</main>
{% endblock content %}
{% endblock content %}
2 changes: 1 addition & 1 deletion base/templates/base/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h3>About</h3>

<div class="roomList__header">
<div>
<h2>Study Rooms Hosted by dennis_ivy</a>
<h2>Study Rooms Hosted by {{user.user}}</a>
</h2>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion base/templates/base/update-user.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h3>Edit your profile</h3>


<div class="form__action">
<a class="btn btn--dark" href="index.html">Cancel</a>
<a class="btn btn--dark" href="{% url 'home' %}">Cancel</a>
<button class="btn btn--main" type="submit">Update</button>
</div>
</form>
Expand Down
6 changes: 3 additions & 3 deletions base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def loginPage(request):
return redirect('home')

if request.method == 'POST':
email = request.POST.get('email').lower()
username = request.POST.get('Username')
password = request.POST.get('password')

try:
user = User.objects.get(email=email)
user = User.objects.get(username)
except:
messages.error(request, 'User does not exist')

user = authenticate(request, email=email, password=password)
user = authenticate(request, username=username, password=password)

if user is not None:
login(request, user)
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
Binary file added studybud/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added studybud/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file added studybud/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added studybud/__pycache__/wsgi.cpython-310.pyc
Binary file not shown.