Skip to content

Commit

Permalink
Merge pull request #26 from alissatroiano/style-updates
Browse files Browse the repository at this point in the history
Update view, so artwork deletes if runtime error occurs
  • Loading branch information
alissatroiano authored Aug 29, 2023
2 parents 38bd501 + 971aab5 commit 0c93726
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 19 deletions.
19 changes: 19 additions & 0 deletions hugo/migrations/0009_style_parent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.2 on 2023-08-26 21:01

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


class Migration(migrations.Migration):

dependencies = [
('hugo', '0008_artwork_price'),
]

operations = [
migrations.AddField(
model_name='style',
name='parent',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='hugo.style'),
),
]
1 change: 1 addition & 0 deletions hugo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class Style(models.Model):
name = models.CharField(max_length=254)
friendly_name = models.CharField(max_length=254, null=True, blank=True)
parent = models.ForeignKey('self', null=True, blank=True, on_delete=models.CASCADE)
class Meta:
verbose_name_plural = 'Styles'

Expand Down
31 changes: 24 additions & 7 deletions hugo/static/hugo/css/hugo.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ img.card-img-top {

p#aiPrompt,
p.artwork-desc.body-font {
line-height: 1.5;
font-size: 14px;
line-height: 1.25;
font-size: 12px;
}

.art-card::after {
Expand Down Expand Up @@ -462,6 +462,12 @@ div#smallContent {
.intro {
font-size: 0.8em
}
p#aiPrompt,
p.artwork-desc.body-font {
line-height: 1;
font-size: 10px;
}

}


Expand All @@ -471,25 +477,36 @@ div#smallContent {
top: 10%;
}

p.body-font.my-3.ai-art-desc {
line-height: 2;
font-size: 12px;
}
p#aiPrompt,
p.artwork-desc.body-font {
line-height: 1.25;
font-size: 11px;
}

a.btn.display-font {
font-size: 12px;
}

a.tag-font {
font-size: 10px;
}
#artcardText {
font-size: 10px;
}
#artworkCardTitle {
display: none;
}

}

@media only screen and (min-width: 1280px) {
#artcardText {
font-size: 1rem;
}

p#aiPrompt,
p.artwork-desc.body-font {
line-height: 1.25;
font-size: 14px;
}

}
8 changes: 4 additions & 4 deletions hugo/templates/hugo.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ <h3 class="display-font display-5 my-3" id="artworkTitle">

</div>
<div class="card-info">
<h3 class="display-font" id="artworkCardTitle">
{{ artwork.title }}</h3>
<p class="display-font user-credit"> by
<h5 class="display-font" id="artworkCardTitle">
{{ artwork.title }}</h5>
<p class="display-font user-credits"> by
<a class="display-font user-credit" href="{% url 'artist_artworks' artwork.user.username %}"> {{ artwork.user }}</a>
</p>
<p class="artwork_desc body-font mx-md-3" id="aiPrompt">
<p class="artwork_desc body-font mx-lg-3" id="aiPrompt">
"{{ artwork.artwork_description }}"
</p>
<div class="view-art my-2">
Expand Down
5 changes: 2 additions & 3 deletions hugo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
urlpatterns = [
path('', views.hugo, name='hugo'),
path('<artwork_id>', views.artwork_detail, name='artwork_detail'),
path('add_hugo/', views.add_hugo, name='add_hugo'),
path('test_error/', views.test_error, name='test_error'),
]
path('add_hugo/', views.add_hugo, name='add_hugo')
]

7 changes: 2 additions & 5 deletions hugo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ def add_hugo(request):

return redirect(reverse('hugo'))
except Exception as e:
# Delete the artwork if an exception occurs
artwork.delete()
return render(request, 'runtime_error_template.html', {'error_message': str(e)})
else:
form = ArtworkForm()
Expand All @@ -129,8 +131,3 @@ def add_hugo(request):
context = {'form': form}

return render(request, template, context)

def test_error(request, *args, **kwargs):

return render(request, 'runtime_error_template.html', status=404)

0 comments on commit 0c93726

Please sign in to comment.