Example #1
0
    def create_meeting(self,
                       title,
                       time=None,
                       location=None,
                       description=None):
        """See :http:post:`/api/meetings`."""
        if not self.user:
            raise PermissionError()

        e = InputError()
        if not str_or_none(title):
            e.errors['title'] = 'empty'
        e.trigger()

        meeting = Meeting(id='Meeting:' + randstr(),
                          trashed=False,
                          app=self,
                          authors=[self.user.id],
                          title=title,
                          time=time.isoformat() + 'Z' if time else None,
                          location=str_or_none(location),
                          description=str_or_none(description))
        self.r.oset(meeting.id, meeting)
        self.r.rpush('meetings', meeting.id)

        self.activity.publish(
            Event.create('create-meeting',
                         None, {'meeting': meeting},
                         app=self))
        return meeting
Example #2
0
    def do_edit(self, **attrs):
        e = InputError()
        if 'title' in attrs and not str_or_none(attrs['title']):
            e.errors['title'] = 'empty'
        e.trigger()

        if 'title' in attrs:
            self.title = attrs['title']
        if 'time' in attrs:
            self.time = attrs['time']
        if 'location' in attrs:
            self.location = str_or_none(attrs['location'])
        if 'description' in attrs:
            self.description = str_or_none(attrs['description'])
Example #3
0
    def do_edit(self, **attrs):
        e = InputError()
        if 'title' in attrs and str_or_none(attrs['title']) is None:
            e.errors['title'] = 'empty'
        if attrs.get('duration') is not None and attrs['duration'] <= 0:
            e.errors['duration'] = 'not_positive'
        e.trigger()

        if 'title' in attrs:
            self.title = attrs['title']
        if 'duration' in attrs:
            self.duration = attrs['duration']
        if 'description' in attrs:
            self.description = str_or_none(attrs['description'])
Example #4
0
    def do_edit(self, **attrs):
        e = InputError()
        if 'title' in attrs and not str_or_none(attrs['title']):
            e.errors['title'] = 'empty'
        e.trigger()

        if 'title' in attrs:
            self.title = attrs['title']
        if 'time' in attrs:
            self.time = attrs['time']
        if 'location' in attrs:
            self.location = str_or_none(attrs['location'])
        if 'description' in attrs:
            self.description = str_or_none(attrs['description'])
Example #5
0
    def create_meeting(self, title, time=None, location=None, description=None):
        """See :http:post:`/api/meetings`."""
        if not self.user:
            raise PermissionError()

        e = InputError()
        if not str_or_none(title):
            e.errors['title'] = 'empty'
        e.trigger()

        meeting = Meeting(
            id='Meeting:' + randstr(), trashed=False, app=self, authors=[self.user.id], title=title,
            time=time, location=str_or_none(location), description=str_or_none(description))
        self.r.oset(meeting.id, meeting)
        self.r.rpush('meetings', meeting.id)
        return meeting
Example #6
0
    def create_agenda_item(self, title, duration=None, description=None):
        """See :http:post:`/api/meetings/(id)/items`."""
        if not self.app.user:
            raise PermissionError()

        e = InputError()
        if str_or_none(title) is None:
            e.errors['title'] = 'empty'
        if duration is not None and duration <= 0:
            e.errors['duration'] = 'not_positive'
        description = str_or_none(description)
        e.trigger()

        item = AgendaItem(
            id='AgendaItem:' + randstr(), trashed=False, app=self.app, authors=[self.app.user.id],
            title=title, duration=duration, description=description)
        self.app.r.oset(item.id, item)
        self.app.r.rpush(self._items_key, item.id)
        return item
Example #7
0
    def do_edit(self, **attrs):
        e = InputError()
        if 'title' in attrs and str_or_none(attrs['title']) is None:
            e.errors['title'] = 'empty'
        if attrs.get('duration') is not None and attrs['duration'] <= 0:
            e.errors['duration'] = 'not_positive'
        e.trigger()

        if 'title' in attrs:
            self.title = attrs['title']
        if 'duration' in attrs:
            self.duration = attrs['duration']
        if 'description' in attrs:
            self.description = str_or_none(attrs['description'])
Example #8
0
    def create_agenda_item(self, title, duration=None, description=None):
        """See :http:post:`/api/meetings/(id)/items`."""
        if not self.app.user:
            raise PermissionError()

        e = InputError()
        if str_or_none(title) is None:
            e.errors['title'] = 'empty'
        if duration is not None and duration <= 0:
            e.errors['duration'] = 'not_positive'
        description = str_or_none(description)
        e.trigger()

        item = AgendaItem(id='AgendaItem:' + randstr(),
                          trashed=False,
                          app=self.app,
                          authors=[self.app.user.id],
                          title=title,
                          duration=duration,
                          description=description)
        self.app.r.oset(item.id, item)
        self.app.r.rpush(self._items_key, item.id)
        return item