Delete a hostname.
(user,
data,
db,
messages)
| 164 | @require(db = 'ddserver.db:Database', |
| 165 | messages = 'ddserver.interface.message:MessageManager') |
| 166 | def post_hosts_delete(user, |
| 167 | data, |
| 168 | db, |
| 169 | messages): |
| 170 | ''' Delete a hostname. ''' |
| 171 | |
| 172 | # We do not check the host id for existence and belonging as we only delete |
| 173 | # host of the user |
| 174 | |
| 175 | with db.cursor() as cur: |
| 176 | cur.execute(''' |
| 177 | DELETE |
| 178 | FROM hosts |
| 179 | WHERE id = %(host_id)s |
| 180 | AND user_id = %(user_id)s |
| 181 | ''', {'host_id': data.host_id, |
| 182 | 'user_id': user.id}) |
| 183 | |
| 184 | messages.success('Ok, done.') |
| 185 | |
| 186 | bottle.redirect('/user/hosts/list') |