Changeset View
Changeset View
Standalone View
Standalone View
pykolab/xml/attendee.py
Show All 19 Lines | participant_status_labels = { | ||||
kolabformat.PartDeclined: N_("Declined"), | kolabformat.PartDeclined: N_("Declined"), | ||||
kolabformat.PartTentative: N_("Tentatively Accepted"), | kolabformat.PartTentative: N_("Tentatively Accepted"), | ||||
kolabformat.PartDelegated: N_("Delegated"), | kolabformat.PartDelegated: N_("Delegated"), | ||||
kolabformat.PartInProcess: N_("Started"), | kolabformat.PartInProcess: N_("Started"), | ||||
kolabformat.PartCompleted: N_("Completed"), | kolabformat.PartCompleted: N_("Completed"), | ||||
} | } | ||||
def participant_status_label(status): | def participant_status_label(status): | ||||
return _(participant_status_labels[status]) if participant_status_labels.has_key(status) else _(status) | return _(participant_status_labels[status]) if status in participant_status_labels else _(status) | ||||
class Attendee(kolabformat.Attendee): | class Attendee(kolabformat.Attendee): | ||||
cutype_map = { | cutype_map = { | ||||
"INDIVIDUAL": kolabformat.CutypeIndividual, | "INDIVIDUAL": kolabformat.CutypeIndividual, | ||||
"RESOURCE": kolabformat.CutypeResource, | "RESOURCE": kolabformat.CutypeResource, | ||||
"GROUP": kolabformat.CutypeGroup, | "GROUP": kolabformat.CutypeGroup, | ||||
"ROOM": kolabformat.CutypeRoom, | "ROOM": kolabformat.CutypeRoom, | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | def __init__( | ||||
if not name == None: | if not name == None: | ||||
self.contactreference.set_name(name) | self.contactreference.set_name(name) | ||||
kolabformat.Attendee.__init__(self, self.contactreference) | kolabformat.Attendee.__init__(self, self.contactreference) | ||||
if isinstance(rsvp, bool): | if isinstance(rsvp, bool): | ||||
self.setRSVP(rsvp) | self.setRSVP(rsvp) | ||||
else: | else: | ||||
if self.rsvp_map.has_key(rsvp): | if rsvp in self.rsvp_map: | ||||
self.setRSVP(self.rsvp_map[rsvp]) | self.setRSVP(self.rsvp_map[rsvp]) | ||||
if not role == None: | if not role == None: | ||||
self.set_role(role) | self.set_role(role) | ||||
if not cutype == None: | if not cutype == None: | ||||
self.set_cutype(cutype) | self.set_cutype(cutype) | ||||
if ical_params and ical_params.has_key('DELEGATED-FROM'): | if ical_params and 'DELEGATED-FROM' in ical_params: | ||||
self.delegate_from(Attendee(str(ical_params['DELEGATED-FROM']), role=self.get_role(), cutype=self.get_cutype())) | self.delegate_from(Attendee(str(ical_params['DELEGATED-FROM']), role=self.get_role(), cutype=self.get_cutype())) | ||||
if ical_params and ical_params.has_key('DELEGATED-TO'): | if ical_params and 'DELEGATED-TO' in ical_params: | ||||
self.delegate_to(Attendee(str(ical_params['DELEGATED-TO']))) | self.delegate_to(Attendee(str(ical_params['DELEGATED-TO']))) | ||||
if not participant_status == None: | if not participant_status == None: | ||||
self.set_participant_status(participant_status) | self.set_participant_status(participant_status) | ||||
def copy_from(self, obj): | def copy_from(self, obj): | ||||
if isinstance(obj, kolabformat.Attendee): | if isinstance(obj, kolabformat.Attendee): | ||||
self.contactreference = ContactReference(obj.contact()) | self.contactreference = ContactReference(obj.contact()) | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | def get_role(self, translated=False): | ||||
return self._translate_value(role, self.role_map) | return self._translate_value(role, self.role_map) | ||||
return role | return role | ||||
def get_rsvp(self): | def get_rsvp(self): | ||||
return self.rsvp() | return self.rsvp() | ||||
def _translate_value(self, val, map): | def _translate_value(self, val, map): | ||||
name_map = dict([(v, k) for (k, v) in map.iteritems()]) | name_map = dict([(v, k) for (k, v) in map.iteritems()]) | ||||
return name_map[val] if name_map.has_key(val) else 'UNKNOWN' | return name_map[val] if val in name_map else 'UNKNOWN' | ||||
def set_cutype(self, cutype): | def set_cutype(self, cutype): | ||||
if cutype in self.cutype_map: | if cutype in self.cutype_map: | ||||
self.setCutype(self.cutype_map[cutype]) | self.setCutype(self.cutype_map[cutype]) | ||||
elif cutype in self.cutype_map.values(): | elif cutype in self.cutype_map.values(): | ||||
self.setCutype(cutype) | self.setCutype(cutype) | ||||
else: | else: | ||||
raise InvalidAttendeeCutypeError(_("Invalid cutype %r") % (cutype)) | raise InvalidAttendeeCutypeError(_("Invalid cutype %r") % (cutype)) | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |