Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9276fe2
Implemented Docker
ishan-xy Jun 25, 2024
9994f69
run.sh
ishan-xy Jun 25, 2024
9f1372e
CSRF origin
ishan-xy Jun 25, 2024
711fc34
csrf
ishan-xy Jun 25, 2024
4b22ae6
roll no. not required, kwargs in views
ishan-xy Jun 27, 2024
e42fc07
added leetcode username verification
ishan-xy Jun 28, 2024
4b4d691
Debug to False
ishan-xy Jun 29, 2024
110e375
remove permissions
ishan-xy Jul 4, 2024
2e3a6eb
Merge pull request #6 from creative-computing-society/dev-backend
ishan-xy Jul 4, 2024
2af1e23
static
ishan-xy Jul 6, 2024
d121d7c
Merge pull request #7 from creative-computing-society/dev-backend
ishan-xy Jul 6, 2024
658fb97
static
ishan-xy Jul 6, 2024
c9f477a
static
ishan-xy Jul 6, 2024
4dba6d0
settings
ishan-xy Jul 7, 2024
cbfb845
collectstatic
ishan-xy Jul 7, 2024
18529c3
leetcode user error fix
ishan-xy Jul 10, 2024
0c845e8
auth, and user data
ishan-xy Jul 11, 2024
fc3c715
admin panel
ishan-xy Aug 22, 2024
d5b8bfc
bug fix
ishan-xy Aug 22, 2024
16958b1
bug fix
ishan-xy Aug 22, 2024
05c35b6
delete system
ishan-xy Aug 23, 2024
23cefbd
removed extra prints
ishan-xy Aug 23, 2024
3025c5a
fixed login issue
ishan-xy Aug 25, 2024
07b660f
time update
ishan-xy Aug 25, 2024
8f93977
redone leaderboard system
ishan-xy Aug 26, 2024
116e1c4
timezone
ishan-xy Aug 26, 2024
18fa2cc
totalsolved_timestamp
ishan-xy Aug 26, 2024
34ed931
firstlastname
ishan-xy Sep 3, 2024
acafec0
names
ishan-xy Sep 3, 2024
ba511d2
sso
ishan-xy Sep 3, 2024
939d1fb
admin
ishan-xy Sep 3, 2024
766f31f
question_diff
ishan-xy Sep 5, 2024
c8859a2
Better Authentication and Roles system, Implemented Concurrency [Majo…
ishan-xy Oct 13, 2024
2826d39
removed comments
ishan-xy Oct 13, 2024
4bfc552
changed refresh time to 2 mins
ishan-xy Oct 13, 2024
22b124f
changed pagination
ishan-xy Oct 13, 2024
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
95 changes: 94 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,95 @@
# Created by https://www.gitignore.io

### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.cache
nosetests.xml
coverage.xml

# Translations
*.mo
*.pot

# Sphinx documentation
docs/_build/

# PyBuilder
target/


### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py

.env
.venv
.venv
db.sqlite3

staticfiles/

passwords.json
reset_passwords.py
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Use an official Python runtime as a parent image
FROM python:3.12.3

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Set the working directory in the container
WORKDIR /app

# Copy the requirements file first for better caching
COPY requirements.txt /app/

# Install any needed packages specified in requirements.txt
RUN python -m pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code to the container
COPY . /app/

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# RUN adduser --disabled-password --gecos "" appuser && chown -R appuser /app

# Switch to non-root user
# USER appuser

# Define the command to run the application
CMD ["sh", "run.sh"]
File renamed without changes.
3 changes: 3 additions & 0 deletions admin_dash/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions admin_dash/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AdminDashConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'admin_dash'
3 changes: 3 additions & 0 deletions admin_dash/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
47 changes: 47 additions & 0 deletions admin_dash/populateQuestions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import logging
from django.utils import timezone
from leaderboard.models import Question
from leaderboard.utility import fetch_all_questions

# Define a logger for this module
logger = logging.getLogger(__name__)

def populate_question_model(frontendQuestionId):
try:
logger.info(f"Populating question model for frontendQuestionId {frontendQuestionId}...")

questions_dict = fetch_all_questions()
question_data = questions_dict.get(str(frontendQuestionId))

if question_data:
# Map LeetCode difficulty to the model choices
leetcode_difficulty = question_data.get('difficulty', '')
difficulty_mapping = {
"Easy": "Basic",
"Medium": "Intermediate",
"Hard": "Advanced"
}
difficulty = difficulty_mapping.get(leetcode_difficulty, "Basic")

# Fetch or create the Question model instance
obj, created = Question.objects.update_or_create(
leetcode_id=int(question_data['frontendQuestionId']),
defaults={
'title': question_data['title'],
'titleSlug': question_data['titleSlug'],
'difficulty': difficulty,
}
)

# Check if the object was created or updated
if created:
logger.info(f"Question with frontendQuestionId {frontendQuestionId} created successfully.")
obj.questionDate = timezone.now()
obj.save()
else:
logger.info(f"Question with frontendQuestionId {frontendQuestionId} updated successfully.")
else:
logger.warning(f"Question with frontendQuestionId {frontendQuestionId} not found.")

except Exception as e:
logger.error(f"Error populating question model for frontendQuestionId {frontendQuestionId}: {e}")
Binary file added admin_dash/static/img/ccs-bulb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
109 changes: 109 additions & 0 deletions admin_dash/templates/admin_dash/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<link
href="https://cdn.jsdelivr.net/npm/@coreui/coreui@5.0.2/dist/css/coreui.min.css"
rel="stylesheet"
integrity="sha384-39e9UaGkm/+yp6spIsVfzcs3j7ac7G2cg0hzmDvtG11pT1d7YMnOC26w4wMPhzsL"
crossorigin="anonymous"
/>

<title>{% block title %}Admin Dashboard{% endblock %}</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
background-color: #0d1015;

}
::-webkit-scrollbar {
width: 0px;
}
.parent{
display: flex;
justify-content: center;
align-items: center;
margin: 0;
}
.form-control{
background-color: #D4EDEB;
color: black;
border: none;
}
.form-control::placeholder{
color: black;
}
.form-control:focus{
background-color: #D4EDEB;
color: black;
border: none;
}
.btn-login{
background-color: green;
color: white;
height: 5vh;
border: none;
border-radius: 5px;
}
.btn-login:hover{
background-color: #004A00;
color: white;
}
.btn-logout {
background-color: red;
color: white;
height: 5vh;
border: none;
border-radius: 5px;
}
.btn-logout:hover {
background-color: #4a0000;
color: white;
}
.navbar-custom {
background-color: #2C313B;
}

.navbar-custom .navbar-brand {
color: white;
}

.navbar-custom .navbar-brand img {
filter: brightness(0) invert(1); /* Optional: Adjust logo color if needed */
}

</style>
{% block extra_css %}{% endblock %}
</head>
<body>
<nav class="navbar navbar-custom">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="{% static 'img/ccs-bulb.png' %}" alt="Logo" width="34" height="40" class="d-inline-block align-text-top">
<span></span>
</a>
{%if user.is_authenticated %}
<form action="{% url 'admin_dash:admin_logout' %}" class="d-inline">
<button type="submit" class="btn btn-logout">Logout</button>
</form>
{% endif %}
</div>
</nav>

{% block content %}

{% endblock %}
<script
src="https://cdn.jsdelivr.net/npm/@coreui/coreui@5.0.2/dist/js/coreui.bundle.min.js"
integrity="sha384-/lLdeDXcg75fFKvNaXc6K+P80Jk8U+1mKJUYqkLSxqr18HIUvJYVN42+m23Zbw4b"
crossorigin="anonymous"
></script>
{% block extra_js %}{% endblock %}
</body>
</html>
Loading