old_contents: # -*- coding: utf-8 -*-
  ##
  ##
  ## This file is part of Indico.
  ## Copyright (C) 2002 - 2013 European Organization for Nuclear Research (CERN).
  ##
  ## Indico is free software; you can redistribute it and/or
  ## modify it under the terms of the GNU General Public License as
  ## published by the Free Software Foundation; either version 3 of the
  ## License, or (at your option) any later version.
  ##
  ## Indico is distributed in the hope that it will be useful, but
  ## WITHOUT ANY WARRANTY; without even the implied warranty of
  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  ## General Public License for more details.
  ##
  ## You should have received a copy of the GNU General Public License
  ## along with Indico;if not, see <http://www.gnu.org/licenses/>.
  
  from indico.util.date_time import get_datetime_from_request
  from indico.util.i18n import _
  from indico.modules.rb.models.holidays import Holiday
  from indico.modules.rb.models.utils import is_weekend
  from MaKaC.services.implementation.base import ServiceBase
  
  
  class GetDateWarning(ServiceBase):
      def _checkParams(self):
          self._start_dt = get_datetime_from_request(prefix='start_', source=self._params)
          self._end_dt = get_datetime_from_request(prefix='end_', source=self._params)
  
      def _getAnswer(self):
          if not self._start_dt or not self._end_dt:
              return None
          if Holiday.find(Holiday.date.in_([self._start_dt, self._end_dt])).count():
              return _('Holidays chosen')
          if is_weekend(self._start_dt) or is_weekend(self._end_dt):
              return _('Weekend chosen')
          return None
  
new_contents: # -*- coding: utf-8 -*-
  ##
  ##
  ## This file is part of Indico.
  ## Copyright (C) 2002 - 2013 European Organization for Nuclear Research (CERN).
  ##
  ## Indico is free software; you can redistribute it and/or
  ## modify it under the terms of the GNU General Public License as
  ## published by the Free Software Foundation; either version 3 of the
  ## License, or (at your option) any later version.
  ##
  ## Indico is distributed in the hope that it will be useful, but
  ## WITHOUT ANY WARRANTY; without even the implied warranty of
  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  ## General Public License for more details.
  ##
  ## You should have received a copy of the GNU General Public License
  ## along with Indico;if not, see <http://www.gnu.org/licenses/>.
  
  from indico.util.date_time import get_datetime_from_request
  from indico.util.i18n import _
  from indico.modules.rb.models.holidays import Holiday
  from indico.modules.rb.models.utils import is_weekend
  from MaKaC.services.implementation.base import ServiceBase
  
  
  class GetDateWarning(ServiceBase):
      def _checkParams(self):
          self._start_dt = get_datetime_from_request(prefix='start_', source=self._params)
          self._end_dt = get_datetime_from_request(prefix='end_', source=self._params)
  
      def _getAnswer(self):
          if not self._start_dt or not self._end_dt:
              return None
          start_date = self._start_dt.date()
          end_date = self._end_dt.date()
          holidays = Holiday.find_all(Holiday.date.in_([start_date, end_date]))
          if holidays:
              return _(u'Holidays chosen: {0}'.format(', '.join(h.name for h in holidays)))
          if is_weekend(start_date) or is_weekend(end_date):
              return _(u'Weekend chosen')
          return None
  
subject: Fix holiday check, show holiday name