Example #1
0
File: note.py Project: MrPetru/spam
 def get_delete(self, proj, note_id, **kwargs):
     """Display a DELETE confirmation form."""
     project = tmpl_context.project
     note = note_get(note_id)
     f_confirm.custom_method = 'DELETE'
     f_confirm.value = dict(proj=project.id,
                            note_id=note.id,
                            text_=note.text)
     tmpl_context.form = f_confirm
     return dict(title='%s %s?' % (
                     _('Are you sure you want to delete note:'), note.id))
Example #2
0
File: note.py Project: MrPetru/spam
    def post_delete(self, proj, note_id):
        """Delete a note."""
        session = session_get()
        note = note_get(note_id)
        ob = note.annotated
        
        session.delete(note)
        session.refresh(ob.annotable)
        
        msg = '%s %s' % (_('Deleted note:'), note.id)

        updates = [dict(item=note, type='deleted', topic=TOPIC_NOTES,
                                                        filter=ob.annotable.id)]
        if isinstance(ob, AssetVersion):
            updates.append(dict(item=ob.asset, topic=TOPIC_ASSETS))
        else:
            updates.append(dict(item=ob, topic=TOPICS[ob.__class__]))
        notify.send(updates)

        return dict(msg=msg, status='ok', updates=updates)
Example #3
0
File: note.py Project: MrPetru/spam
    def unpin(self, proj, note_id):
        """Un-pin a note."""
        session = session_get()
        note = note_get(note_id)
        ob = note.annotated

        if not note.sticky:
            msg = '%s %s' % (_('Note is not pinned:'), note.id)
            return dict(msg=msg, status='info', updates=[])

        note.sticky = False
        session.refresh(ob.annotable)

        msg = '%s %s' % (_('Un-pinned note:'), note.id)

        updates = [
            dict(item=note, topic=TOPIC_NOTES, filter=ob.annotable.id),
            dict(item=ob, topic=TOPICS[ob.__class__]),
            ]
        notify.send(updates)

        return dict(msg=msg, status='ok', updates=updates)
Example #4
0
File: note.py Project: MrPetru/spam
 def get_one(self, proj, annotable_id, note_id):
     """This method is currently unused, but is needed for the 
     RESTController to work."""
     note = note_get(note_id)
     return dict(note=note)