Front page
This commit is contained in:
0
CTOAsYouGo/core/__init__.py
Normal file
0
CTOAsYouGo/core/__init__.py
Normal file
BIN
CTOAsYouGo/core/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
CTOAsYouGo/core/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
CTOAsYouGo/core/__pycache__/admin.cpython-310.pyc
Normal file
BIN
CTOAsYouGo/core/__pycache__/admin.cpython-310.pyc
Normal file
Binary file not shown.
BIN
CTOAsYouGo/core/__pycache__/apps.cpython-310.pyc
Normal file
BIN
CTOAsYouGo/core/__pycache__/apps.cpython-310.pyc
Normal file
Binary file not shown.
BIN
CTOAsYouGo/core/__pycache__/models.cpython-310.pyc
Normal file
BIN
CTOAsYouGo/core/__pycache__/models.cpython-310.pyc
Normal file
Binary file not shown.
BIN
CTOAsYouGo/core/__pycache__/urls.cpython-310.pyc
Normal file
BIN
CTOAsYouGo/core/__pycache__/urls.cpython-310.pyc
Normal file
Binary file not shown.
BIN
CTOAsYouGo/core/__pycache__/views.cpython-310.pyc
Normal file
BIN
CTOAsYouGo/core/__pycache__/views.cpython-310.pyc
Normal file
Binary file not shown.
5
CTOAsYouGo/core/admin.py
Normal file
5
CTOAsYouGo/core/admin.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.contrib import admin
|
||||
from .models import Task, Request
|
||||
|
||||
admin.site.register(Task)
|
||||
admin.site.register(Request)
|
||||
6
CTOAsYouGo/core/apps.py
Normal file
6
CTOAsYouGo/core/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CoreConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'core'
|
||||
45
CTOAsYouGo/core/migrations/0001_initial.py
Normal file
45
CTOAsYouGo/core/migrations/0001_initial.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# Generated by Django 4.2.2 on 2023-06-25 12:04
|
||||
|
||||
import django.core.validators
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Task',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=255)),
|
||||
('description', models.TextField()),
|
||||
('price_from', models.IntegerField(validators=[django.core.validators.MinValueValidator(0)])),
|
||||
('price_to', models.IntegerField(validators=[django.core.validators.MinValueValidator(0)])),
|
||||
('needed_information', models.JSONField()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Request',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=255)),
|
||||
('description', models.TextField()),
|
||||
('price_from', models.IntegerField(validators=[django.core.validators.MinValueValidator(0)])),
|
||||
('price_to', models.IntegerField(validators=[django.core.validators.MinValueValidator(0)])),
|
||||
('needed_information', models.JSONField()),
|
||||
('start_in_days', models.IntegerField()),
|
||||
('email', models.EmailField(max_length=254)),
|
||||
('email_confirmation', models.EmailField(max_length=254)),
|
||||
('external_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
|
||||
('comment', models.TextField(blank=True, null=True)),
|
||||
('task', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requests', to='core.task')),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
CTOAsYouGo/core/migrations/__init__.py
Normal file
0
CTOAsYouGo/core/migrations/__init__.py
Normal file
Binary file not shown.
BIN
CTOAsYouGo/core/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
CTOAsYouGo/core/migrations/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
27
CTOAsYouGo/core/models.py
Normal file
27
CTOAsYouGo/core/models.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from django.db import models
|
||||
from django.core.validators import MinValueValidator, MaxValueValidator
|
||||
import uuid
|
||||
|
||||
class Task(models.Model):
|
||||
title = models.CharField(max_length=255)
|
||||
description = models.TextField()
|
||||
price_from = models.IntegerField(validators=[MinValueValidator(0)])
|
||||
price_to = models.IntegerField(validators=[MinValueValidator(0)])
|
||||
needed_information = models.JSONField()
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Request(models.Model):
|
||||
task = models.ForeignKey(Task, related_name='requests', on_delete=models.CASCADE)
|
||||
title = models.CharField(max_length=255)
|
||||
description = models.TextField()
|
||||
price_from = models.IntegerField(validators=[MinValueValidator(0)])
|
||||
price_to = models.IntegerField(validators=[MinValueValidator(0)])
|
||||
needed_information = models.JSONField()
|
||||
start_in_days = models.IntegerField()
|
||||
email = models.EmailField()
|
||||
email_confirmation = models.EmailField()
|
||||
external_id = models.UUIDField(default=uuid.uuid4, editable=False, unique=True)
|
||||
comment = models.TextField(null=True, blank=True)
|
||||
|
||||
47
CTOAsYouGo/core/templates/core/base.html
Normal file
47
CTOAsYouGo/core/templates/core/base.html
Normal file
@@ -0,0 +1,47 @@
|
||||
{% load compress %}
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>CTO As You Go</title>
|
||||
<!-- add your CSS and JS files here -->
|
||||
{% compress css %}
|
||||
<link rel="stylesheet" href="{% static 'src/output.css' %}">
|
||||
{% endcompress %}
|
||||
<script src="https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<header class="bg-white">
|
||||
<div
|
||||
class="mx-auto flex h-16 max-w-screen-xl items-center gap-8 px-4 sm:px-6 lg:px-8"
|
||||
>
|
||||
<a class="block text-teal-600 dark:text-teal-300" href="/">
|
||||
<span class="sr-only">Home</span>
|
||||
<img src="{% static 'images/logo.png' %}" alt="cto as you go logo">
|
||||
</a>
|
||||
|
||||
<div class="flex flex-1 items-center justify-end md:justify-between">
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="sm:flex sm:gap-4">
|
||||
<a
|
||||
class="block rounded-md bg-gray-100 px-5 py-2.5 text-sm font-medium text-teal-600 transition hover:text-teal-600/75 sm:block"
|
||||
href="/why_it_works"
|
||||
>
|
||||
How?
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
28
CTOAsYouGo/core/templates/core/home.html
Normal file
28
CTOAsYouGo/core/templates/core/home.html
Normal file
@@ -0,0 +1,28 @@
|
||||
{% extends 'core/base.html' %}
|
||||
{% load currency_filters %}
|
||||
|
||||
{% block content %}
|
||||
<!-- add your search bar here -->
|
||||
|
||||
<div class="task-cards pt-3">
|
||||
{% for task in tasks %}
|
||||
<article class="rounded-xl border-2 border-gray-200 bg-slate-100 mb-3 ml-3 mr-3">
|
||||
<div class="flex items-start gap-4 p-4 sm:p-6 lg:p-8 ">
|
||||
<div>
|
||||
<h3 class="font-medium sm:text-lg">
|
||||
<a href="/task/{{ task.id }}" class="hover:underline">
|
||||
{{ task.title }}
|
||||
</a>
|
||||
</h3>
|
||||
|
||||
<p class="line-clamp-2 text-sm text-gray-700">
|
||||
From: {{ task.price_from|cents_to_dollars }} To: {{ task.price_to|cents_to_dollars }}
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
10
CTOAsYouGo/core/templates/core/task_details.html
Normal file
10
CTOAsYouGo/core/templates/core/task_details.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{% extends 'core/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<!-- add your task details here -->
|
||||
|
||||
<h2>{{ task.title }}</h2>
|
||||
<p>{{ task.description }}</p>
|
||||
<p>{{ task.price_from }} - {{ task.price_to }}</p>
|
||||
<a href="/task/{{ task.id }}/create_request">Create a request</a>
|
||||
{% endblock %}
|
||||
6
CTOAsYouGo/core/templates/core/why_it_works.html
Normal file
6
CTOAsYouGo/core/templates/core/why_it_works.html
Normal file
@@ -0,0 +1,6 @@
|
||||
{% extends 'core/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Why it works?</h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec mollis volutpat sem, quis ultrices orci imperdiet sit amet.</p>
|
||||
{% endblock %}
|
||||
0
CTOAsYouGo/core/templatetags/__init__.py
Normal file
0
CTOAsYouGo/core/templatetags/__init__.py
Normal file
Binary file not shown.
Binary file not shown.
10
CTOAsYouGo/core/templatetags/currency_filters.py
Normal file
10
CTOAsYouGo/core/templatetags/currency_filters.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from django import template
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def cents_to_dollars(value):
|
||||
try:
|
||||
return "${:.2f}".format(int(value) / 100)
|
||||
except (ValueError, TypeError):
|
||||
return ''
|
||||
3
CTOAsYouGo/core/tests.py
Normal file
3
CTOAsYouGo/core/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
9
CTOAsYouGo/core/urls.py
Normal file
9
CTOAsYouGo/core/urls.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.home, name='home'),
|
||||
path('task/<int:task_id>', views.task_detail, name='task_detail'),
|
||||
path('task/<int:task_id>/create_request', views.create_request, name='create_request'),
|
||||
path('why_it_works', views.why_it_works, name='why_it_works'),
|
||||
]
|
||||
23
CTOAsYouGo/core/views.py
Normal file
23
CTOAsYouGo/core/views.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.shortcuts import render
|
||||
from .models import Task, Request
|
||||
|
||||
def home(request):
|
||||
tasks = Task.objects.all()
|
||||
return render(request, 'core/home.html', {'tasks': tasks})
|
||||
|
||||
def task_detail(request, task_id):
|
||||
task = Task.objects.get(id=task_id)
|
||||
return render(request, 'core/task_detail.html', {'task': task})
|
||||
|
||||
def create_request(request, task_id):
|
||||
if request.method == 'POST':
|
||||
# logic to create a new Request
|
||||
pass
|
||||
else:
|
||||
task = Task.objects.get(id=task_id)
|
||||
return render(request, 'core/create_request.html', {'task': task})
|
||||
|
||||
def why_it_works(request):
|
||||
return render(request, 'core/why_it_works.html')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user