def delete_bugzilla_user(db, user_id, alt_id): """ For given user_id delete BzUser and his comments, attachments, ccs from the database. And replace 'user_id' in related bugzillas and bugzilla history with 'alt_id'. """ bzcomments = queries.get_bzcomments_by_uid(db, user_id) for bzcomm in bzcomments.all(): if bzcomm.has_lob("content"): bzcomm.del_lob("content") bzcomments.delete(False) bzattachments = queries.get_bzattachments_by_uid(db, user_id) for attach in bzattachments.all(): if attach.has_lob("content"): attach.del_lob("content") bzattachments.delete(False) queries.get_bzbugccs_by_uid(db, user_id).delete(False) bzbughistory = queries.get_bzbughistory_by_uid(db, user_id).all() for hist in bzbughistory: hist.user_id = alt_id bz_bugs = queries.get_bugzillas_by_uid(db, user_id).all() for bug in bz_bugs: bug.creator_id = alt_id
def delete_bugzilla_user(db, user_id, alt_id): """ For given user_id delete BzUser and his comments, attachments, ccs from the database. And replace 'user_id' in related bugzillas and bugzilla history with 'alt_id'. """ bzcomments = queries.get_bzcomments_by_uid(db, user_id) for bzcomm in bzcomments.all(): if bzcomm.has_lob("content"): bzcomm.del_lob("content") bzcomments.delete(False) bzattachments = queries.get_bzattachments_by_uid(db, user_id) for attach in bzattachments.all(): if attach.has_lob("content"): attach.del_lob("content") bzattachments.delete(False) queries.get_bzbugccs_by_uid(db, user_id).delete(False) bzbughistory = queries.get_bzbughistory_by_uid(db, user_id).all() for hist in bzbughistory: hist.user_id = alt_id bz_bugs = queries.get_bugzillas_by_uid(db, user_id).all() for bug in bz_bugs: bug.creator_id = alt_id
def bugzillas(self): bz_user = queries.get_bz_user(self.db, self.mail) if not bz_user: return {} user_bugzillas = queries.get_bugzillas_by_uid(self.db, bz_user.id) bz_data = { "Mail": bz_user.email, "Name": bz_user.name, "Real Name": bz_user.real_name } bz_data["Created Bugzillas"] = [{ "Bug ID": bz.id, "Summary": bz.summary, "Status": bz.status, "Resolution": bz.resolution, "Creation Date": str(bz.creation_time) } for bz in user_bugzillas] attachments = queries.get_bzattachments_by_uid(self.db, bz_user.id).all() ccs = queries.get_bzbugccs_by_uid(self.db, bz_user.id).all() comments = queries.get_bzcomments_by_uid(self.db, bz_user.id).all() history = queries.get_bzbughistory_by_uid(self.db, bz_user.id).all() bz_data["Attachments"] = [{ "Bug ID": a.bug_id, "Description": a.description, "Creation Date": str(a.creation_time), "Filename": a.filename } for a in attachments] bz_data["CCs"] = [cc.bug_id for cc in ccs] bz_data["Comments"] = [{ "Bug ID": c.bug_id, "Comment #": c.number, "Creation Date": str(c.creation_time) } for c in comments] bz_data["History"] = [{ "Bug ID": h.bug_id, "Time": str(h.time), "Field": h.field, "Added": h.added, "Removed": h.removed } for h in history] return bz_data
def bugzillas(self): bz_user = queries.get_bz_user(self.db, self.mail) if not bz_user: return {} user_bugzillas = queries.get_bugzillas_by_uid(self.db, bz_user.id) bz_data = {"Mail": bz_user.email, "Name": bz_user.name, "Real Name": bz_user.real_name} bz_data["Created Bugzillas"] = [{"Bug ID": bz.id, "Summary": bz.summary, "Status": bz.status, "Resolution": bz.resolution, "Creation Date": str(bz.creation_time)} for bz in user_bugzillas] attachments = queries.get_bzattachments_by_uid(self.db, bz_user.id).all() ccs = queries.get_bzbugccs_by_uid(self.db, bz_user.id).all() comments = queries.get_bzcomments_by_uid(self.db, bz_user.id).all() history = queries.get_bzbughistory_by_uid(self.db, bz_user.id).all() bz_data["Attachments"] = [{"Bug ID": a.bug_id, "Description": a.description, "Creation Date": str(a.creation_time), "Filename": a.filename} for a in attachments] bz_data["CCs"] = [cc.bug_id for cc in ccs] bz_data["Comments"] = [{"Bug ID": c.bug_id, "Comment #": c.number, "Creation Date": str(c.creation_time)} for c in comments] bz_data["History"] = [{"Bug ID": h.bug_id, "Time": str(h.time), "Field": h.field, "Added": h.added, "Removed": h.removed} for h in history] return bz_data