Beispiel #1
0
class RegistrationState(TitledIntEnum):
    __titles__ = [None, L_('Completed'), L_('Pending'), L_('Rejected'), L_('Withdrawn'), L_('Awaiting payment')]
    complete = 1
    pending = 2
    rejected = 3
    withdrawn = 4
    unpaid = 5
Beispiel #2
0
class CheckboxField(RegistrationFormBillableField):
    name = 'checkbox'
    wtf_field_class = wtforms.BooleanField
    friendly_data_mapping = {None: '', True: L_('Yes'), False: L_('No')}

    def calculate_price(self, reg_data, versioned_data):
        if not versioned_data.get('is_billable') or not reg_data:
            return 0
        return versioned_data.get('price', 0)

    def get_friendly_data(self,
                          registration_data,
                          for_humans=False,
                          for_search=False):
        return self.friendly_data_mapping[registration_data.data]

    def get_places_used(self):
        places_used = 0
        if self.form_item.data.get('places_limit'):
            for registration in self.form_item.registration_form.active_registrations:
                if self.form_item.id not in registration.data_by_field:
                    continue
                if registration.data_by_field[self.form_item.id].data:
                    places_used += 1
        return places_used

    @property
    def view_data(self):
        return dict(super(CheckboxField, self).view_data,
                    places_used=self.get_places_used())

    @property
    def filter_choices(self):
        return {
            unicode(val).lower(): caption
            for val, caption in self.friendly_data_mapping.iteritems()
            if val is not None
        }

    @property
    def validators(self):
        def _check_number_of_places(form, field):
            if form.modified_registration:
                old_data = form.modified_registration.data_by_field.get(
                    self.form_item.id)
                if not old_data or not self.has_data_changed(
                        field.data, old_data):
                    return
            if field.data and self.form_item.data.get('places_limit'):
                places_left = self.form_item.data.get(
                    'places_limit') - self.get_places_used()
                if not places_left:
                    raise ValidationError(
                        _('There are no places left for this option.'))

        return [_check_number_of_places]

    @property
    def default_value(self):
        return None
Beispiel #3
0
class RegistrationVisibility(RichIntEnum):
    __titles__ = [
        L_('Do not display to anyone'),
        L_('Display to other participants'),
        L_('Display to everyone')
    ]
    nobody = 0
    participants = 1
    all = 2
Beispiel #4
0
class PublishRegistrationsMode(RichIntEnum):
    __titles__ = [
        L_('Hide all participants'),
        L_('Show only consenting participants'),
        L_('Show all participants')
    ]
    hide_all = 0
    show_with_consent = 1
    show_all = 2
Beispiel #5
0
class BooleanField(RegistrationFormBillableField):
    name = 'bool'
    wtf_field_class = IndicoRadioField
    required_validator = InputRequired
    friendly_data_mapping = {None: '',
                             True: L_('Yes'),
                             False: L_('No')}

    @property
    def wtf_field_kwargs(self):
        return {'choices': [(True, _('Yes')), (False, _('No'))],
                'coerce': lambda x: {'yes': True, 'no': False}.get(x, None)}

    @property
    def filter_choices(self):
        return {unicode(val).lower(): caption for val, caption in self.friendly_data_mapping.iteritems()
                if val is not None}

    @property
    def view_data(self):
        return dict(super(BooleanField, self).view_data, places_used=self.get_places_used())

    @property
    def validators(self):
        def _check_number_of_places(form, field):
            if form.modified_registration:
                old_data = form.modified_registration.data_by_field.get(self.form_item.id)
                if not old_data or not self.has_data_changed(field.data, old_data):
                    return
            if field.data and self.form_item.data.get('places_limit'):
                places_left = self.form_item.data.get('places_limit') - self.get_places_used()
                if field.data and not places_left:
                    raise ValidationError(_('There are no places left for this option.'))
        return [_check_number_of_places]

    @property
    def default_value(self):
        return None

    def get_places_used(self):
        places_used = 0
        if self.form_item.data.get('places_limit'):
            for registration in self.form_item.registration_form.active_registrations:
                if self.form_item.id not in registration.data_by_field:
                    continue
                if registration.data_by_field[self.form_item.id].data:
                    places_used += 1
        return places_used

    def calculate_price(self, reg_data, versioned_data):
        if not versioned_data.get('is_billable'):
            return 0
        return versioned_data.get('price', 0) if reg_data else 0

    def get_friendly_data(self, registration_data, for_humans=False):
        return self.friendly_data_mapping[registration_data.data]
Beispiel #6
0
class ModificationMode(RichIntEnum):
    __titles__ = [
        None,
        L_('Until modification deadline'),
        L_('Until payment'),
        L_('Never')
    ]
    allowed_always = 1
    allowed_until_payment = 2
    not_allowed = 3
Beispiel #7
0
class CheckboxField(RegistrationFormBillableField):
    name = 'checkbox'
    mm_field_class = fields.Boolean
    setup_schema_base_cls = LimitedPlacesBillableFieldDataSchema
    friendly_data_mapping = {None: '',
                             True: L_('Yes'),
                             False: L_('No')}

    def calculate_price(self, reg_data, versioned_data):
        if not reg_data:
            return 0
        return versioned_data.get('price', 0)

    def get_friendly_data(self, registration_data, for_humans=False, for_search=False):
        return self.friendly_data_mapping[registration_data.data]

    def get_places_used(self):
        places_used = 0
        if self.form_item.data.get('places_limit'):
            for registration in self.form_item.registration_form.active_registrations:
                if self.form_item.id not in registration.data_by_field:
                    continue
                if registration.data_by_field[self.form_item.id].data:
                    places_used += 1
        return places_used

    @property
    def view_data(self):
        return dict(super().view_data, places_used=self.get_places_used())

    @property
    def filter_choices(self):
        return {str(val).lower(): caption for val, caption in self.friendly_data_mapping.items()
                if val is not None}

    def get_validators(self, existing_registration):
        def _check_number_of_places(new_data):
            if existing_registration:
                old_data = existing_registration.data_by_field.get(self.form_item.id)
                if not old_data or not self.has_data_changed(new_data, old_data):
                    return True
            if new_data and self.form_item.data.get('places_limit'):
                places_left = self.form_item.data.get('places_limit') - self.get_places_used()
                if not places_left:
                    raise ValidationError(_('There are no places left for this option.'))
        return _check_number_of_places

    @property
    def default_value(self):
        return False
Beispiel #8
0
class InvitationState(RichIntEnum):
    __titles__ = [L_('Pending'), L_('Accepted'), L_('Declined')]
    pending = 0
    accepted = 1
    declined = 2
Beispiel #9
0
class ModificationMode(TitledIntEnum):
    __titles__ = [None, L_('Always'), L_('Until payment'), L_('Never')]
    allowed_always = 1
    allowed_until_payment = 2
    not_allowed = 3
Beispiel #10
0
## 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 MaKaC.plugins.Collaboration.base import CollaborationServiceException,\
    CSErrorBase
from MaKaC.webinterface.common.contribFilters import PosterFilterField
from MaKaC.conference import Contribution
from MaKaC.common.fossilize import fossilizes
from MaKaC.plugins.Collaboration.RecordingRequest.fossils import IRecordingRequestErrorFossil
from MaKaC.plugins.Collaboration.collaborationTools import CollaborationTools

from indico.util.i18n import L_

postingUrgency = [("withinHours", L_("Within hours")),
                  ("withinDay", L_("Within a day")),
                  ("withinWeek", L_("Within a week"))]


def getTalks(conference, oneIsEnough=False, sort=False):
    """ oneIsEnough: the algorithm will stop at the first contribution found
                     it will then return a list with a single element
        sort: if True, contributions are sorted by start date (non scheduled contributions at the end)
    """
    talks = []
    filter = PosterFilterField(conference, False, False)
    for cont in conference.getContributionList():
        if filter.satisfies(cont):
            talks.append(cont)
            if oneIsEnough:
Beispiel #11
0
from MaKaC.plugins.Collaboration.collaborationTools import CollaborationTools
from MaKaC.plugins.Collaboration.base import SpeakerStatusEnum
from MaKaC.plugins.Collaboration.output import OutputGenerator
from MaKaC.webinterface.pages.conferences import WPConferenceDefaultDisplayBase
from MaKaC.webinterface.simple_event import WPSimpleEventDisplay
from MaKaC.webinterface.pages.collaboration import WPConfModifCollaboration
from MaKaC.webinterface.pages.main import WPMainBase
from MaKaC.webinterface import wcomponents, urlHandlers
from MaKaC.plugins import Collaboration
from MaKaC.plugins.Collaboration import urlHandlers as collaborationUrlHandlers

from indico.util.i18n import L_
from indico.util.date_time import format_datetime

STATUS_STRING = {
    SpeakerStatusEnum.NOEMAIL: L_("No Email"),
    SpeakerStatusEnum.NOTSIGNED: L_("Not Signed"),
    SpeakerStatusEnum.SIGNED: L_("Signed"),
    SpeakerStatusEnum.FROMFILE: L_("Uploaded"),
    SpeakerStatusEnum.PENDING: L_("Pending..."),
    SpeakerStatusEnum.REFUSED: L_("Refused")
}


class IMEventDisplayComponent(Component):

    zope.interface.implements(IEventDisplayContributor)

    # EventDisplayContributor

    def injectCSSFiles(self, obj):
Beispiel #12
0
class NewsModule(Module):
    """
    This module holds all the information needed to keep the news in Indico.
    That means all the news items and other related information.

    _newsTypes is a tuple with 2 values: id, label. Keep the order as it will
    appear in the display interface.
    """

    id = "news"
    _newsTypes = [("general", L_("General News")),
                  ("future", L_("Coming soon")), ("new", L_("New features")),
                  ("bug", L_("Bug fixes"))]

    def __init__(self):
        self._newsItems = []
        self._p_changed = 1
        self._newsCounter = Counter()
        # days to keep a 'New' tag on recent news items
        self._recentDays = 14
        # fetch all news from the previous location.
        self.addNewsItem(
            NewsItem(_("Previous news"),
                     HelperMaKaCInfo.getMaKaCInfoInstance().getNews(),
                     "general"))

    def getNewsItemsList(self):
        return self._newsItems

    def addNewsItem(self, news):
        news.setId(self._newsCounter.newCount())
        self._newsItems.insert(0, news)
        self._p_changed = 1

    def removeNewsItem(self, id):
        item = self.getNewsItemById(id)
        if item:
            self._newsItems.remove(item)
            self._p_changed = 1
        else:
            raise Exception(_("News item does not exist"))

    def getNewsItemById(self, id):
        for new in self._newsItems:
            if new.getId() == id:
                return new
        return None

    def getRecentDays(self):
        if not hasattr(self, '_recentDays'):
            self._recentDays = 14
        return self._recentDays

    def setRecentDays(self, recentDays):
        self._recentDays = recentDays

    @classmethod
    def getNewsTypes(self):
        return NewsModule._newsTypes

    @classmethod
    def getNewsTypesAsDict(self):
        return dict(NewsModule._newsTypes)
Beispiel #13
0
class OfflineEventsModule(Module):
    """
    This module holds all the information needed to keep the creation process of the offline version of the events.
    That means all the news items and other related information.
    """

    id = "offlineEvents"
    _offlineEventTypes = {
        "Queued": L_("Queued"),
        "Generated": L_("Generated"),
        "Failed": L_("Failed"),
        "Expired": L_("Expired")
    }

    def __init__(self):
        self._idxConf = OOBTree()
        self._offlineEventCounter = Counter()

    def getOfflineEventIndex(self):
        return self._idxConf

    def getOfflineEventByConfId(self, confId):
        return self._idxConf.get(confId, [])

    def getOfflineEventByFileId(self, confId, fileId):
        offline_request_list = self._idxConf.get(confId, [])
        for req in offline_request_list:
            if req.id == fileId:
                return req
        return None

    def addOfflineEvent(self, offlineEvent):
        confId = offlineEvent.conference.getId()
        if not self._idxConf.has_key(confId):
            lst = []
            self._idxConf[confId] = lst
        else:
            lst = self._idxConf[confId]
        offlineEvent.id = self._offlineEventCounter.newCount()
        lst.append(offlineEvent)
        self._idxConf[confId] = lst

    def removeOfflineEvent(self, offlineEvent, del_file=False):
        if offlineEvent:
            confId = offlineEvent.conference.getId()
            lst = self._idxConf.get(confId, [])
            if offlineEvent in lst:
                lst.remove(offlineEvent)
            self._idxConf[confId] = lst
            if del_file:
                self.removeOfflineFile(offlineEvent)
        else:
            raise Exception(_("OfflineEvent does not exist"))

    def removeOfflineFile(self, offlineEvent):
        filepath = offlineEvent.file.getFilePath()
        if os.path.isfile(filepath):
            os.remove(filepath)
        offlineEvent.status = "Expired"

    @classmethod
    def getOfflineEventTypes(self):
        return OfflineEventsModule._offlineEventTypes
Beispiel #14
0
##
## You should have received a copy of the GNU General Public License
## along with Indico;if not, see <http://www.gnu.org/licenses/>.

from MaKaC.plugins.Collaboration.base import CollaborationServiceException,\
    CSErrorBase
from MaKaC.webinterface.common.contribFilters import PosterFilterField
from MaKaC.conference import Contribution
from MaKaC.common.fossilize import fossilizes
from MaKaC.plugins.Collaboration.RecordingRequest.fossils import IRecordingRequestErrorFossil
from MaKaC.plugins.Collaboration.collaborationTools import CollaborationTools

from indico.util.i18n import L_

postingUrgency = [
    ("withinHours" , L_("Within hours")),
    ("withinDay" , L_("Within a day")),
    ("withinWeek" , L_("Within a week"))
]

def getTalks(conference, oneIsEnough = False, sort = False):
    """ oneIsEnough: the algorithm will stop at the first contribution found
                     it will then return a list with a single element
        sort: if True, contributions are sorted by start date (non scheduled contributions at the end)
    """
    talks = []
    filter = PosterFilterField(conference, False, False)
    for cont in conference.getContributionList():
        if filter.satisfies(cont):
            talks.append(cont)
            if oneIsEnough: