Beispiel #1
0
    def handle_unis(self, course: Course, unis: List[str]) -> None:
        """
        Add a list of UNI users to a course
        """
        site = get_current_site(self.request)
        for uni in unis:
            user = self.get_or_create_user(uni)
            display_name = user_display_name(user)
            if course.is_true_member(user):
                msg = '{} ({}) is already a course member'.format(
                    display_name, uni)
                messages.add_message(self.request, messages.WARNING, msg)
            else:
                email = '{}@columbia.edu'.format(uni)
                course.group.user_set.add(user)
                subj = 'Locus Tempus Invitation: {}'.format(course.title)
                send_template_email(
                    subj,
                    self.email_template,
                    {'course_title': course.title, 'site': site},
                    email
                )
                msg = (
                    '{} is now a workspace member. An email notification '
                    'was sent to {}.').format(display_name, email)

                messages.add_message(self.request, messages.SUCCESS, msg)
Beispiel #2
0
    def post(self, request: HttpRequest, *args, **kwargs) -> HttpResponse:
        user = get_object_or_404(
            User, id=request.POST.get('user_id', None))
        course = get_object_or_404(Course, id=kwargs.get('pk', None))

        if course.is_true_faculty(user):
            msg = u'{} is already Author in this workspace.'.format(
                user_display_name(user))
        elif course.is_member(user):
            course.faculty_group.user_set.add(user)
            msg = u'{} is now Author.'.format(user_display_name(user))
        else:
            msg = u'{} is not a member of this workspace.'.format(
                user_display_name(user))

        messages.add_message(request, messages.INFO, msg)
        return HttpResponseRedirect(
            reverse('course-roster-view', args=[course.pk]))