-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b7064ff
Showing
23 changed files
with
1,302 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy | ||
# More GitHub Actions for Azure: https://github.com/Azure/actions | ||
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions | ||
|
||
name: Build and deploy Python app to Azure Web App - paws-backend | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python version | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Create and start virtual environment | ||
run: | | ||
python -m venv venv | ||
source venv/bin/activate | ||
- name: Install dependencies | ||
run: pip install -r requirements.txt | ||
|
||
# Optional: Add step to run tests here (PyTest, Django test suites, etc.) | ||
|
||
- name: Zip artifact for deployment | ||
run: zip release.zip ./* -r | ||
|
||
- name: Upload artifact for deployment jobs | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-app | ||
path: | | ||
release.zip | ||
!venv/ | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
environment: | ||
name: 'Production' | ||
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
permissions: | ||
id-token: write #This is required for requesting the JWT | ||
|
||
steps: | ||
- name: Download artifact from build job | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-app | ||
|
||
- name: Unzip artifact for deployment | ||
run: unzip release.zip | ||
|
||
|
||
- name: Login to Azure | ||
uses: azure/login@v1 | ||
with: | ||
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_65385D52358C41A1B340C88B1CF0FE57 }} | ||
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_1CE927B36F8B4BF398C2DF30CE3502CD }} | ||
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_C9E0646AF67942A9A660F43365693C20 }} | ||
|
||
- name: 'Deploy to Azure Web App' | ||
uses: azure/webapps-deploy@v2 | ||
id: deploy-to-webapp | ||
with: | ||
app-name: 'paws-backend' | ||
slot-name: 'Production' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# 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/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
test.py | ||
*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
|
||
## Setup and Installation | ||
clone the repo | ||
|
||
## Install the requirements: | ||
|
||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
Apply the migrations: | ||
|
||
```bash | ||
python manage.py migrate | ||
``` | ||
|
||
## Running the Project | ||
|
||
To run the project: | ||
|
||
```bash | ||
python manage.py runserver | ||
`````` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.contrib import admin | ||
from .models import Animal, BaseUser, NgoUser, CustomUser, Campaign | ||
|
||
class AnimalAdmin(admin.ModelAdmin): | ||
list_display = ('id', 'user_name', 'user_email', 'user_phone', | ||
'animal_type', 'numberOfAnimals', 'description', | ||
'condition', 'image', 'latitude', 'longitude', | ||
'address', 'landmark', 'status', 'reported_time', | ||
'response_time', 'assigned_to') | ||
|
||
|
||
class CampaignAdmin(admin.ModelAdmin): | ||
list_display = ('ngo_name', 'title', 'description', 'tags', 'phone_number', | ||
'email', 'start_date', 'end_date', 'application_deadline', | ||
'age_group', 'image_link', 'is_over', 'campaign_id', 'applicant_list') | ||
|
||
|
||
class BaseUserAdmin(admin.ModelAdmin): | ||
list_display = ('email', 'name', 'phone_number', 'is_ngo', 'is_active', | ||
'is_staff', 'is_superuser', 'date_joined', 'notify_token') | ||
search_fields = ['email', 'name', 'phone_number'] | ||
|
||
class NgoUserAdmin(admin.ModelAdmin): | ||
list_display = ('user', 'emergency_contact_number', 'animals_supported', | ||
'website', 'address', 'latitude', 'longitude', 'no_received_reports', 'created_campaigns_id') | ||
|
||
class CustomUserAdmin(admin.ModelAdmin): | ||
list_display = ('user', 'no_reports', 'level', 'coins', 'applied_campaigns') | ||
|
||
|
||
|
||
admin.site.register(Animal, AnimalAdmin) | ||
admin.site.register(BaseUser, BaseUserAdmin) | ||
admin.site.register(NgoUser, NgoUserAdmin) | ||
admin.site.register(CustomUser, CustomUserAdmin) | ||
admin.site.register(Campaign, CampaignAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AniresfrConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'aniresfr' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from django.contrib.auth.base_user import BaseUserManager | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
|
||
class CustomUserManager(BaseUserManager): | ||
""" | ||
Custom user model manager where email is the unique identifiers | ||
for authentication instead of usernames. | ||
""" | ||
def create_user(self, email, password, **extra_fields): | ||
""" | ||
Create and save a user with the given email and password. | ||
""" | ||
if not email: | ||
raise ValueError(_("The Email must be set")) | ||
email = self.normalize_email(email) | ||
user = self.model(email=email, **extra_fields) | ||
user.set_password(password) | ||
user.save() | ||
return user | ||
|
||
def create_superuser(self, email, password, **extra_fields): | ||
""" | ||
Create and save a SuperUser with the given email and password. | ||
""" | ||
extra_fields.setdefault("is_staff", True) | ||
extra_fields.setdefault("is_superuser", True) | ||
extra_fields.setdefault("is_active", True) | ||
|
||
if extra_fields.get("is_staff") is not True: | ||
raise ValueError(_("Superuser must have is_staff=True.")) | ||
if extra_fields.get("is_superuser") is not True: | ||
raise ValueError(_("Superuser must have is_superuser=True.")) | ||
return self.create_user(email, password, **extra_fields) |
Oops, something went wrong.