Beispiel #1
0
    def test_attendee(self):
        a = Attendee(email='*****@*****.**')
        line = str(a)
        self.assertIn("ATTENDEE;[email protected]", line)

        a2 = Attendee(email='*****@*****.**', common_name='Email')
        line = str(a2)
        self.assertIn("ATTENDEE;CN=Email:mailto:[email protected]", line)

        with self.assertRaises(ValueError):
            Attendee(email=None)

        with self.assertRaises(ValueError):
            Attendee(email="*****@*****.**", common_name=5)

        with self.assertRaises(ValueError):
            Attendee(email="*****@*****.**", rsvp="lol")

        b = Attendee(email="*****@*****.**", rsvp="TRUE")
        self.assertTrue(b.rsvp)

        b.rsvp = True
        self.assertTrue(b.rsvp)

        b.rsvp = "FALSE"
        self.assertFalse(b.rsvp)

        b.rsvp = False
        self.assertFalse(b.rsvp)
Beispiel #2
0
    def test_attendee(self):
        a = Attendee(email='*****@*****.**')
        line = str(a)
        self.assertIn("ATTENDEE;CN='*****@*****.**", line)

        a2 = Attendee(email='*****@*****.**', common_name='Email')
        line = str(a2)
        self.assertIn("ATTENDEE;CN='Email':mailto:[email protected]", line)
Beispiel #3
0
    def test_event_attendee(self):
        attendee_a = Attendee(email="*****@*****.**", common_name="Test", rsvp="TRUE")
        attendee_b = Attendee(email="*****@*****.**")
        event_a = Event(name="Test #1", attendees={attendee_a, attendee_b})

        text = str(event_a)

        self.assertIn("ATTENDEE;CN=Test;RSVP=TRUE:mailto:[email protected]", text)
        self.assertIn("ATTENDEE;[email protected]:mailto:[email protected]", text)
Beispiel #4
0
 def test_add_attendees(self):
     e = Event()
     a = Attendee(email='*****@*****.**')
     e.add_attendee(a)
     lines = str(e).splitlines()
     self.assertIn("ATTENDEE;[email protected]:mailto:[email protected]",
                   lines)
Beispiel #5
0
def add_attendees(attendees, event):
    '''Add Attendees to event'''
    if attendees:
        for attendee in attendees:
            response_status = True if attendee.get(
                'responseStatus') == 'accepted' else False
            event.add_attendee(Attendee(attendee.get('email'),
                                        response_status))
Beispiel #6
0
    def test_attendee(self):
        a = Attendee(email='*****@*****.**')
        line = str(a)
        self.assertIn("ATTENDEE;[email protected]:mailto:[email protected]",
                      line)

        a2 = Attendee(email='*****@*****.**', common_name='Email')
        line = str(a2)
        self.assertIn("ATTENDEE;CN=Email:mailto:[email protected]", line)

        a3 = Attendee(
            email="*****@*****.**",
            common_name="Email",
            partstat="ACCEPTED",
            role="CHAIR",
        )
        line = str(a3)
        self.assertIn(
            "ATTENDEE;CN=Email;PARTSTAT=ACCEPTED;ROLE=CHAIR:mailto:[email protected]",
            line,
        )
Beispiel #7
0
def i_cal_feed(request, token):
    try:
        token = ICalToken.objects.get(pk=token)
        try:
            student = Student.objects.get(id=token.user.id)
            occupancy_list = Occupancy.objects.filter(
                subject___class=student._class)
        except Student.DoesNotExist:
            try:
                teacher = Teacher.objects.get(id=token.user.id)
                occupancy_list = Occupancy.objects.filter(teacher=teacher)
            except Teacher.DoesNotExist:
                return HttpResponse('Invalid token', status=403)
        calendar = Calendar()
        for occ in occupancy_list:
            occ_mod_created = OccupancyModification.objects.get(
                occupancy=occ, modification_type='INSERT')
            organizer = Organizer(
                common_name=f'{occ.teacher.first_name} {occ.teacher.last_name}',
                email=occ.teacher.email,
            )
            if occ.group_number:
                attendee_name = f'{occ.subject.name} - Groupe {occ.group_number}'
            else:
                attendee_name = f'{occ.subject._class.name}'
            attendees = [Attendee(
                common_name=attendee_name,
                email='',
            )]
            e = Event(
                name=occ.name,
                begin=occ.start_datetime,
                duration=occ.duration,
                created=occ_mod_created.modification_date,
                location=occ.classroom.name,
                organizer=organizer,
                attendees=attendees,
            )
            occ_last_modification = OccupancyModification.objects.filter(
                occupancy=occ,
                modification_type='EDIT').order_by('-modification_date')
            if len(occ_last_modification) > 0:
                e.last_modified = occ_last_modification[0].modification_date
            calendar.events.add(e)
        response = HttpResponse(str(calendar), content_type='text/calendar')
        response['Content-Disposition'] = 'attachment; filename="calendar.ics"'
        return response
    except ICalToken.DoesNotExist:
        return HttpResponse('Token does not exist', status=403)
 def parse_attendee(alarm, lines):
     for line in lines:
         alarm.recipients.append(Attendee.parse(line))
Beispiel #9
0
 def parse_attendee(alarm: "EmailAlarm", lines: List[ContentLine]):
     for line in lines:
         alarm.recipients.append(Attendee.parse(line))
Beispiel #10
0
 def serialize_attendee(event: "Event", container: "Container"):
     for attendee in event.attendees:
         if isinstance(attendee, str):
             attendee = Attendee(attendee)
         container.append(attendee.serialize())
Beispiel #11
0
 def parse_attendee(event: "Event", lines: List[ContentLine]):
     for line in lines:
         event.attendees.append(Attendee.parse(line))