# Path: course/models/news.py
# class News(models.Model):
#     def __str__(self):
#     def render_entry(self):
#     def render_date(self):
# 
# Path: course/forms.py
# class NewsForm(ModelForm):
#     class Meta:
#         model = News
#         fields = [
#             'headline',
#             'entry'
#         ]
# 
# Path: util/error/reporting.py
# def db_error(message):
#     """
#     Report a database error in a view.
#     """
#     return render_to_response('error/db.html', {'error': message})


from django.urls import reverse
from django.contrib.auth.decorators import login_required, permission_required
from django.shortcuts import redirect, render
from django.views.decorators.http import require_POST
from django.utils.translation import ugettext as _
from django.http import HttpRequest
from course.models import news
from course.forms import NewsForm
from util.error.reporting import db_error




@login_required()
@permission_required('news.add_news')
def create(request):
    if request.method == 'POST':
        form = NewsForm(request.POST)
        if form.is_valid():

# Path: course/models/news.py
# class News(models.Model):
#     def __str__(self):
#     def render_entry(self):
#     def render_date(self):
# 
# Path: course/forms.py
# class NewsForm(ModelForm):
#     class Meta:
#         model = News
#         fields = [
#             'headline',
#             'entry'
#         ]
# 
# Path: util/error/reporting.py
# def db_error(message):
#     """
#     Report a database error in a view.
#     """
#     return render_to_response('error/db.html', {'error': message})


# Path: course/views/news.py
from django.urls import reverse
from django.contrib.auth.decorators import login_required, permission_required
from django.shortcuts import redirect, render
from django.views.decorators.http import require_POST
from django.utils.translation import ugettext as _
from django.http import HttpRequest
from course.models import news
from course.forms import NewsForm
from util.error.reporting import db_error





@login_required()
@permission_required('news.add_news')
def create(request):
    if request.method == 'POST':
        form = NewsForm(request.POST)
        if form.is_valid():

            news_item = form.save(commit=False)