diff --git a/news/choices.py b/news/choices.py index 74ac3e2..939064d 100644 --- a/news/choices.py +++ b/news/choices.py @@ -1,5 +1,5 @@ STYLE_CHOICES = ( - (0, "Standard"), - (1, "Quote"), - (2, "Image Only") + (0, "Standard [Title + URL + Image]"), + (1, "Quote [Title]"), + (2, "Image Only [Image]") ) diff --git a/news/forms.py b/news/forms.py index 652e213..3874a87 100644 --- a/news/forms.py +++ b/news/forms.py @@ -11,17 +11,15 @@ class PostForm(forms.Form): style = forms.ChoiceField(label='Style',choices=STYLE_CHOICES, required=True) title = forms.CharField(label='Title', max_length=200, required=False) - body = forms.CharField(label='Optional text', max_length=10000, required=False) - url = forms.CharField(label='URL', max_length=200, required=False) - # date = forms.DateTimeField('date published') - # state = forms.IntegerField(label='State', default=1) + + body = forms.CharField(label='Optional body', max_length=10000, required=False) today = datetime.today() # + datetime.timedelta(days=1) today_formatted = today.strftime("%Y-%m-%d %H:%M:%S") + image = forms.FileField(required=False) pub_date = forms.DateTimeField(label='Optional publication date, example: ' + today_formatted, required=False) - image = forms.FileField() class SigninForm(forms.Form): username = forms.CharField(label='Enter Username', min_length=4, max_length=150) diff --git a/news/static/news/css/app.css b/news/static/news/css/app.css index e68f179..f7f6ad6 100644 --- a/news/static/news/css/app.css +++ b/news/static/news/css/app.css @@ -152,18 +152,6 @@ a h1 { } } -.inside_image_top { - position: absolute; - top: 12px; - left: 12px; -} - -.inside_image_bottom { - position: absolute; - bottom: 12px; - left: 12px; -} - .details { font-size: 14px; color: #999; @@ -197,12 +185,34 @@ a h1 { } @media print, screen and (min-width: 40em) { .imgcontainer { - width: 500px; + width: 600px; border-bottom: 10px solid #111; border-top: 10px solid #111; } } +.imgcontainer h1 { + padding: 0px 8px; + line-height: 120%; +} + +.imgcontainer h1 span { + background-color: #111111; +} + +.inside_image_top { + position: absolute; + top: 0px; + left: 12px; + right: 12px; +} + +.inside_image_bottom { + position: absolute; + bottom: 12px; + left: 12px; +} + .post { padding: 10px 0px; margin-bottom: 10px; @@ -293,7 +303,7 @@ input[type=email] { input[type=file] { font-size: 14px; padding:10px 15px; - background:#e8e8e8; + background:#555; border:0 none; cursor:pointer; -webkit-border-radius: 8px; @@ -303,7 +313,7 @@ input[type=file] { input[type=file]:hover { font-size: 14px; padding:10px 15px; - background:#fcf; + background:#777; border:0 none; cursor:pointer; -webkit-border-radius: 8px; diff --git a/news/templates/news/index.html b/news/templates/news/index.html index 747f42f..7e2dbbe 100644 --- a/news/templates/news/index.html +++ b/news/templates/news/index.html @@ -30,7 +30,7 @@
{% if post.url %}{% endif %} -

{{ post.title }}

+

{{ post.title }}

{% if post.url %}
{% endif %} {% if post.body %} diff --git a/news/views.py b/news/views.py index 809cd41..4b0f68e 100644 --- a/news/views.py +++ b/news/views.py @@ -106,10 +106,12 @@ def submission(request): post.url = form.cleaned_data['url'] post.style = form.cleaned_data['style'] - filename = str(uuid.uuid4()) - handle_uploaded_file(filename, request.FILES['image']) + file = request.FILES.get('image', None) + if file is not None: + filename = str(uuid.uuid4()) + handle_uploaded_file(filename, file) + post.image_url = filename - post.image_url = filename if request.user.is_staff: post.state = PostState.PUBLISHED.value pub_date = form.cleaned_data['pub_date']