Beispiel #1
0
 def deletePassword(self, password_id):
     """
     Delete a password (and all password history).
     
     :param password_id: The numeric ID of password.
     :type password_id: int
     :return: The deleted password object.
     :rtype: dict
     """
     pw = passwords.delete(password_id)
     auditlog.log(auditlog.CODE_CONTENT_DEL, target=pw)
     return pw.to_dict(decrypt=False)
Beispiel #2
0
 def delete(self, group_id):
     """
     Deletes a group.
     """
     group = groups.get(group_id)
     
     all_resources = group.resources.all()
     
     # This is very lazy (could be done in SQL), but simple/easy-to-debug.
     resources_only_in_this_group = []
     resources_in_other_groups_too = [] 
     for r in all_resources:
         if r.groups.all() == [group]:
             resources_only_in_this_group.append(r)
         else:
             resources_in_other_groups_too.append(r)
     
     if cherrypy.request.method == 'POST':
    
         # First remove any resources that are only owned by this group. 
         for r in resources_only_in_this_group:
             # Remove any passwords in this resource
             for pw in r.passwords:
                 del_pw = passwords.delete(pw.id)
                 auditlog.log(auditlog.CODE_CONTENT_DEL, target=del_pw)
             del_r = resources.delete(r.id)
             auditlog.log(auditlog.CODE_CONTENT_DEL, target=del_r)
         
         # Next we manually remove the group from any other resources that were associated
         # with this group.
         for r in resources_in_other_groups_too:
             group_ids = set([g.id for g in r.groups.all()])
             group_ids.remove(group.id)
             (mod_r, modified) = resources.modify(r.id, group_ids=group_ids)
             if modified:
                 auditlog.log(auditlog.CODE_CONTENT_MOD, target=mod_r, attributes_modified=modified)
         
         # And finally we can delete the group itself.
         group = groups.delete(group.id)
         auditlog.log(auditlog.CODE_CONTENT_DEL, target=group)
         
         notify_entity_activity(group, 'deleted')
         raise cherrypy.HTTPRedirect('/group/list')
     else:
         return render('group/delete.html', {'group_id': group_id,
                                             'del_resources': resources_only_in_this_group,
                                             'mod_resources': resources_in_other_groups_too})
Beispiel #3
0
 def delete(self, resource_id, redirect_to=None):
     resource = resources.get(resource_id)
     if cherrypy.request.method == 'POST':
         
         # First remove any passwords for this resource.
         for pw in resource.passwords:
             del_pw = passwords.delete(pw.id)
             auditlog.log(auditlog.CODE_CONTENT_DEL, target=del_pw)
     
         # Then remove the actual resource
         resource = resources.delete(resource_id)
         auditlog.log(auditlog.CODE_CONTENT_DEL, target=resource)
         notify_entity_activity(resource, 'deleted')
         if redirect_to:
             raise cherrypy.HTTPRedirect(redirect_to)
         else:
             raise cherrypy.HTTPRedirect('/resource/list')
     else:
         return render('resource/delete.html', {'resource': resource,
                                                'redirect_to': redirect_to})
Beispiel #4
0
 def delete(self, password_id):
     pw = passwords.delete(password_id)
     auditlog.log(auditlog.CODE_CONTENT_DEL, target=pw)
     notify_entity_activity(pw, 'deleted')
     raise cherrypy.HTTPRedirect('/resource/view/%d' % int(pw.resource_id))