From 5434e0d765a445685a85a36ef55a7e4949f649f1 Mon Sep 17 00:00:00 2001 From: jtweeder Date: Tue, 11 Jul 2023 21:02:58 -0500 Subject: [PATCH 1/2] centered rec cards --- .gitignore | 1 + templates/stewpot/meal_post.html | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 441efff..f5f2132 100644 --- a/.gitignore +++ b/.gitignore @@ -111,3 +111,4 @@ venv.bak/ manage.py dev_static/ +meals/migrations/__pycache__/__init__.cpython-310.pyc diff --git a/templates/stewpot/meal_post.html b/templates/stewpot/meal_post.html index 09c2568..e5811c0 100644 --- a/templates/stewpot/meal_post.html +++ b/templates/stewpot/meal_post.html @@ -4,14 +4,11 @@ {% block css_style %} -.list{ - text-align: center; -} -.container { - border-radius: 5px; - padding: 20px; -} +#rec { + margin: auto; + padding: 10px + } {% endblock css_style %} @@ -24,9 +21,9 @@

{{pp.title}}

{% for meal in shared_meals %} -

{{meal.title}}

+

{{meal.title}}

-
+
From b546e74d82e3f5c7b218fe8243ad2994674393d5 Mon Sep 17 00:00:00 2001 From: jtweeder Date: Wed, 12 Jul 2023 19:05:05 -0500 Subject: [PATCH 2/2] final touches to launch blog feature --- stewpot/test_stewpot.py | 44 +++++++++++++++++++-------------- stewpot/tests.py | 3 --- stewpot/urls.py | 2 ++ stewpot/views.py | 19 ++++++++------ templates/base.html | 1 + templates/stewpot/postings.html | 28 +++++++++++++++++++++ 6 files changed, 68 insertions(+), 29 deletions(-) delete mode 100644 stewpot/tests.py create mode 100644 templates/stewpot/postings.html diff --git a/stewpot/test_stewpot.py b/stewpot/test_stewpot.py index 3bb2d98..c7491bf 100644 --- a/stewpot/test_stewpot.py +++ b/stewpot/test_stewpot.py @@ -8,22 +8,22 @@ class share_meal(TestCase): def setUp(self): self.tst_user = User.objects.create_user('john', - 'lennon@thebeatles.com', - 'johnpassword') + 'lennon@thebeatles.com', + 'johnpassword') self.tst_recipe = mstr_recipe.objects.create(meal_id=uuid.uuid1(), - title='TestTitle2', - rec_url="https://www.mealcurator.com", - vegan=False, - vegetarian=False, - meal_time='bk', - dish_type='sp', - cooking_method='st', - cooking_time='20', - times_selected=0, - sumreview=0, - numreview=0, - found_words="test" - ) + title='TestTitle2', + rec_url="https://www.mealcurator.com", + vegan=False, + vegetarian=False, + meal_time='bk', + dish_type='sp', + cooking_method='st', + cooking_time='20', + times_selected=0, + sumreview=0, + numreview=0, + found_words="test" + ) self.share_meal = (models.share_meal .objects.create(title='ShareTest', creator=self.tst_user, @@ -34,13 +34,13 @@ def setUp(self): .objects.create(title='Test Posting', creator=self.tst_user, text='A Test Posting Post') - ) + ) self.share_meal_posting = (models.share_meal .objects.create(title='PostingTest', creator=self.tst_user, text='Posting Meal Test', meal=self.tst_recipe) - ) + ) self.factory = RequestFactory() @@ -54,7 +54,13 @@ def test_share_start(self): self.assertEqual(response.status_code, 200) def test_posting(self): - request = self.factory.get(f'share/post') + request = self.factory.get('/share/post') request.user = self.tst_user response = views.view_share(request, self.meal_posting.id) - self.assertEqual(response.status_code, 200) \ No newline at end of file + self.assertEqual(response.status_code, 200) + + def test_blog(self): + request = self.factory.get('/share/post') + request.user = self.tst_user + response = views.home_postings(request) + self.assertEqual(response.status_code, 200) diff --git a/stewpot/tests.py b/stewpot/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/stewpot/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/stewpot/urls.py b/stewpot/urls.py index 650ba6f..3a66921 100644 --- a/stewpot/urls.py +++ b/stewpot/urls.py @@ -7,4 +7,6 @@ path('', share_views.save_share, name='save-shared'), path('view/', share_views.view_share, name='view-shared'), path('post/', share_views.view_posting, name='view-posting'), + path('post/', share_views.home_postings, name='home-postings'), + ] diff --git a/stewpot/views.py b/stewpot/views.py index c066994..472374a 100644 --- a/stewpot/views.py +++ b/stewpot/views.py @@ -8,22 +8,22 @@ # TODO: Let someone add a shared recipe to a list/make a list # TODO: Let Admins make multiple recipes and make a blogpost about them - -# Landing page for capturing title and text from user @login_required def start_share(request, meal_id): + """Landing page for capturing title and text from user""" meal = mstr_recipe.objects.get(meal_id=meal_id) template = 'stewpot/share.html' context = {'meal': meal, 'start': True} return render(request, template, context) - -# Create share_meal and redirect to view of it @login_required def save_share(request): + """Create share_meal and redirect to view of it""" if request.method == 'POST': - shared_title = check_blank(request.POST.get('shared_title'), 'A shared recipe from mealCurator') - shared_text = check_blank(request.POST.get('shared_text'), 'I found this on mealCurator and wanted to share it with you') + shared_title = check_blank(request.POST.get('shared_title'), + 'A shared recipe from mealCurator') + shared_text = check_blank(request.POST.get('shared_text'), + 'I found this on mealCurator and wanted to share it with you') shared_meal = mstr_recipe.objects.get(meal_id=request.POST.get('shared_meal')) shared = share_meal.objects.create( @@ -34,7 +34,6 @@ def save_share(request): ) return redirect('view-shared', shared.id) - # View a shared meal def view_share(request, share_id): shared = (share_meal.objects.values('id', @@ -79,3 +78,9 @@ def view_posting(request, post_id): 'shared_meals': shared} template = 'stewpot/meal_post.html' return render(request, template, context) + +def home_postings(request): + posts = meal_posting.objects.all().order_by('created_on') + context = {'posts': posts} + template = 'stewpot/postings.html' + return render(request, template, context) diff --git a/templates/base.html b/templates/base.html index 29b3e34..8b099f4 100644 --- a/templates/base.html +++ b/templates/base.html @@ -135,6 +135,7 @@ {% block botnavbar %}
{{ meal.meal__title }}
Vegan: {{ meal.meal__vegan|yesno:"Yes,No" }}Vegetarian: {{ meal.meal__vegetarian|yesno:"Yes,No" }}