Blame action/sslcert.py

9e1462
9e1462
9e1462
import exception
9e1462
from action.action import Action
9e1462
from action.user import UserBase
9e1462
9e1462
9e1462
class SslcertCreate(UserBase):
9e1462
  def process(self, request):
9e1462
    user_id = self.parse_user_id(request)
9e1462
    data = request.model.sslcerts.extract_data( str(request.postvars.get('data', '')) )
9e1462
9e1462
    user = request.model.users.get_by_id(user_id)
9e1462
    if not user:
9e1462
      raise exception.ActionError( request.t('User not found') )
9e1462
9e1462
    sslcert = None
9e1462
    try:
9e1462
      sslcert = request.model.sslcerts.create(user, data)
9e1462
    except Exception as e:
9e1462
      self.propagate_exception(e)
9e1462
9e1462
    request.connection.commit()
9e1462
    return self.redirect_to_user(request, user, ['edit'])
9e1462
9e1462
9e1462
class SslcertDelete(UserBase):
9e1462
  def process(self, request):
9e1462
    sslcert_id = 0
9e1462
    try:
9e1462
      sslcert_id = int(request.postvars.get('sslcert_id', 0))
9e1462
    except Exception:
9e1462
      raise exception.ActionError( request.t('SSL Certificate Id incorrect') )
9e1462
    if not sslcert_id:
9e1462
      raise exception.ActionError( request.t('SSL Certificate Id incorrect') )
9e1462
9e1462
    sslcert = request.model.sslcerts.get_by_id(sslcert_id)
9e1462
    if not sslcert:
9e1462
      raise exception.ActionError( request.t('SSL Certificate not found') )
9e1462
    user = sslcert.get_user()
9e1462
9e1462
    try:
9e1462
      sslcert.delete()
9e1462
    except Exception as e:
9e1462
      self.propagate_exception(e)
9e1462
9e1462
    request.connection.commit()
9e1462
    return self.redirect_to_user(request, user, ['edit'])
9e1462
9e1462
9e1462
actions = {
9e1462
  'create' : SslcertCreate(),
9e1462
  'delete' : SslcertDelete(),
9e1462
}