diff --git a/db.sqlite3 b/db.sqlite3
index 5ac2eab..153ca49 100644
Binary files a/db.sqlite3 and b/db.sqlite3 differ
diff --git a/news/__pycache__/models.cpython-37.pyc b/news/__pycache__/models.cpython-37.pyc
index ba692cc..96f9289 100644
Binary files a/news/__pycache__/models.cpython-37.pyc and b/news/__pycache__/models.cpython-37.pyc differ
diff --git a/news/__pycache__/views.cpython-37.pyc b/news/__pycache__/views.cpython-37.pyc
index 4a38b52..ada0fde 100644
Binary files a/news/__pycache__/views.cpython-37.pyc and b/news/__pycache__/views.cpython-37.pyc differ
diff --git a/news/models.py b/news/models.py
index f86e19f..185946d 100644
--- a/news/models.py
+++ b/news/models.py
@@ -4,9 +4,10 @@ from enum import Enum
# Create your models here.
class PostState(Enum):
+ DRAFT = 0
PUBLISHED = 1
- DRAFT = 2
- PROGRAMMED = 3
+ PROGRAMMED = 2
+ USER_SUBMITTED = 3
class Post(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
diff --git a/news/templates/base.html b/news/templates/base.html
index c1d82d0..4ed97a0 100644
--- a/news/templates/base.html
+++ b/news/templates/base.html
@@ -28,8 +28,10 @@
{% if user.is_authenticated %}
[ {{ user.username }} ]
+ {% if user.is_staff %}
Submit
+ {% endif %}
Log out
{% else %}
Log in
diff --git a/news/views.py b/news/views.py
index 3dac6a5..3aca033 100644
--- a/news/views.py
+++ b/news/views.py
@@ -9,7 +9,7 @@ from django.contrib import messages
from django.contrib.auth import authenticate, login, logout, update_session_auth_hash
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import PasswordChangeForm
-from .models import Post, Comment
+from .models import Post, Comment, PostState
from .forms import PostForm, CustomUserCreationForm, SigninForm
from datetime import datetime
import logging
@@ -103,7 +103,10 @@ def submission(request):
handle_uploaded_file(filename, request.FILES['image'])
post.image_url = filename
- post.state = 1
+ if request.user.is_staff:
+ post.state = PostState.PUBLISHED
+ else:
+ post.state = PostState.USER_SUBMITTED
post.save()
return HttpResponseRedirect(reverse('news:submitted'))