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

Dev #119

Merged
merged 64 commits into from
Dec 26, 2023
Merged

Dev #119

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
87c6305
User(AbstractUser) is implemented.
Jamshidbek2000 Dec 19, 2023
92899d8
Login implemented. Temporary users_list was added for testing
Jamshidbek2000 Dec 20, 2023
900e62a
User has new field: profile_picture. We can save pictures
Jamshidbek2000 Dec 20, 2023
4de4693
User picture is implemented
Jamshidbek2000 Dec 22, 2023
6ca256d
login options auth/email
zstenger93 Dec 24, 2023
7254dd7
translations for the login types
zstenger93 Dec 24, 2023
f600974
disabled instant autocomplete for fields and addedd language button f…
zstenger93 Dec 24, 2023
7900536
Merge pull request #96 from zstenger93/frontend
zstenger93 Dec 24, 2023
3491efa
fixing ask for email via 42
zstenger93 Dec 24, 2023
4906e60
login test fix
zstenger93 Dec 24, 2023
02ea5d1
Merge pull request #97 from zstenger93/frontend
zstenger93 Dec 24, 2023
bf2d925
Merge pull request #98 from zstenger93/ci/cd_tests
zstenger93 Dec 24, 2023
cf0ef87
app layout change, 404 page
zstenger93 Dec 24, 2023
96650b9
added translation for 404 tho it's ain't persisting if u just type wr…
zstenger93 Dec 24, 2023
5c5cf45
wrapper change for different backgrounds
zstenger93 Dec 24, 2023
437ccfd
fix for wrapper
zstenger93 Dec 24, 2023
926a891
wtb better background images
zstenger93 Dec 24, 2023
64259c9
need to try if async page data tests are working now or not
zstenger93 Dec 24, 2023
c7e981c
different button style \..O../
zstenger93 Dec 24, 2023
54ab644
Merge pull request #100 from zstenger93/frontend
zstenger93 Dec 25, 2023
77c67b0
Merge pull request #99 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
44bcb56
picture extracted from 42API. Started working on FriendRequest
Jamshidbek2000 Dec 25, 2023
487dfd4
Merge branch 'dev' into user_management
zstenger93 Dec 25, 2023
1700f65
Merge pull request #101 from zstenger93/user_management
zstenger93 Dec 25, 2023
b0ecbca
3rd test fix try to init root at start
zstenger93 Dec 25, 2023
ca65ebc
Merge pull request #102 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
9d1e29b
testing is fun, sarcasm intended
zstenger93 Dec 25, 2023
7ca679e
Merge pull request #103 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
d157a66
commented out crashing test
zstenger93 Dec 25, 2023
1404c64
compose fix
zstenger93 Dec 25, 2023
d00ae62
Merge branch 'dev' into ci/cd_tests
zstenger93 Dec 25, 2023
e161d7d
Merge pull request #104 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
84bddf7
json bourne fixed
zstenger93 Dec 25, 2023
d79a67b
Merge branch 'ci/cd_tests' of https://github.com/zstenger93/Transcend…
zstenger93 Dec 25, 2023
aa8ce00
Merge pull request #105 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
74ab61d
reaintalled node modules..
zstenger93 Dec 25, 2023
c27c986
Merge pull request #106 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
4da8307
rollback coz node modules .. fck node modules..
zstenger93 Dec 25, 2023
df55756
ffffuuuuuu
zstenger93 Dec 25, 2023
3e9a3cc
Merge pull request #107 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
e752875
detailed logs
zstenger93 Dec 25, 2023
ee1f804
Merge pull request #108 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
3dc51f4
wtf
zstenger93 Dec 25, 2023
e7026d4
Merge pull request #109 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
8d2599d
fck json
zstenger93 Dec 25, 2023
5266898
Merge pull request #110 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
87529ab
another node reinstall
zstenger93 Dec 25, 2023
d3ac527
Merge pull request #111 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
5a0f7e9
god sake u srs
zstenger93 Dec 25, 2023
b2d9beb
Merge pull request #112 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
412c8f6
..
zstenger93 Dec 25, 2023
8d2a8c1
Merge pull request #113 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
b995132
.
zstenger93 Dec 25, 2023
b66e9ac
Merge pull request #114 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
45aac8b
won't touch this shit anytime soon again
zstenger93 Dec 25, 2023
6cfbfa3
Merge pull request #115 from zstenger93/ci/cd_tests
zstenger93 Dec 25, 2023
6c3c52f
meaningful comment
zstenger93 Dec 25, 2023
2b6f8ba
Merge pull request #116 from zstenger93/frontend
zstenger93 Dec 25, 2023
0719abd
homepage property
zstenger93 Dec 25, 2023
440f4b2
Merge pull request #117 from zstenger93/frontend
zstenger93 Dec 25, 2023
2321e3a
responsive welcome message
zstenger93 Dec 25, 2023
c9c5798
hamburger menu on small screen
zstenger93 Dec 25, 2023
7721d5e
hamburger menu icons
zstenger93 Dec 25, 2023
a8e5461
Merge pull request #118 from zstenger93/frontend
zstenger93 Dec 26, 2023
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
4 changes: 4 additions & 0 deletions .github/workflows/build_and_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
working-directory: frontend
run: npm install

- name: Print npm log
if: failure()
run: cat /home/runner/.npm/_logs/*.log

- name: Build Frontend
working-directory: frontend
run: npm run build
Expand Down
13 changes: 11 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


# dependencies
*/node_modules
node_modules
*/.pnp
*.pnp.js

Expand All @@ -44,4 +44,13 @@
*yarn-debug.log*
*yarn-error.log*

node_modules
# Jamshidbek
to-do.txt
jsonuser.json

# backend/authentication
backend/authentication/images/*

# media
media
node_modules
2 changes: 2 additions & 0 deletions backend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd backend && source venv/bin/activate
python manage.py makemigrations && python manage.py migrate
3 changes: 3 additions & 0 deletions backend/authentication/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from django.contrib import admin
from .models import User

# Register your models here.

admin.site.register(User)
30 changes: 25 additions & 5 deletions backend/authentication/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Generated by Django 5.0 on 2023-12-10 07:48
# Generated by Django 5.0 on 2023-12-19 09:26

import django.contrib.auth.models
import django.contrib.auth.validators
import django.utils.timezone
from django.db import migrations, models


Expand All @@ -8,17 +11,34 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('auth', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='User',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=255)),
('display_name', models.CharField(max_length=255)),
('email', models.EmailField(max_length=254)),
('picture', models.URLField()),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')),
('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')),
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')),
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
],
options={
'verbose_name': 'user',
'verbose_name_plural': 'users',
'abstract': False,
},
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
]
18 changes: 0 additions & 18 deletions backend/authentication/migrations/0002_alter_user_id.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.0 on 2023-12-20 09:36

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('authentication', '0001_initial'),
]

operations = [
migrations.AddField(
model_name='user',
name='losses',
field=models.PositiveIntegerField(default=0),
),
migrations.AddField(
model_name='user',
name='total_matches',
field=models.PositiveIntegerField(default=0),
),
migrations.AddField(
model_name='user',
name='wins',
field=models.PositiveIntegerField(default=0),
),
]
17 changes: 0 additions & 17 deletions backend/authentication/migrations/0003_delete_user.py

This file was deleted.

18 changes: 18 additions & 0 deletions backend/authentication/migrations/0003_user_picture.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2023-12-20 10:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('authentication', '0002_user_losses_user_total_matches_user_wins'),
]

operations = [
migrations.AddField(
model_name='user',
name='picture',
field=models.ImageField(blank=True, default='default_profile_picture.PNG', null=True, upload_to='authentication/images/'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2023-12-20 10:22

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('authentication', '0003_user_picture'),
]

operations = [
migrations.RenameField(
model_name='user',
old_name='picture',
new_name='profile_picture',
),
]
18 changes: 18 additions & 0 deletions backend/authentication/migrations/0005_user_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2023-12-21 10:00

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('authentication', '0004_rename_picture_user_profile_picture'),
]

operations = [
migrations.AddField(
model_name='user',
name='title',
field=models.CharField(blank=True, max_length=100, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 5.0 on 2023-12-21 12:39

import authentication.models
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('authentication', '0005_user_title'),
]

operations = [
migrations.AlterField(
model_name='user',
name='profile_picture',
field=models.ImageField(blank=True, default='default_profile_picture.PNG', null=True, upload_to=authentication.models.user_profile_picture_path),
),
]
25 changes: 25 additions & 0 deletions backend/authentication/migrations/0007_friendrequest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.0 on 2023-12-22 13:23

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('authentication', '0006_alter_user_profile_picture'),
]

operations = [
migrations.CreateModel(
name='FriendRequest',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('status', models.CharField(choices=[('pending', 'Pending'), ('accepted', 'Accepted'), ('rejected', 'Rejected')], default='pending', max_length=10)),
('timestamp', models.DateTimeField(auto_now_add=True)),
('from_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='friend_requests_sent', to=settings.AUTH_USER_MODEL)),
('to_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='friend_requests_received', to=settings.AUTH_USER_MODEL)),
],
),
]
43 changes: 42 additions & 1 deletion backend/authentication/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
from django.db import models

from django.contrib.auth.models import AbstractUser
from .utils import user_profile_picture_path
# Create your models here.

class User(AbstractUser):

profile_picture = models.ImageField(upload_to=user_profile_picture_path, null=True, blank=True, default='default_profile_picture.PNG')
total_matches = models.PositiveIntegerField(default=0)
wins = models.PositiveIntegerField(default=0)
losses = models.PositiveIntegerField(default=0)
title = models.CharField(max_length=100, null=True, blank=True)

def get_friends(self) -> list:
accepted_requests = FriendRequest.objects.filter(
models.Q(from_user=self, status='accepted') | models.Q(to_user=self, status='accepted')
)
friends = [request.to_user if request.from_user == self else request.from_user for request in accepted_requests]
return friends

def get_received_friend_requests(self) -> list:
received_requests = FriendRequest.objects.filter(to_user=self, status='pending')
users = [request.from_user for request in received_requests]
return users



def __str__(self) -> str:
return "Custom User: " + super().__str__() + ' . Total matches: ' + str(self.total_matches) + ' . Wins: ' + str(self.wins) + ' . Losses: ' + str(self.losses)

class FriendRequest(models.Model):
STATUS_CHOICES = (
('pending', 'Pending'),
('accepted', 'Accepted'),
('rejected', 'Rejected'),
)

from_user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='friend_requests_sent')
to_user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='friend_requests_received')
status = models.CharField(max_length=10, choices=STATUS_CHOICES, default='pending')
timestamp = models.DateTimeField(auto_now_add=True)

def __str__(self):
return f"{self.from_user} to {self.to_user} ({self.status})"
Empty file.
51 changes: 32 additions & 19 deletions backend/authentication/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,45 @@
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Ping Pong World</title>
<!-- Include Tailwind CSS CDN or link to your local file -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Ping Pong World</title>
<!-- Include Tailwind CSS CDN or link to your local file -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css">
</head>

<body class="bg-gray-100">

<div class="container mx-auto mt-20 text-center">
<h1 class="text-4xl font-bold text-green-600 mb-4">Ping Pong Home Page</h1>
<p class="text-gray-600 mb-8">The Ultimate Ping Pong Experience!</p>
<div class="container mx-auto mt-20 text-center">
<h1 class="text-4xl font-bold text-green-600 mb-4">Ping Pong Home Page</h1>
<p class="text-gray-600 mb-8">The Ultimate Ping Pong Experience!</p>

<div class="flex justify-center">
<a href="#" class="bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded-full mr-4">Play
Now</a>
<a href="#" class="bg-gray-500 hover:bg-gray-600 text-white font-bold py-2 px-4 rounded-full">Learn More</a>
<!-- Display username and email from the context with enhanced styles -->
<p class="text-lg font-semibold text-gray-800 mb-4">
Welcome, <span class="bg-green-200 px-2 py-1 rounded-md">{{ username }}</span>!
</p>
<p class="text-sm text-gray-600 mb-8">
Email: <span class="bg-blue-200 px-2 py-1 rounded-md">{{ email }}</span>
</p>

<!-- Add the logout button -->
<a href="{% url 'logout' %}" class="bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded-full ml-4">Logout</a>
</div>
</div>
<div class="flex justify-center">
<a href="#" class="bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-4 rounded-full mr-4">Play
Now</a>
<a href="#" class="bg-gray-500 hover:bg-gray-600 text-white font-bold py-2 px-4 rounded-full">Learn More</a>

<!-- Include Tailwind CSS and JavaScript CDNs or link to your local files -->
<!-- Replace with the appropriate version numbers based on your project -->
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.js"></script> -->
<!-- Add the logout button -->
<a href="{% url 'logout' %}"
class="bg-red-500 hover:bg-red-600 text-white font-bold py-2 px-4 rounded-full ml-4">Logout</a>
</div>


<a href="{% url 'users_list' %}"
class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-full">Users List</a>
</div>

<!-- Include Tailwind CSS and JavaScript CDNs or link to your local files -->
<!-- Replace with the appropriate version numbers based on your project -->
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.js"></script> -->

</body>

Expand Down
Loading