Skip to content

Commit

Permalink
Split into mono repository - front and backend (#77) - create vuejs f…
Browse files Browse the repository at this point in the history
…rontend

# backend:

- add graphene to backend
- rename azure module, add new vs code build tasks and add global schema for core 
- update DB link
- replace property (as a single item) with abstract class and subclass it for house, room, and apartment 
- add/delete new packages like pandas
- django toolbar: make it work
- add migrations for core
- clean view form google captcha

# create vue js + apollo based frontend
- prepare circle ci, adjust azure to skip according to folder, adds new routers
- move one dir up

# Pipelines
- adjust ci: split frontend and backend into azure pipelines and quay.io
-  speed up dockerfile
- update entry script
- reformat python and js/ts
- adjust sonar exclusions
  • Loading branch information
dmpe authored Oct 27, 2019
1 parent d524c1a commit 5107d44
Show file tree
Hide file tree
Showing 115 changed files with 13,439 additions and 208 deletions.
76 changes: 50 additions & 26 deletions azure-pipelines.yml → .azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# https://aka.ms/yaml

variables:
quayId: dmpe
dockerId: f789gh
imageName: django-wohn
imageNameB: django-wohn-backend
major: 1
minor: $[counter(variables['major'], 3)]

Expand All @@ -14,52 +16,75 @@ trigger:
- pr

stages:
- stage: PrepareBuildAndPush
displayName: Prepare Docker Build and push to DockerHub
- stage: Preparations
displayName: Prepare all the tasks that are needed for later use
jobs:
- job: BuildJob
strategy:
parallel: 2
pool:
vmImage: 'ubuntu-latest'
steps:

- task: Docker@2
displayName: "Docker login"
inputs:
containerRegistry: 'docker_hub'
command: 'login'

- task: Docker@2
displayName: "quay login"
inputs:
containerRegistry: 'quay.io'
command: 'login'

- task: AzureKeyVault@1
inputs:
azureSubscription: 'DjangoAzure'
KeyVaultName: 'b40'
SecretsFilter: '*'
# https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzureKeyVaultV1/README.md

- task: Docker@2
displayName: "Build our Image now"
inputs:
containerRegistry: 'docker_hub'
repository: $(dockerId)/$(imageName)
command: 'build'
Dockerfile: 'Dockerfile'
tags: |
$(major).$(minor)
latest

- task: Docker@2
displayName: "Push to Docker Hub"
# only push on master branch, i.e. when PR is merged
# condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
containerRegistry: 'docker_hub'
repository: '$(dockerId)/$(imageName)'
command: 'push'
tags: |
$(major).$(minor)
latest
- stage: DockerBuild
displayName: Build Docker images
jobs:
- job: BuildImages
# strategy:
# parallel: 2
pool:
vmImage: 'ubuntu-latest'
steps:
- task: CopyFiles@2
inputs:
SourceFolder: '$(Build.SourcesDirectory)/'
Contents: '*.md'
TargetFolder: 'backend/'
OverWrite: true

- task: Docker@2
displayName: "Build our Backend now"
inputs:
containerRegistry: 'quay.io'
repository: $(quayId)/$(imageNameB)
command: 'build'
Dockerfile: 'backend/Dockerfile'
tags: |
$(major).$(minor)
latest
- task: Docker@2
displayName: "Push to Docker Hub"
condition: succeeded()
inputs:
containerRegistry: 'quay.io'
repository: '$(quayId)/$(imageNameB)'
command: 'push'
tags: |
$(major).$(minor)
latest
- stage: SendToSonarQube
displayName: Run SonarQube scannerMode
displayName: Run SonarQube
jobs:
- job: ScanJob
pool:
Expand All @@ -78,4 +103,3 @@ stages:
- task: SonarCloudPublish@1
inputs:
pollingTimeoutSec: '300'
# TODO: take picture from output and commit it to docs directory
33 changes: 33 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
# https://circleci.com/gh/dmpe/django-wohn
version: 2
jobs:
build:
machine:
image: ubuntu-1604:201903-01
# setup_remote_docker:
# version: 18.09.3
working_directory: ~/repo
steps:
- checkout

- run: |
pwd
ls -ls
- run:
name: Build and push Docker image
command: |
cd frontend/
docker build -t quay.io/dmpe/django-wohn-frontend:latest .
echo $DOCKER_PASS | docker login -u $DOCKER_LOGIN --password-stdin quay.io
docker push quay.io/dmpe/django-wohn-frontend:latest
workflows:
version: 2
workflow:
jobs:
- build:
context: DockerHub
18 changes: 17 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#############
#############
### Custom
#############
acme.json
Expand All @@ -23,6 +23,22 @@ env.bak/
venv.bak/
node_modules/


#############
#### JavaScript
#############
.DS_Store
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*

#############
#### Python @ GitHub
#############
Expand Down
13 changes: 11 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"python.formatting.provider": "black",
"python.linting.pylintPath": "/usr/bin/pylint3",
"python.linting.pylintPath": "/usr/bin/pylint",
"python.linting.pylintArgs": ["--load-plugins", "pylint_django"],
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
Expand All @@ -15,5 +15,14 @@
"files.trimTrailingWhitespace": true,
"editor.insertSpaces": true,
"git.ignoreLimitWarning": true,
"python.linting.flake8Enabled": true
"python.linting.flake8Enabled": true,
"editor.formatOnSave": false,
"[javascript]": {
"editor.formatOnSave": true
},
"eslint.autoFixOnSave": true,
"tslint.autoFixOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.tslint": true
}
}
39 changes: 30 additions & 9 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
{
"label": "isort",
"type": "shell",
"command": "isort -rc ."
"command": "isort -rc . --apply"
},
{
"label": "Docker build",
"label": "Docker Backend",
"type": "shell",
"command": "docker build -t dj-wohn .",
"group": {
"kind": "build",
"isDefault": true
}
"command": "docker build -t django-wohn-backend:latest backend/",
"problemMatcher": []
},
{
"label": "Docker Frontend",
"type": "shell",
"command": "docker build -t django-wohn-frontend:latest frontend/",
"problemMatcher": []
},
{
"label": "black",
Expand All @@ -28,17 +31,35 @@
"command": "flake8 ."
},
{
"label": "Test",
"label": "JS/TS format",
"type": "shell",
"command": "tslint --project ./frontend"
},
{
"label": "Format",
"dependsOrder": "sequence",
"dependsOn": [
"isort",
"black",
"flake8"
"flake8",
"JS/TS format",
],
"group": {
"kind": "test",
"isDefault": true
}
},
{
"label": "Build docker images",
"dependsOrder": "parallel",
"dependsOn": [
"Docker Backend",
"Docker Frontend"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
![GitHub repo size](https://img.shields.io/github/repo-size/dmpe/django-wohn)
![Docker Pulls](https://img.shields.io/docker/pulls/f789gh/django-wohn)
![Docker Automated](https://img.shields.io/docker/automated/f789gh/django-wohn)
![Docker Builds](https://img.shields.io/docker/build/f789gh/django-wohn)
[![Docker Repository on Quay](https://quay.io/repository/dmpe/django-wohn-frontend/status "Docker Repository on Quay")](https://quay.io/repository/dmpe/django-wohn-frontend)
[![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed-raw/dmpe/django-wohn)](https://github.com/dmpe/django-wohn/pulls?q=is%3Apr+is%3Aclosed)
[![HSTS Domain](https://img.shields.io/hsts/preload/monitor.melive.xyz)](https://dev.ssllabs.com/ssltest/analyze.html?d=monitor.melive.xyz&hideResults=on)
![Mozilla HTTP Observatory Grade](https://img.shields.io/mozilla-observatory/grade-score/monitor.melive.xyz?publish)
Expand Down
File renamed without changes.
13 changes: 7 additions & 6 deletions Dockerfile → backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ LABEL author="John Malc <cincenko@outlook.com>"
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

RUN mkdir -p /wohn
RUN mkdir -p /wohn && \
apt update && \
apt install -y nano tree locate graphviz libgraphviz-dev

WORKDIR /wohn
ADD . /wohn

RUN apt update && \
apt install -y nano tree locate graphviz libgraphviz-dev && \
pip install -r requirenments.txt && \
RUN pip install -r requirenments.txt && \
chmod +x start_django.sh

EXPOSE 8000 8123

# TODO: set entrypoint once container can start
# ENTRYPOINT ["./start_django.sh"]
CMD ["./start_django.sh"]
ENTRYPOINT ["./start_django.sh"]
#CMD ["./start_django.sh"]
File renamed without changes.
6 changes: 4 additions & 2 deletions core/admin.py → backend/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def changelist_view(self, request, extra_context=None):
try:
# fetches "table" data
qs = response.context_data["cl"].queryset
except (AttributeErtodayror, KeyError):
except (AttributeError, KeyError):
return response

# needs to have JSON object with 3 large arrays - one for each currency
Expand Down Expand Up @@ -164,5 +164,7 @@ def prepare_data(self, queryset=None, currency=None):


admin.site.register(myUser, UserAdmin)
admin.site.register(Property, PropertyAdmin)
admin.site.register(Room, PropertyAdmin)
admin.site.register(House, PropertyAdmin)
admin.site.register(Apartment, PropertyAdmin)
admin.site.register(ExchangeRate, ExchangeRateAdmin)
File renamed without changes.
26 changes: 13 additions & 13 deletions core/backends.py → backend/core/backends.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf import settings
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.hashers import *
from django.core.validators import *
from django.core.validators import validate_email
from django.db import *

from .mics import *
Expand All @@ -10,13 +10,13 @@

class EmailUserNameAuthBackend(ModelBackend):
"""
This is used for authentication of myUsers
using either username or email in the input field.
By default, username/password is used and this
extends the approach with the email/password.
This is used for authentication of myUsers
using either username or email in the input field.
By default, username/password is used and this
extends the approach with the email/password.
Should work on /admin/ and on /administration/
"""
Should work on /admin/ and on /administration/
"""

def get_user(self, user_id):
try:
Expand All @@ -42,15 +42,15 @@ def authenticate(self, request, username=None, password=None):

def check_for_user_existence(self, inputString=None):
"""
check in the database if the username or email does exist
if yes, return positive bool value
check in the database if the username or email does exist
if yes, return positive bool value
Used for email-based password reset
Used for email-based password reset
:param inputString: either it can be a username or email
:param inputString: either it can be a username or email
:returns: user object if user found and bool value (TRUE, FALSE)
"""
:returns: user object if user found and bool value (TRUE, FALSE)
"""
getUserObject, presentInSystem = None, False
is_valid = validate_email(inputString)

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5107d44

Please sign in to comment.