Skip to content
Open

Test #30

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/master_ftpapps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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 - ftpapps

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python version
uses: actions/setup-python@v1
with:
python-version: '3.8'

- 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: Upload artifact for deployment jobs
uses: actions/upload-artifact@v2
with:
name: python-app
path: |
.
!venv/

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: python-app
path: .

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
with:
app-name: 'ftpapps'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_c2f557e82a9545e298a8ff89de12e554 }}
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/djangoapp.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions azuresite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

INSTALLED_APPS = [
'polls.apps.PollsConfig',
'eactivities.apps.EactivitesConfig',
'cars.apps.CarsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -76,10 +78,14 @@
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': os.environ.get('DBNAME'),
'USER': os.environ.get('DBUSER'),
'PASSWORD': os.environ.get('DBPASS'),
'HOST': os.environ.get('DBHOST'),
'PORT': '5432',
}
}


Expand Down
1 change: 1 addition & 0 deletions azuresite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@

urlpatterns = [
path('', include('polls.urls')),
path('', include('cars.urls')),
path('admin/', admin.site.urls),
]
Empty file added cars/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions cars/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions cars/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class CarsConfig(AppConfig):
name = 'cars'
Empty file added cars/migrations/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions cars/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django.db import models

# Create your models here.

from django.db import models

class Driver(models.Model):

name = models.TextField()

license = models.TextField()

class Car(models.Model):

make = models.TextField()

model = models.TextField()

year = models.IntegerField()


owner = models.ForeignKey("Driver", on_delete=models.SET_NULL, null=True)
25 changes: 25 additions & 0 deletions cars/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">



<title>Contacts</title>

<link rel="stylesheet" href="https://unpkg.com/[email protected]/css/tachyons.min.css"/>

</head>

<body>

{% block page_content %}{% endblock %}

</body>

</html>
29 changes: 29 additions & 0 deletions cars/templates/car_detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends "base.html" %}

{% block page_content %}

<div class="mw6 center pa3 sans-serif">

<h1 class="mb4">Driver: {{ drivers.name | linebreaks }}</h1>

<header class="b mb2">License: {{ drivers.license }}</header>

{% for v in vehicles %}

<div class="pa2 mb3 striped--near-white">

<div class="pl2">

<p class="mb2">Make/Model: {{ v.make }} {{ v.model }}</p>

<p class="mb2">Year: {{ v.year }}</p>

</div>

</div>

{% endfor %}

</div>

{% endblock %}
3 changes: 3 additions & 0 deletions cars/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
11 changes: 11 additions & 0 deletions cars/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.urls import path

from . import views



urlpatterns = [

path("cars/<int:pk>/", views.car_detail, name="car_detail"),

]
24 changes: 24 additions & 0 deletions cars/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.shortcuts import render

# Create your views here.
from django.shortcuts import render

from cars.models import Car, Driver



def car_detail(request, pk):

owner_obj = Driver.objects.get(pk=pk)

car_objs = Car.objects.filter(owner_id=owner_obj.id)

context = {

"vehicles": car_objs,

"drivers": owner_obj,

}

return render(request, "car_detail.html", context)
Empty file added eactivities/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions eactivities/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions eactivities/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class EactivitiesConfig(AppConfig):
name = 'eactivities'
Empty file.
8 changes: 8 additions & 0 deletions eactivities/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.db import models

# Create your models here.
class UploadModel(models.Model):
# file will be uploaded to MEDIA_ROOT/uploads
# or...
# file will be saved to MEDIA_ROOT/uploads/2015/01/30
upload = models.FileField(upload_to='files',null=True)
3 changes: 3 additions & 0 deletions eactivities/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions eactivities/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
2 changes: 1 addition & 1 deletion polls/templates/polls/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}">

<h1>Polls app</h1>
<h1>Cea mai tare comunssxitate</h1>

{% if latest_question_list %}
<ul>
Expand Down