-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
13 changed files
with
233 additions
and
14 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,32 @@ | ||
**/*.pyc | ||
**/*.pyo | ||
**/*.mo | ||
**/*.db | ||
**/*.css.map | ||
**/*.egg-info | ||
**/*.sql.gz | ||
**/__pycache__/ | ||
.cache | ||
.project | ||
.idea | ||
.pydevproject | ||
.idea/workspace.xml | ||
.DS_Store | ||
.git/ | ||
.sass-cache | ||
.vagrant/ | ||
dist | ||
docs | ||
env | ||
logs | ||
src/{{ project_name }}/settings/local.py | ||
src/node_modules | ||
web/media | ||
web/static/CACHE | ||
stats | ||
Dockerfile | ||
.gitignore | ||
Dockerfile | ||
db.sqlite3 | ||
**/*.md | ||
logs/ |
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 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
|
||
jobs: | ||
Deployment: | ||
if: github.ref == 'refs/heads/main' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Cloning repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Push to Dokku server | ||
uses: dokku/github-action@master | ||
with: | ||
branch: 'main' | ||
git_remote_url: ssh://dokku@${{ secrets.DOKKU_SERVER_IP }}/${{ secrets.DOKKU_APP_NAME }} | ||
ssh_private_key: ${{ secrets.DOKKU_SSH_PRIVATE_KEY }} |
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,32 @@ | ||
FROM python:3.10-slim-buster | ||
|
||
WORKDIR /app | ||
|
||
ENV PYTHONUNBUFFERED=1 \ | ||
PYTHONPATH=/app \ | ||
DJANGO_SETTINGS_MODULE=shopping_list.settings \ | ||
PORT=8000 \ | ||
WEB_CONCURRENCY=2 | ||
|
||
# Install system packages required Django. | ||
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN addgroup --system django \ | ||
&& adduser --system --ingroup django django | ||
|
||
# Requirements are installed here to ensure they will be cached. | ||
COPY ./requirements.txt /requirements.txt | ||
RUN pip install -r /requirements.txt | ||
|
||
# Copy project code | ||
COPY . . | ||
|
||
RUN python manage.py collectstatic --noinput --clear | ||
|
||
# Run as non-root user | ||
RUN chown -R django:django /app | ||
USER django | ||
|
||
# Run application | ||
# CMD gunicorn shopping_list.wsgi:application |
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
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
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 @@ | ||
release: django-admin migrate --noinput | ||
web: gunicorn PBPTugas2.wsgi |
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,7 @@ | ||
from django.forms import ModelForm | ||
from main.models import Item | ||
|
||
class ItemForm(ModelForm): | ||
class Meta: | ||
model = Item | ||
fields = ["name", "amount", "description"] |
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,19 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
<h1>Add New Item</h1> | ||
|
||
<form method="POST"> | ||
{% csrf_token %} | ||
<table> | ||
{{ form.as_table }} | ||
<tr> | ||
<td></td> | ||
<td> | ||
<input type="submit" value="Add Item"/> | ||
</td> | ||
</tr> | ||
</table> | ||
</form> | ||
|
||
{% endblock %} |
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 |
---|---|---|
@@ -1,9 +1,43 @@ | ||
<h1>Pengelolaan Stok Produk toko PBP</h1> | ||
|
||
{% extends 'base.html' %} | ||
|
||
<h5>Nama Aplikasi: </h5> | ||
<p>{{ application }}</p> | ||
<h5>Name: </h5> | ||
<p>{{ name }}<p> | ||
<h5>Class: </h5> | ||
<p>{{ class }}<p> | ||
{% block content %} | ||
|
||
|
||
<h1>Pengelolaan Stok Produk toko PBP</h1> | ||
|
||
|
||
<h5>Nama Aplikasi: </h5> | ||
<p>{{ application }}</p> | ||
<h5>Name: </h5> | ||
<p>{{ name }}<p> | ||
<h5>Class: </h5> | ||
<p>{{ class }}<p> | ||
|
||
|
||
<table> | ||
<tr> | ||
<th>Name</th> | ||
<th>Ammount</th> | ||
<th>Description</th> | ||
|
||
</tr> | ||
|
||
{% for item in items %} | ||
<tr> | ||
<td>{{item.name}}</td> | ||
<td>{{item.amount}}</td> | ||
<td>{{item.description}}</td> | ||
|
||
</tr> | ||
{% endfor %} | ||
</table> | ||
|
||
<br /> | ||
|
||
<a href="{% url 'main:create_item' %}"> | ||
<button> | ||
Add New Item | ||
</button> | ||
</a> | ||
{% endblock content %} |
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 |
---|---|---|
@@ -1,9 +1,14 @@ | ||
from django.urls import path | ||
from main.views import show_main | ||
from main.views import show_main, create_item, show_xml, show_json, show_xml_by_id, show_json_by_id | ||
|
||
app_name = 'main' | ||
|
||
urlpatterns = [ | ||
path('', show_main, name='show_main'), | ||
path('create-item', create_item, name='create_item'), | ||
path('xml/', show_xml, name='show_xml'), | ||
path('json/', show_json, name='show_json'), | ||
path('xml/<int:id>/', show_xml_by_id, name='show_xml_by_id'), | ||
path('json/<int:id>/', show_json_by_id, name='show_json_by_id'), | ||
|
||
] |
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 |
---|---|---|
@@ -1,12 +1,45 @@ | ||
from django.shortcuts import render | ||
|
||
from django.http import HttpResponseRedirect | ||
from main.forms import ItemForm | ||
from django.urls import reverse | ||
from main.models import Item | ||
from django.http import HttpResponse | ||
from django.core import serializers | ||
|
||
|
||
def show_main(request): | ||
items = Item.objects.all() | ||
context = { | ||
'application': 'Miracle', | ||
'name': 'Kevin Ignatius Wijaya', | ||
'class': 'PBP F' | ||
'class': 'PBP F', | ||
'items' : items | ||
} | ||
|
||
return render(request, "main.html", context) | ||
|
||
def create_item(request): | ||
form = ItemForm(request.POST or None) | ||
|
||
if form.is_valid() and request.method == "POST": | ||
form.save() | ||
return HttpResponseRedirect(reverse('main:show_main')) | ||
|
||
context = {'form': form} | ||
return render(request, "create_item.html", context) | ||
|
||
def show_xml(request): | ||
data = Item.objects.all() | ||
return HttpResponse(serializers.serialize("xml", data), content_type="application/xml") | ||
|
||
def show_xml_by_id(request, id): | ||
data = Item.objects.filter(pk=id) | ||
return HttpResponse(serializers.serialize("xml", data), content_type="application/xml") | ||
|
||
def show_json(request): | ||
data = Item.objects.all() | ||
return HttpResponse(serializers.serialize("json", data), content_type="application/json") | ||
def show_json_by_id(request, id): | ||
data = Item.objects.filter(pk=id) | ||
return HttpResponse(serializers.serialize("json", data), content_type="application/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 |
---|---|---|
|
@@ -3,4 +3,5 @@ gunicorn | |
whitenoise | ||
psycopg2-binary | ||
requests | ||
urllib3 | ||
urllib3 | ||
django-environ |
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,18 @@ | ||
{% load static %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0" | ||
/> | ||
{% block meta %} | ||
{% endblock meta %} | ||
</head> | ||
|
||
<body> | ||
{% block content %} | ||
{% endblock content %} | ||
</body> | ||
</html> |