Skip to content

Commit

Permalink
Merge pull request #1 from ak2466/alex-development
Browse files Browse the repository at this point in the history
Update workflow
  • Loading branch information
ak2466 authored Apr 22, 2024
2 parents 2cb1734 + a97c638 commit fe628c4
Show file tree
Hide file tree
Showing 260 changed files with 2,151 additions and 1,320 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Docker Image CI

on:
workflow_dispatch:

jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
-
name: Checkout the repository
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Log into GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{secrets.GH_USERNAME}}
password: ${{secrets.GH_PAT}}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: Code/.
push: true
tags: ghcr.io/ak2466/plantpals:latest

deploy:
runs-on: ubuntu-latest
steps:
-
name: SSH
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
docker ps -aq | xargs docker stop | xargs docker rm
docker rmi -f $(docker images -aq)
service docker restart
docker pull ghcr.io/ak2466/plantpals:latest
docker run -d ${{secrets.DB_VOLUME}}
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/db.sqlite3
/Forum/__pycache__/**
/profile_of_user/__pycache__/**
/profile_of_user/migrations/**
/.venv/**
**db.sqlite3**
**__pycache__**
**migrations/**
**.DS_Store**
**djangoenv/**
/db/db.sqlite3
**/Forum/__pycache__/**
**/profile_of_user/__pycache__/**
**/profile_of_user/migrations/**
**/.venv/**
plant-pals/db.sqlite3
51 changes: 51 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## Code of Conduct

### Our Pledge

We want the environment of our project to remain friendly and comfortable for
all involved. As such, there may be no harassment of any kind (age, body,
disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation) permitted in any project space or materials. Also, every member
of the team is expected to do their part and contribute appropriately to the
project.

### Our Standards

Behaviors that are expected of participants include:

* Listening to suggestions from other team members
* Giving criticism kindly and constructively
* Being friendly towards other members of the team
* Supporting other team members when needed
* Completing work in a timely fashion
* Turning in work that is high quality

Behaviors that are unacceptable include:

* Insulting or being unkind toward other team members
* Producing work that has little time and effort put into it
* Being behind on work without communicating these difficulties to the team

### Scope

This Code of Conduct applies both within project meeting spaces, class, the discord,
and within the materials made for this project. If circumstances outside of these
arise, the group will discuss together to decide on the appropriate response.

### Enforcement

Any behavior that violates the code of conduct will be discussed
in the Monday meetings so that the team may decide on how best to move
forward and find an understanding of the root of the issue. If the problem
needs to be addressed more immediately, it will be brought up in the
'general' tab of the discord and a virtual meeting will be set up and held
to tackle the issue.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Contributing

Hello, welcome to the Plant Pals project!

This repository is only to be contibuted to be project members, who will make pull requests
from their branches that must be reviewed by another member before the change is made.

When contributing to the project, please follow the code of conduct.

## Pull Request Process

1. Pull requests may be made by any member of the team.
2. Changes should be initially made on the team members updated personal branch.
3. Once these changes are made and tested, create a pull request to merge with the main branch.
4. One other member of the team must approve the pull request before the changes are made.
5. There must always be a backup version of the repository in case of a change breaking the website.

## Issues

Any ideas for features that should be added, bugs found, or areas of the website that need improvement should be opened in github as issues.
We will address these issues over the course of the project based on priority.
14 changes: 14 additions & 0 deletions Code/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM python:3.12-alpine

WORKDIR /usr/src/app

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN pip install --upgrade pip

COPY . /usr/src/app/.

RUN pip install --no-cache-dir -r requirements.txt

CMD /usr/src/app/entrypoint.sh
13 changes: 13 additions & 0 deletions Code/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.8'

services:
django:
container_name: django
build:
context: ./
ports:
- 80:80
platform: linux/amd64
volumes:
- ./db:/usr/src/app/db
image: ghcr.io/ak2466/plantpals:latest
13 changes: 13 additions & 0 deletions Code/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/ash

echo "Changing directory"
cd plant-pals

echo "Apply database migrations"
python manage.py migrate

echo "Starting server"
python manage.py runserver 0.0.0.0:80

exec "$@"

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["*"]


# Application definition
Expand Down Expand Up @@ -69,7 +69,7 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
'NAME': BASE_DIR / '../db/db.sqlite3',
}
}

Expand Down Expand Up @@ -119,3 +119,6 @@
# Managing Media
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

# fixing big auto field error
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Code/plant-pals/media/plant_database/Bamboo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Code/plant-pals/media/plant_database/Basil.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Code/plant-pals/media/plant_database/Cactus.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Code/plant-pals/media/plant_database/Gardenia.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Code/plant-pals/media/plant_database/Mint.jpg
Binary file added Code/plant-pals/media/plant_database/Monstera.jpg
Binary file added Code/plant-pals/media/plant_database/Orchid.jpg
Binary file added Code/plant-pals/media/plant_database/Pilea.jpg
Binary file added Code/plant-pals/media/plant_database/ZZ_Plant.jpg
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
from .models import Post, Replie, Profile

# make sure to register what you want to be able to have admin control of from models!
# if you don't, you can't access it on the admin site w/ admin control pannels
# if you don't, you can't access it on the admin site w/ admin control panels
admin.site.register(Post)
admin.site.register(Replie)
admin.site.register(Profile)
admin.site.register(Profile)

#import plants database model
from .models import Plant

admin.site.register(Plant)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@
## fields = [''] | says that the names in the list is now a variable. You
## can see these used in models.py in our Profile class.

# profile form draws from profile model and has an avatar image field
class ProfileForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['avatar']

# plant form draws from profile model and has plant image fields
class PlantForm(forms.ModelForm):
class Meta:
model = Profile
fields = ['plant_image_1', 'plant_name_1']
# Add fields for plant_image_2, plant_name_2, and so on...
# if doing this, make sure to add to models.py

98 changes: 98 additions & 0 deletions Code/plant-pals/profile_of_user/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
from django.db import models
from django.contrib.auth.models import User
from django.utils.timezone import now
from django.db.models import UniqueConstraint # Constrains fields to unique values

# profile model
class Profile(models.Model):
user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE)
# for user avatar images
avatar = models.ImageField(upload_to="images", default="default/user.png")

## for the plants. If more portfolio plants are wanted, copy and past this
## just remember to change the name, add it to the PlantForm class in forms.py,
## adjust views.py to allow for another plant submission, and add it to
## the profile html page.

# change default to a temp plant when we have one
plant_image_1 = models.ImageField(upload_to="additional_images", default="default/user.png")
plant_name_1 = models.CharField(max_length=60, default="")

#makes sure the images are deleted when a profile is deleted
def delete(self, using=None, keep_parents=False):
self.avatar.delete()
self.plant_image_1.delete()
super().delete()

# post model
class Post(models.Model):
user1 = models.ForeignKey(User, on_delete=models.CASCADE, default=1)
post_id = models.AutoField
post_content = models.CharField(max_length=5000)
timestamp= models.DateTimeField(default=now)
image = models.ImageField(upload_to="images",default="")

#makes sure the image is deleted when a post is deleted
def delete(self, using=None, keep_parents=False):
self.image.delete()
super().delete()

# reply model (associated with post)
class Replie(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE, default=1)
reply_id = models.AutoField
reply_content = models.CharField(max_length=5000)
post = models.ForeignKey(Post, on_delete=models.CASCADE, default='')
timestamp= models.DateTimeField(default=now)
image = models.ImageField(upload_to="images",default="")

# makes sure the image is deleted when a reply is deleted
def delete(self, using=None, keep_parents=False):
self.image.delete()
super().delete()

### model for plant watering schedule
class DailyTask(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
task_date = models.DateField()
task_description = models.CharField(max_length=100)
completed = models.BooleanField(default=False)

class Meta:
unique_together = ('user', 'task_date')

##############################################################################
# Plant data entry model
##############################################################################
class Plant(models.Model):
"""This model is for entering plants into the database."""

#Fields
scientific_name = models.CharField("scientific name", max_length = 100, unique = True)
common_name = models.CharField("common name", max_length = 50)
growth_habit = models.CharField("growth habit", max_length = 20)
duration = models.CharField("seasonal duration", max_length = 20)
sun_requirements = models.CharField("sun requirements", max_length = 20)
water = models.CharField("water recommended", max_length = 50)
temp_low_F = models.FloatField("lowest temperature (F)", max_length = 5)
temp_high_F = models.FloatField("highest temperature (F)", max_length = 5)
image = models.ImageField("plant image", upload_to="plant_database",default="")

#ordering of plants
class Meta:
ordering = ['scientific_name']

#methods
def __str__(self):
return self.scientific_name

#makes sure the image is deleted when a plant is deleted
def delete(self, using=None, keep_parents=False):
self.image.delete()
super().delete()

##############################################################################
# Search function model
##############################################################################


Loading

0 comments on commit fe628c4

Please sign in to comment.