Skip to content

Commit

Permalink
adding pre-commit and fixing bugs (#66)
Browse files Browse the repository at this point in the history
* adding pre-commit

* update readme

* fix flake

---------

Co-authored-by: Ishaan Mittal <[email protected]>
  • Loading branch information
mittal-ishaan and ishaan-tf authored Aug 17, 2024
1 parent a8d941b commit aa4daf0
Show file tree
Hide file tree
Showing 71 changed files with 2,015 additions and 3,718 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

__pycache__
migrations
db.sqlite3
db.sqlite3
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
max-line-length = 88
# Remove F811 from admin.py
ignore = E501, E722, W503, F811
per-file-ignores =
home/models/students.py: E402
home/models/admin.py: F811
home/models/__init__.py: F401
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ labels: ''
assignees: ''

---


2 changes: 1 addition & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
max-parallel: 4
matrix:
python-version: [3.11]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-to-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
docker compose down
docker rmi mess-website-nginx || true
docker rmi mess-website-web || true
docker compose up -d
docker compose up -d
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
exclude: .*migrations\/.*
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.8.0
hooks:
- id: black
language_version: python3.10
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ COPY ./entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

# Set the entrypoint to the entrypoint.sh script
ENTRYPOINT ["/app/entrypoint.sh"]
ENTRYPOINT ["/app/entrypoint.sh"]
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Before you begin, ensure you have the following installed:
```
5. Migrate the database

```shell
```shell
python manage.py migrate
```
6. Copy the environment
Expand All @@ -94,10 +94,23 @@ Before you begin, ensure you have the following installed:
7. Edit the environment variables in `.env` file
8. Finally run
```shell
$ python manage.py runserver
python manage.py runserver
```
_Note:_ SQLite is as the default database

### Pre-Commit Hooks

1. This project uses pre-commit hooks to ensure code quality. To install pre-commit hooks, run the following command:
```shell
pip install pre-commit
pre-commit install
```

2. To run pre-commit hooks manually, run the following command:
```shell
pre-commit run --all-files
```

## Roadmap

- [x] Student Information Access
Expand Down Expand Up @@ -130,4 +143,4 @@ Project Link: [https://github.com/DaemonLab/Mess-Website](https://github.com/Dae
[Gunicorn]: https://img.shields.io/badge/gunicorn-37474F?style=for-the-badge&logo=gunicorn&logoColor=white
[Gunicorn-url]: https://gunicorn.org/
[Nginx]: https://img.shields.io/badge/nginx-269539?style=for-the-badge&logo=nginx&logoColor=white
[Nginx-url]: https://www.nginx.com/
[Nginx-url]: https://www.nginx.com/
2,418 changes: 0 additions & 2,418 deletions db/db.sqbpro

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ services:
- /etc/letsencrypt/live/diningfee.iiti.ac.in/fullchain.pem:/etc/letsencrypt/live/diningfee.iiti.ac.in/fullchain.pem
- /etc/letsencrypt/live/diningfee.iiti.ac.in/privkey.pem:/etc/letsencrypt/live/diningfee.iiti.ac.in/privkey.pem
depends_on:
- web
- web
24 changes: 14 additions & 10 deletions home/adapters/account_adapter.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
from allauth.account.adapter import DefaultAccountAdapter
from django.contrib.auth import get_user_model, login
from home.models import Student
from django.contrib import messages
from allauth.account.adapter import DefaultAccountAdapter
from django.contrib.auth import get_user_model
from django.forms import ValidationError

from home.models import Student

User = get_user_model()


class CustomAccountAdapter(DefaultAccountAdapter):
def should_send_confirmation_mail(self, request, email_address):
return None
def clean_email(self,email):
RestrictedList = Student.objects.all().values_list('email')

def clean_email(self, email):
RestrictedList = Student.objects.all().values_list("email")
# try:
# Student.objects.get(email=email)
# return email
# except Exception as e:
# ValidationError('You are not a registered student. Please contact admin.')
if email.endswith('iiti.ac.in'):
if email.endswith("iiti.ac.in"):
print(11)
raise ValidationError('Please login with your IITI email ID through google login only.')
raise ValidationError(
"Please login with your IITI email ID through google login only."
)
elif RestrictedList.filter(email=email).exists():
print(email)
print(RestrictedList.filter(email=email))
else:
raise ValidationError('This email ID is not registered with the Dining Facility. Please contact the Dining Wadern Office.')
raise ValidationError(
"This email ID is not registered with the Dining Facility. Please contact the Dining Wadern Office."
)
return email

Loading

0 comments on commit aa4daf0

Please sign in to comment.