Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Circleci project setup #26

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
47 changes: 47 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Use the latest 2.1 version of CircleCI pipeline process engine.
# See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1

# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects.
# See: https://circleci.com/docs/2.0/orb-intro/
orbs:
# The python orb contains a set of prepackaged CircleCI configuration you can use repeatedly in your configuration files
# Orb commands and jobs help you with common scripting around a language/tool
# so you dont have to copy and paste it everywhere.
# See the orb documentation here: https://circleci.com/developer/orbs/orb/circleci/python
python: circleci/python@1.5.0

# Define a job to be invoked later in a workflow.
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
jobs:
build-and-test: # This is the name of the job, feel free to change it to better match what you're trying to do!
# These next lines defines a Docker executors: https://circleci.com/docs/2.0/executor-types/
# You can specify an image from Dockerhub or use one of the convenience images from CircleCI's Developer Hub
# A list of available CircleCI Docker convenience images are available here: https://circleci.com/developer/images/image/cimg/python
# The executor is the environment in which the steps below will be executed - below will use a python 3.10.2 container
# Change the version below to your required version of python
docker:
- image: cimg/python:3.10.2
# Checkout the code as the first step. This is a dedicated CircleCI step.
# The python orb's install-packages step will install the dependencies from a Pipfile via Pipenv by default.
# Here we're making sure we use just use the system-wide pip. By default it uses the project root's requirements.txt.
# Then run your tests!
# CircleCI will report the results back to your VCS provider.
steps:
- checkout
- python/install-packages:
pkg-manager: pip
# app-dir: ~/project/package-directory/ # If you're requirements.txt isn't in the root directory.
# pip-dependency-file: test-requirements.txt # if you have a different name for your requirements file, maybe one that combines your runtime and test requirements.
- run:
name: Run tests
# This assumes pytest is installed via the install-package step above
command: pytest

# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
sample: # This is the name of the workflow, feel free to change it to better match your workflow.
# Inside the workflow, you define the jobs you want to run.
jobs:
- build-and-test
Empty file added lettings/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions lettings/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.contrib import admin
from .models import Letting, Address

admin.site.register(Letting)
admin.site.register(Address)
5 changes: 5 additions & 0 deletions lettings/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class LettingsConfig(AppConfig):
name = 'lettings'
87 changes: 87 additions & 0 deletions lettings/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Generated by Django 3.0 on 2022-09-16 14:54

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = []

operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.CreateModel(
name="Address",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"number",
models.PositiveIntegerField(
validators=[django.core.validators.MaxValueValidator(9999)]
),
),
("street", models.CharField(max_length=64)),
("city", models.CharField(max_length=64)),
(
"state",
models.CharField(
max_length=2,
validators=[django.core.validators.MinLengthValidator(2)],
),
),
(
"zip_code",
models.PositiveIntegerField(
validators=[django.core.validators.MaxValueValidator(99999)]
),
),
(
"country_iso_code",
models.CharField(
max_length=3,
validators=[django.core.validators.MinLengthValidator(3)],
),
),
],
options={
"verbose_name": "address",
"verbose_name_plural": "adresses",
},
),
migrations.CreateModel(
name="Letting",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("title", models.CharField(max_length=256)),
(
"address",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to="lettings.Address"
),
),
],
),
],
database_operations=[],
)
]
Empty file added lettings/migrations/__init__.py
Empty file.
15 changes: 5 additions & 10 deletions oc_lettings_site/models.py → lettings/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.db import models
from django.core.validators import MaxValueValidator, MinLengthValidator
from django.contrib.auth.models import User


class Address(models.Model):
@@ -11,8 +10,12 @@ class Address(models.Model):
zip_code = models.PositiveIntegerField(validators=[MaxValueValidator(99999)])
country_iso_code = models.CharField(max_length=3, validators=[MinLengthValidator(3)])

class Meta:
verbose_name = "address"
verbose_name_plural = "adresses"

def __str__(self):
return f'{self.number} {self.street}'
return f"{self.number} {self.street}"


class Letting(models.Model):
@@ -21,11 +24,3 @@ class Letting(models.Model):

def __str__(self):
return self.title


class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
favorite_city = models.CharField(max_length=64, blank=True)

def __str__(self):
return self.user.username
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions lettings/tests/unit_test/lettings_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.test import TestCase
from lettings.models import Letting, Address
import pytest


@pytest.mark.django_db
class LettingTestCase(TestCase):
def setUp(self):
address = Address.objects.create(
number=1,
street="rue du test",
city="testville",
state="testland",
zip_code="01000",
country_iso_code="fr",
)
Letting.objects.create(title="titre", address=address)

def test_create_Letting(self):
letting = Letting.objects.get(id=1)
self.assertEqual(letting.title, "titre")
29 changes: 29 additions & 0 deletions lettings/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.shortcuts import render
from .models import Letting


# Aenean leo magna, vestibulum et tincidunt fermentum, consectetur quis velit. Sed non placerat
# massa. Integer est nunc, pulvinar a tempor et, bibendum id arcu. Vestibulum ante ipsum primis in
# faucibus orci luctus et ultrices posuere cubilia curae; Cras eget scelerisque
def index(request):
lettings_list = Letting.objects.all()
context = {"lettings_list": lettings_list}
return render(request, "lettings/index.html", context)


# Cras ultricies dignissim purus, vitae hendrerit ex varius non. In accumsan porta nisl id
# eleifend. Praesent dignissim, odio eu consequat pretium, purus urna vulputate arcu, vitae
# efficitur lacus justo nec purus. Aenean finibus faucibus lectus at porta. Maecenas auctor, est ut
# luctus congue, dui enim mattis enim, ac condimentum velit libero in magna. Suspendisse potenti.
# In tempus a nisi sed laoreet. Suspendisse porta dui eget sem accumsan interdum. Ut quis urna
# pellentesque justo mattis ullamcorper ac non tellus. In tristique mauris eu velit fermentum,
# tempus pharetra est luctus. Vivamus consequat aliquam libero, eget bibendum lorem. Sed non dolor
# risus. Mauris condimentum auctor elementum. Donec quis nisi ligula. Integer vehicula tincidunt
# enim, ac lacinia augue pulvinar sit amet.
def letting(request, letting_id):
letting = Letting.objects.get(id=letting_id)
context = {
"title": letting.title,
"address": letting.address,
}
return render(request, "lettings/letting.html", context)
Binary file modified oc-lettings-site.sqlite3
Binary file not shown.
10 changes: 0 additions & 10 deletions oc_lettings_site/admin.py

This file was deleted.

17 changes: 17 additions & 0 deletions oc_lettings_site/migrations/0002_auto_20220916_1449.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.0 on 2022-09-16 14:49

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('oc_lettings_site', '0001_initial'),
]

operations = [
migrations.AlterModelOptions(
name='address',
options={'verbose_name': 'address', 'verbose_name_plural': 'adresses'},
),
]
35 changes: 35 additions & 0 deletions oc_lettings_site/migrations/0003_auto_20220916_1454.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 3.0 on 2022-09-16 14:54

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("oc_lettings_site", "0002_auto_20220916_1449"),
]

operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.RemoveField(
model_name="letting",
name="address",
),
migrations.RemoveField(
model_name="profile",
name="user",
),
migrations.DeleteModel(
name="Address",
),
migrations.DeleteModel(
name="Letting",
),
migrations.DeleteModel(
name="Profile",
),
],
database_operations=[],
)
]
Loading