# Path: course/models/subject.py
# class Subject(models.Model):
#     def __str__(self):
#     def render_description(self):
#     def get_active(cls):
#     def get_visible(cls):
#     def get_inactive(cls):
#     def get_invisible(cls):
#     def active_courses(self):
#     def visible_courses(self):
#     def is_active(self):
#     def is_visible(self):
# 
# Path: course/forms.py
# class SubjectForm(ModelForm):
#     name = forms.CharField(
#         validators=[subject_name_validator,
#                     subject_disallowed_names_validator],
#         help_text=_(
#             'Name of the subject, also decides its url. '
#             'Allowed characters are word characters, numbers, spaces, '
#             '\'-\' and \'_\' and it cannot be any of '
#             + ', ').join(map(lambda a: '\'' + a + '\'', SUBJECT_DISALLOWED_NAMES)) + '.'
#     )
# 
#     class Meta:
#         model = Subject
#         fields = [
#             'name',
#             'description_en',
#             'description_de',
#         ]
# 
# 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 course.models import subject
from course.forms import SubjectForm
from util.error.reporting import db_error
            'target': reverse('subject', args=(subjectname,))
        }
    )


def subject_overview(request):
    return render(
        request,
        'subject/overview.html',
        {
            'title': _('Subject Overview'),
            'visible_subjects': subject.Subject.get_visible(),
            'invisible_subjects': subject.Subject.get_invisible()
        }
    )


@login_required()
@permission_required('subject.add_subject')
def create(request):
    if request.method == 'POST':
        form = SubjectForm(request.POST)
        if form.is_valid():

            created = form.save()
            return redirect('subject', created.name)

    else:
        form = SubjectForm()
        form.initial['description'] = _((

# Path: course/models/subject.py
# class Subject(models.Model):
#     def __str__(self):
#     def render_description(self):
#     def get_active(cls):
#     def get_visible(cls):
#     def get_inactive(cls):
#     def get_invisible(cls):
#     def active_courses(self):
#     def visible_courses(self):
#     def is_active(self):
#     def is_visible(self):
# 
# Path: course/forms.py
# class SubjectForm(ModelForm):
#     name = forms.CharField(
#         validators=[subject_name_validator,
#                     subject_disallowed_names_validator],
#         help_text=_(
#             'Name of the subject, also decides its url. '
#             'Allowed characters are word characters, numbers, spaces, '
#             '\'-\' and \'_\' and it cannot be any of '
#             + ', ').join(map(lambda a: '\'' + a + '\'', SUBJECT_DISALLOWED_NAMES)) + '.'
#     )
# 
#     class Meta:
#         model = Subject
#         fields = [
#             'name',
#             'description_en',
#             'description_de',
#         ]
# 
# 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/subject.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 course.models import subject
from course.forms import SubjectForm
from util.error.reporting import db_error

            'target': reverse('subject', args=(subjectname,))
        }
    )


def subject_overview(request):
    return render(
        request,
        'subject/overview.html',
        {
            'title': _('Subject Overview'),
            'visible_subjects': subject.Subject.get_visible(),
            'invisible_subjects': subject.Subject.get_invisible()
        }
    )


@login_required()
@permission_required('subject.add_subject')
def create(request):
    if request.method == 'POST':
        form = SubjectForm(request.POST)
        if form.is_valid():

            created = form.save()
            return redirect('subject', created.name)

    else:
        form = SubjectForm()
        form.initial['description'] = _((

            'English is a weakly typed, interpreted language and runs on a '