Skip to content

Commit 8441373

Browse files
committed
Initialize recipe school project
0 parents  commit 8441373

File tree

75 files changed

+830
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+830
-0
lines changed

db.sqlite3

53 KB
Binary file not shown.

manage.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "spjaproject.settings")
7+
8+
from django.core.management import execute_from_command_line
9+
10+
execute_from_command_line(sys.argv)

recipes/__init__.py

Whitespace-only changes.

recipes/__init__.pyc

146 Bytes
Binary file not shown.
142 Bytes
Binary file not shown.
1.26 KB
Binary file not shown.
1.38 KB
Binary file not shown.
2.3 KB
Binary file not shown.
854 Bytes
Binary file not shown.
3.03 KB
Binary file not shown.

recipes/admin.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from django.contrib import admin
2+
3+
from .models import Chef, Recipe, Comment
4+
5+
class ChefAdmin(admin.ModelAdmin):
6+
fieldsets = [
7+
('Person Information', {'fields': ['name', 'experience', 'age']}),
8+
('Date information', {'fields': ['date_added']}),
9+
]
10+
11+
list_display = ('name', 'age', 'experience')
12+
13+
class RecipeAdmin(admin.ModelAdmin):
14+
fieldsets = [
15+
('Recipe Information', {'fields': ['chef', 'r_title', 'ingredients', 'process']}),
16+
('Date information', {'fields': ['date_published']}),
17+
]
18+
19+
class CommentAdmin(admin.ModelAdmin):
20+
fieldsets = [
21+
('Comment', {'fields': ['recipe', 'c_title', 'nick', 'text']}),
22+
('Date', {'fields': ['date_commented']}),
23+
]
24+
25+
admin.site.register(Chef, ChefAdmin)
26+
admin.site.register(Recipe, RecipeAdmin)
27+
admin.site.register(Comment, CommentAdmin)

recipes/admin.pyc

1.5 KB
Binary file not shown.

recipes/forms.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from django import forms
2+
3+
from .models import Comment, Recipe, Chef
4+
5+
class CommentForm(forms.ModelForm):
6+
7+
class Meta:
8+
model = Comment
9+
fields = ('nick', 'c_title', 'text')
10+
11+
class RecipeForm(forms.ModelForm):
12+
13+
class Meta:
14+
model = Recipe
15+
fields = ('r_title', 'ingredients', 'process')
16+
17+
class ChefForm(forms.ModelForm):
18+
19+
class Meta:
20+
model = Chef
21+
fields = ('name', 'age', 'experience')

recipes/migrations/0001_initial.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
import django.core.validators
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Chef',
16+
fields=[
17+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
18+
('name', models.CharField(max_length=50)),
19+
('age', models.IntegerField(verbose_name=[django.core.validators.MinValueValidator(6), django.core.validators.MaxValueValidator(120)])),
20+
('experience', models.CharField(max_length=1, choices=[(b'B', b'Beginner'), (b'A', b'Advanced'), (b'E', b'Expert'), (b'M', b'Magical')])),
21+
('date_added', models.DateTimeField()),
22+
],
23+
),
24+
migrations.CreateModel(
25+
name='Coment',
26+
fields=[
27+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
28+
('nick', models.CharField(max_length=10)),
29+
('c_title', models.CharField(max_length=40)),
30+
('text', models.TextField(max_length=1000)),
31+
('date_commented', models.DateTimeField()),
32+
],
33+
),
34+
migrations.CreateModel(
35+
name='Recipe',
36+
fields=[
37+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
38+
('r_title', models.CharField(max_length=70)),
39+
('ingredients', models.CharField(max_length=255)),
40+
('process', models.TextField()),
41+
('date_published', models.DateTimeField()),
42+
('date_edited', models.DateTimeField()),
43+
('chef', models.ForeignKey(to='recipes.Chef')),
44+
],
45+
),
46+
migrations.AddField(
47+
model_name='coment',
48+
name='recipe',
49+
field=models.ForeignKey(to='recipes.Recipe'),
50+
),
51+
]

recipes/migrations/0001_initial.pyc

2.03 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('recipes', '0001_initial'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='chef',
16+
name='age',
17+
field=models.IntegerField(),
18+
),
19+
]
797 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('recipes', '0002_auto_20151128_1404'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='chef',
16+
name='experience',
17+
field=models.CharField(max_length=30),
18+
),
19+
]
849 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
import django.core.validators
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('recipes', '0003_auto_20151128_1408'),
12+
]
13+
14+
operations = [
15+
migrations.AlterField(
16+
model_name='chef',
17+
name='age',
18+
field=models.IntegerField(verbose_name=[django.core.validators.MinValueValidator(6), django.core.validators.MaxValueValidator(120)]),
19+
),
20+
migrations.AlterField(
21+
model_name='chef',
22+
name='experience',
23+
field=models.CharField(max_length=1, choices=[(b'B', b'Beginner'), (b'A', b'Advanced'), (b'E', b'Expert'), (b'M', b'Magical')]),
24+
),
25+
]
1.27 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('recipes', '0004_auto_20151128_1411'),
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='Comment',
16+
fields=[
17+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
18+
('nick', models.CharField(max_length=10)),
19+
('c_title', models.CharField(max_length=40)),
20+
('text', models.TextField(max_length=1000)),
21+
('date_commented', models.DateTimeField()),
22+
('recipe', models.ForeignKey(to='recipes.Recipe')),
23+
],
24+
),
25+
migrations.RemoveField(
26+
model_name='coment',
27+
name='recipe',
28+
),
29+
migrations.DeleteModel(
30+
name='Coment',
31+
),
32+
]
1.29 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('recipes', '0005_auto_20151128_1413'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='chef',
16+
name='experience',
17+
field=models.CharField(max_length=1, choices=[('B', 'Beginner'), ('A', 'Advanced'), ('E', 'Expert'), ('M', 'Magical')]),
18+
),
19+
]
1.02 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
import django.core.validators
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('recipes', '0006_auto_20151128_1427'),
12+
]
13+
14+
operations = [
15+
migrations.AlterField(
16+
model_name='chef',
17+
name='age',
18+
field=models.IntegerField(validators=[django.core.validators.MinValueValidator(6), django.core.validators.MaxValueValidator(120)]),
19+
),
20+
]
1001 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
import django.core.validators
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('recipes', '0007_auto_20151128_1439'),
12+
]
13+
14+
operations = [
15+
migrations.AlterField(
16+
model_name='chef',
17+
name='age',
18+
field=models.IntegerField(validators=[django.core.validators.MinValueValidator(10), django.core.validators.MaxValueValidator(110)]),
19+
),
20+
migrations.AlterField(
21+
model_name='chef',
22+
name='experience',
23+
field=models.CharField(choices=[('B', 'Beginner'), ('A', 'Advanced'), ('E', 'Expert'), ('M', 'Magical')], max_length=50),
24+
),
25+
]
1.26 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('recipes', '0008_auto_20151128_1454'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='chef',
16+
name='experience',
17+
field=models.CharField(max_length=50),
18+
),
19+
]
849 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('recipes', '0009_auto_20151205_1046'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='recipe',
16+
name='ingredients',
17+
field=models.TextField(max_length=2000),
18+
),
19+
]
852 Bytes
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('recipes', '0010_auto_20151205_1120'),
11+
]
12+
13+
operations = [
14+
migrations.RemoveField(
15+
model_name='recipe',
16+
name='date_edited',
17+
),
18+
]
Binary file not shown.

recipes/migrations/__init__.py

Whitespace-only changes.

recipes/migrations/__init__.pyc

157 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

recipes/models.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from django.db import models
2+
from django.core.validators import MinValueValidator, MaxValueValidator
3+
from django.utils import timezone
4+
import datetime
5+
6+
7+
# Create your models here.
8+
class Chef(models.Model):
9+
"""EXPERIENCES = (
10+
('B', 'Beginner'),
11+
('A', 'Advanced'),
12+
('E', 'Expert'),
13+
('M', 'Magical'),
14+
)"""
15+
name = models.CharField(max_length=50)
16+
age = models.IntegerField(validators=[MinValueValidator(10), MaxValueValidator(110)])
17+
experience = models.CharField(max_length=50)
18+
date_added = models.DateTimeField()
19+
20+
def __str__(self):
21+
return self.name + ": " + str(self.age) + ", " + self.experience
22+
23+
class Recipe(models.Model):
24+
chef = models.ForeignKey(Chef)
25+
r_title = models.CharField(max_length=70)
26+
ingredients = models.TextField(max_length=2000)
27+
process = models.TextField()
28+
date_published = models.DateTimeField()
29+
30+
def __str__(self):
31+
return self.r_title + ", published: " + str(self.date_published.strftime("%H:%M:%S %d.%m.%Y"))
32+
33+
class Comment(models.Model):
34+
recipe = models.ForeignKey(Recipe)
35+
nick = models.CharField(max_length=10)
36+
c_title = models.CharField(max_length=40)
37+
text = models.TextField(max_length=1000)
38+
date_commented = models.DateTimeField()
39+
40+
def __str__(self):
41+
return self.nick + ": " + self.c_title + ", published: " + str(self.date_commented.strftime("%H:%M:%S %d.%m.%Y"))
42+
43+
def was_commented_recently(self):
44+
return self.date_commented >= timezone.now() - datetime.timedelta(days=1)
45+
46+
#from recipes.models import Chef, Recipe, Comment

recipes/models.pyc

2.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)