Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Proud Puffins - submitting final PR that fell through the cracks. #138

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
5 changes: 2 additions & 3 deletions proud-puffins/Credits and sources.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Credits and Sources
Where we'll track where we got data from.

### First names
* Social Security, US government. Top names from the 1970's
Expand All @@ -18,13 +17,13 @@ Where we'll track where we got data from.
* [Women](https://pixnio.com/photos/people/female-women)
* License - High quality copyright free pictures, no rights reserved and without any restriction.

#### Noralize.css
### Normalize.css
* https://github.com/necolas/normalize.css/
* MIT License
* Creates standard initial conditions across browsers as a base for our CSS.
Simplifying development and testing.

#### Learning Resources/ References
### Learning Resources/ References
* [Excellent documentation by django devs](https://docs.djangoproject.com/en/3.1/)
* [Django Tutorials by Dennis Ivy](https://www.youtube.com/watch?v=xv_bwpA_aEA&list=PL-51WBLyFTg2vW-_6XBoUpE7vpmoR3ztO)
* [Models reference](https://github.com/ElSergio217/Django_Tinder/blob/master/music_tinder/app/models.py)
44 changes: 29 additions & 15 deletions proud-puffins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,45 @@ We be Puffins, and we be proud!
* XPOjabar
* rr

## Requirements
- Python3.8+
- Django>=3
- Pillow>=7
- pathlib>=1
- django-random-image-from-folder>=0.0.3
- django-crispy-forms>=1.9.2

## Loading the App
- Download or pull a clone of this directory.
- Create a virtual environment using the tools you like best.
- In the terminal cd in the the directory djangoProjects. This should be the location of the manage.py file.
- Run ```python puffin_setup.py```
- In the terminal cd into the directory djangoProjects. This should be the location of the manage.py file.
- Run ```python3 puffin_setup.py```
- This should make all your migrations, pre load the database with data and start your server.
- Open your favorite browser to 127.0.0.1 to launch app.
- IF you have issues running this, then follow the instructions outlined in the Dev Stuff below.

## Dev stuff
- IF you have issues running this, then follow the instructions outlined in the Alternative method below.

### [Populating profiles database](https://docs.djangoproject.com/en/3.0/howto/initial-data/)
- Add new entries into `earlydating/fixtures/profiles.json`
## Alternative Method
- Download or pull a clone of this directory.
- Create a virtual environment using the tools you like best.
- Go to proud-puffins directory and install the required packages using ```pip3 install -r requirements.txt```
- In the terminal cd into the directory djangoProjects. This should be the location of the manage.py file.
- Run ```python3 manage.py makemigrations```
- Run ```python3 manage.py migrate```
- Run ```python3 manage.py loaddata users.json```
- Run ```python3 manage.py loaddata profiles.json``` (First users.json then profiles.json)
- Run server :)


### Code organisation

- Dev dependencies go in `requirements-dev.txt`
- Normal dependencies go in `requirements.txt`

- Run server using ```python3 manage.py runserver```

## How to use
- Once the App is loaded, visit ```http://127.0.0.1:8000/```
- Register/Login by pressing on the door or click on the login button in the NavBar.
- If you have just registered and logged in, you will be asked to fill in the profile details.
- Now you can start matching by clicking on 'Match Me' in your profile page.
- Once in, you can like or unlike profiles. To move on to the next one, press 'Next profile' button.
- If the other person likes you too, they will appear on your 'mymatches' page (link present in your profiles page) and their email will be shared with you.
- You can see the profiles you've liked in the 'My Likes' page (link present in your profiles page).

### Note:
You may receive lint errors saying ```earlydating.signals was imported but not used in app.py```. Despite those errors we needed it be like that for the working of post_save signals.

## [MIT license](../LICENSE)

Expand Down
1 change: 1 addition & 0 deletions proud-puffins/djangoProject/earlydating/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ class EarlydatingConfig(AppConfig):
name = 'earlydating'

def ready(self):
# Import is necessary for signals to work despite lint errors
import earlydating.signals
8 changes: 5 additions & 3 deletions proud-puffins/djangoProject/earlydating/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
from django.shortcuts import redirect


# To avoid double login/register if you are logged in
def unauthenticated_user(view_func):
"""To avoid logging in/registering again if the user logged in"""
@wraps(view_func)
def wrapper_func(request, *args, **kwargs):
# Redirect to their profile if authenticated
if request.user.is_authenticated:
return redirect('earlydating-yourprofile')
# Else authenticate user
else:
return view_func(request, *args, **kwargs)
return wrapper_func


# Restricting page access to specified user groups
def allowed_users(allowed_roles=[]):
"""Restricting page access to specified user groups"""
def decorator(view_func):
@wraps(view_func)
def wrapper_func(request, *args, **kwargs):
Expand All @@ -30,8 +32,8 @@ def wrapper_func(request, *args, **kwargs):
return decorator


# Restrict page access to other groups
def admin_only(view_func):
"""Restrict page access to only admins"""
@wraps(view_func)
def wrapper_function(request, *args, **kwargs):
group = None
Expand Down
Loading