当前位置: 首页>>代码示例>>Python>>正文


Python models.Semester类代码示例

本文整理汇总了Python中evap.evaluation.models.Semester的典型用法代码示例。如果您正苦于以下问题:Python Semester类的具体用法?Python Semester怎么用?Python Semester使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Semester类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: index

def index(request):
    """Main entry page into EvaP providing all the login options available. The username/password
       login is thought to be used for internal users, e.g. by connecting to a LDAP directory.
       The login key mechanism is meant to be used to include external participants, e.g. visiting
       students or visiting contributors.
    """

    # parse the form data into the respective form
    submit_type = request.POST.get("submit_type", "no_submit")
    new_key_form = NewKeyForm(request.POST if submit_type == "new_key" else None)
    login_username_form = LoginUsernameForm(request, request.POST if submit_type == "login_username" else None)

    # process form data
    if request.method == 'POST':
        if new_key_form.is_valid():
            # user wants a new login key
            profile = new_key_form.get_user()
            profile.ensure_valid_login_key()
            profile.save()

            EmailTemplate.send_login_url_to_user(new_key_form.get_user())

            messages.success(request, _("We sent you an email with a one-time login URL. Please check your inbox."))
            return redirect('evaluation:index')
        elif login_username_form.is_valid():
            # user would like to login with username and password and passed password test
            auth.login(request, login_username_form.get_user())

            # clean up our test cookie
            if request.session.test_cookie_worked():
                request.session.delete_test_cookie()

    # if not logged in by now, render form
    if not request.user.is_authenticated:
        # set test cookie to verify whether they work in the next step
        request.session.set_test_cookie()

        template_data = dict(new_key_form=new_key_form, login_username_form=login_username_form)
        return render(request, "index.html", template_data)
    else:
        user, __ = UserProfile.objects.get_or_create(username=request.user.username)

        # check for redirect variable
        redirect_to = request.GET.get("next", None)
        if redirect_to is not None:
            return redirect(redirect_to)

        # redirect user to appropriate start page
        if request.user.is_reviewer:
            return redirect('staff:semester_view', Semester.active_semester().id)
        if request.user.is_manager:
            return redirect('staff:index')
        elif request.user.is_grade_publisher:
            return redirect('grades:semester_view', Semester.active_semester().id)
        elif user.is_student:
            return redirect('student:index')
        elif user.is_contributor_or_delegate:
            return redirect('contributor:index')
        else:
            return redirect('results:index')
开发者ID:PFischbeck,项目名称:EvaP,代码行数:60,代码来源:views.py

示例2: include_navbar

def include_navbar(user, language):
    return {
        'user': user,
        'language': language,
        'published_result_semesters': Semester.get_all_with_published_unarchived_results(),
        'result_semesters': Semester.get_all_with_unarchived_results(),
        'grade_document_semesters': Semester.objects.filter(grade_documents_are_deleted=False),
    }
开发者ID:PFischbeck,项目名称:EvaP,代码行数:8,代码来源:navbar_templatetags.py

示例3: index

def index(request):
    semesters = Semester.get_all_with_published_unarchived_results()
    evaluations = Evaluation.objects.filter(course__semester__in=semesters, state='published')
    evaluations = [evaluation for evaluation in evaluations if evaluation.can_be_seen_by(request.user)]

    if request.user.is_reviewer:
        additional_evaluations = get_evaluations_with_prefetched_data(
            Evaluation.objects.filter(
                course__semester__in=semesters,
                state__in=['in_evaluation', 'evaluated', 'reviewed']
            )
        )
        additional_evaluations = get_evaluations_with_course_result_attributes(additional_evaluations)
        evaluations += additional_evaluations

    evaluations.sort(key=lambda evaluation: (evaluation.course.semester.pk, evaluation.full_name))  # evaluations must be sorted for regrouping them in the template

    evaluation_pks = [evaluation.pk for evaluation in evaluations]
    degrees = Degree.objects.filter(courses__evaluations__pk__in=evaluation_pks).distinct()
    course_types = CourseType.objects.filter(courses__evaluations__pk__in=evaluation_pks).distinct()
    template_data = dict(
        evaluations=evaluations,
        degrees=degrees,
        course_types=course_types,
        semesters=semesters,
    )
    return render(request, "results_index.html", template_data)
开发者ID:fsr-itse,项目名称:EvaP,代码行数:27,代码来源:views.py

示例4: index

def index(request):
    semesters = Semester.get_all_with_published_courses()
    
    return render_to_response(
        "results_index.html",
        dict(semesters=semesters),
        context_instance=RequestContext(request))
开发者ID:mswart,项目名称:EvaP,代码行数:7,代码来源:views.py

示例5: __init__

 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     courses_of_current_semester = Course.objects.filter(semester=Semester.active_semester())
     excludes = [x.id for x in courses_of_current_semester if x.is_single_result()]
     courses_of_current_semester = courses_of_current_semester.exclude(id__in=excludes)
     self.fields['courses_participating_in'].queryset = courses_of_current_semester
     self.fields['courses_participating_in'].initial = courses_of_current_semester.filter(participants=self.instance) if self.instance.pk else ()
     self.fields['courses_participating_in'].label = _("Courses participating in (active semester)")
     self.fields['courses_participating_in'].required = False
开发者ID:dietzi96,项目名称:EvaP,代码行数:9,代码来源:forms.py

示例6: __init__

 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     courses_in_active_semester = Course.objects.filter(semester=Semester.active_semester())
     excludes = [x.id for x in courses_in_active_semester if x.is_single_result()]
     courses_in_active_semester = courses_in_active_semester.exclude(id__in=excludes)
     self.fields['courses_participating_in'].queryset = courses_in_active_semester
     if self.instance.pk:
         self.fields['courses_participating_in'].initial = courses_in_active_semester.filter(participants=self.instance)
         self.fields['is_staff'].initial = self.instance.is_staff
         self.fields['is_grade_user'].initial = self.instance.is_grade_publisher
开发者ID:anukat2015,项目名称:EvaP,代码行数:10,代码来源:forms.py

示例7: clean_courses_participating_in

    def clean_courses_participating_in(self):
        courses_participating_in = self.cleaned_data.get('courses_participating_in')
        if self.instance.pk:
            courses_voted_for = self.instance.courses_voted_for.filter(semester=Semester.active_semester())
            removed_courses_voted_for = set(courses_voted_for) - set(courses_participating_in)
            if removed_courses_voted_for:
                names = [str(course) for course in removed_courses_voted_for]
                self.add_error("courses_participating_in", _("Courses for which the user already voted can't be removed: %s") % ", ".join(names))

        return courses_participating_in
开发者ID:PFischbeck,项目名称:EvaP,代码行数:10,代码来源:forms.py

示例8: __init__

 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     evaluations_in_active_semester = Evaluation.objects.filter(course__semester=Semester.active_semester())
     excludes = [x.id for x in evaluations_in_active_semester if x.is_single_result]
     evaluations_in_active_semester = evaluations_in_active_semester.exclude(id__in=excludes)
     self.fields['evaluations_participating_in'].queryset = evaluations_in_active_semester
     if self.instance.pk:
         self.fields['evaluations_participating_in'].initial = evaluations_in_active_semester.filter(participants=self.instance)
         self.fields['is_manager'].initial = self.instance.is_manager
         self.fields['is_grade_publisher'].initial = self.instance.is_grade_publisher
         self.fields['is_reviewer'].initial = self.instance.is_reviewer
         self.fields['is_inactive'].initial = not self.instance.is_active
开发者ID:fsr-itse,项目名称:EvaP,代码行数:12,代码来源:forms.py

示例9: user_edit

def user_edit(request, user_id):
    user = get_object_or_404(UserProfile, id=user_id)
    form = UserForm(request.POST or None, request.FILES or None, instance=user)

    courses_contributing_to = Course.objects.filter(semester=Semester.active_semester(), contributions__contributor=user)

    if form.is_valid():
        form.save()
        messages.success(request, _("Successfully updated user."))
        return redirect('staff:user_index')
    else:
        return render(request, "staff_user_form.html", dict(form=form, object=user, courses_contributing_to=courses_contributing_to))
开发者ID:Paul-Geppert,项目名称:EvaP,代码行数:12,代码来源:views.py

示例10: __init__

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        all_users = UserProfile.objects.all()
        # fix generated form
        self.fields['delegates'].required = False
        self.fields['delegates'].queryset = all_users
        self.fields['cc_users'].required = False
        self.fields['cc_users'].queryset = all_users
        courses_of_current_semester = Course.objects.filter(semester=Semester.active_semester())
        self.fields['courses_participating_in'].queryset = courses_of_current_semester
        self.fields['courses_participating_in'].initial = courses_of_current_semester.filter(participants=self.instance) if self.instance.pk else ()
        self.fields['courses_participating_in'].label = _("Courses participating in (active semester)")
        self.fields['courses_participating_in'].required = False
开发者ID:pitwegner,项目名称:EvaP,代码行数:14,代码来源:forms.py

示例11: save

    def save(self, *args, **kw):
        super().save(*args, **kw)
        self.instance.course_set = list(self.instance.course_set.exclude(semester=Semester.active_semester())) + list(self.cleaned_data.get('courses_participating_in'))

        staff_group = Group.objects.get(name="Staff")
        grade_user_group = Group.objects.get(name="Grade publisher")
        if self.cleaned_data.get('is_staff'):
            self.instance.groups.add(staff_group)
        else:
            self.instance.groups.remove(staff_group)

        if self.cleaned_data.get('is_grade_user'):
            self.instance.groups.add(grade_user_group)
        else:
            self.instance.groups.remove(grade_user_group)
开发者ID:schumannd,项目名称:EvaP,代码行数:15,代码来源:forms.py

示例12: __init__

    def __init__(self, *args, **kwargs):
        super(UserForm, self).__init__(*args, **kwargs)

        all_users = UserProfile.objects.order_by('username')
        # fix generated form
        self.fields['delegates'].required = False
        self.fields['delegates'].queryset = all_users
        self.fields['delegates'].help_text = ""
        self.fields['cc_users'].required = False
        self.fields['cc_users'].queryset = all_users
        self.fields['cc_users'].help_text = ""
        courses_of_current_semester = Course.objects.filter(semester=Semester.active_semester())
        self.fields['courses_participating_in'] = forms.ModelMultipleChoiceField(courses_of_current_semester,
                                                                          initial=courses_of_current_semester.filter(participants=self.instance) if self.instance.pk else (),
                                                                          label=_("Courses participating in (active semester)"),
                                                                          help_text="",
                                                                          required=False)
        self.fields['courses_participating_in'].help_text = ""
开发者ID:janno42,项目名称:EvaP,代码行数:18,代码来源:forms.py

示例13: save

 def save(self, *args, **kw):
     super().save(*args, **kw)
     self.instance.course_set = list(self.instance.course_set.exclude(semester=Semester.active_semester())) + list(self.cleaned_data.get('courses_participating_in'))
开发者ID:pitwegner,项目名称:EvaP,代码行数:3,代码来源:forms.py

示例14: save

    def save(self, *args, **kw):
        super().save(*args, **kw)
        new_course_list = list(self.instance.courses_participating_in.exclude(semester=Semester.active_semester())) + list(self.cleaned_data.get('courses_participating_in'))
        self.instance.courses_participating_in.set(new_course_list)

        staff_group = Group.objects.get(name="Staff")
        grade_publisher_group = Group.objects.get(name="Grade publisher")
        reviewer_group = Group.objects.get(name="Reviewer")
        if self.cleaned_data.get('is_staff'):
            self.instance.groups.add(staff_group)
        else:
            self.instance.groups.remove(staff_group)

        if self.cleaned_data.get('is_grade_publisher'):
            self.instance.groups.add(grade_publisher_group)
        else:
            self.instance.groups.remove(grade_publisher_group)

        if self.cleaned_data.get('is_reviewer') and not self.cleaned_data.get('is_staff'):
            self.instance.groups.add(reviewer_group)
        else:
            self.instance.groups.remove(reviewer_group)

        self.instance.is_active = not self.cleaned_data.get('is_inactive')

        self.instance.save()
开发者ID:JenniferStamm,项目名称:EvaP,代码行数:26,代码来源:forms.py

示例15: clean_evaluations_participating_in

    def clean_evaluations_participating_in(self):
        evaluations_participating_in = self.cleaned_data.get('evaluations_participating_in')
        if self.instance.pk:
            evaluations_voted_for = self.instance.evaluations_voted_for.filter(course__semester=Semester.active_semester())
            removed_evaluations_voted_for = set(evaluations_voted_for) - set(evaluations_participating_in)
            if removed_evaluations_voted_for:
                names = [str(evaluation) for evaluation in removed_evaluations_voted_for]
                self.add_error("evaluations_participating_in", _("Evaluations for which the user already voted can't be removed: %s") % ", ".join(names))

        return evaluations_participating_in
开发者ID:fsr-itse,项目名称:EvaP,代码行数:10,代码来源:forms.py


注:本文中的evap.evaluation.models.Semester类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。