コード例 #1
0
ファイル: barcamp.py プロジェクト: sk1p/camper
    def publish_not_allowed(self):
        """check if publishing a barcamp is allowed. Reasons will be listed in the resulting array. False means
        barcamp can be published"""
        if not self.ticketmode_enabled:
            return False
        reasons = []
        if not self.contact_email:
            reasons.append({
                'reason'    : T('The contact email is not set'),
                'url'       : 'legaledit'
            })
        if not len(self.imprint.strip())>20:
            reasons.append({
                'reason'    : T('The Imprint is missing'),
                'url'       : 'legaledit'
            })
        if not len(self.tos.strip())>20:
            reasons.append({
                'reason'    : T('The terms of service are missing'),
                'url'       : 'legaledit'
            })
        if not len(self.cancel_policy.strip())>20:
            reasons.append({
                'reason'    : T('The cancel policy is missing'),
                'url'       : 'legaledit'
            })

        return reasons
コード例 #2
0
ファイル: forms.py プロジェクト: cryu/userbase
class UsernameRegistrationForm(BaseForm):
    username = TextField(T('Username'),
                         [validators.Length(max=200),
                          validators.Required()])
    email = TextField(T('E-Mail'), [
        validators.Length(max=200),
        validators.Email(),
        validators.Required()
    ])
    password = PasswordField(T('Password'), [
        validators.Required(),
        validators.EqualTo('password2', message='Passwords must match')
    ])
    password2 = PasswordField(
        T('Password confirmation'),
        [validators.Length(max=135),
         validators.Required()])
    fullname = TextField(T('Full name'),
                         [validators.Length(max=200),
                          validators.Required()])

    def validate_email(form, field):
        if form.module.users.find({'email': field.data}).count() > 0:
            raise ValidationError(T('this email address is already taken'))

    def validate_username(form, field):
        if form.module.users.find({'username': field.data}).count() > 0:
            raise ValidationError(T('this username is already taken'))
コード例 #3
0
ファイル: forms.py プロジェクト: cryu/userbase
class UsernameLoginForm(Form):
    username = TextField(T('Username'),
                         [validators.Length(max=200),
                          validators.Required()])
    password = PasswordField(
        T('Password'), [validators.Length(max=135),
                        validators.Required()])
    remember = BooleanField(T('stay logged in'))
コード例 #4
0
class PageAddForm(BaseForm):
    """form for adding a barcamp"""
    title = TextField(
        T("Title"),
        [validators.Length(max=80),
         validators.Required()],
        description=T('title of the page (max. 80 characters)'),
    )
コード例 #5
0
ファイル: sponsors.py プロジェクト: sk1p/camper
class SponsorForm(BaseForm):
    """form for adding a new sponsor"""
    # base data
    name = TextField(T(u"Name of sponsor"),
                     [validators.Length(max=300),
                      validators.Required()])
    url = TextField(T(u"URL of sponsor website"),
                    [validators.URL(), validators.Required()])
    image = UploadField(T(u"Sponsor Logo"))
コード例 #6
0
class CancelForm(BaseForm):
    """form for adding a new ticket class"""

    reason = TextAreaField(
        T(u"Reason"),
        [validators.Required(),
         validators.Length(max=10000)],
        description=T(u'Please give a reason for canceling here.'),
    )
コード例 #7
0
ファイル: forms.py プロジェクト: cryu/userbase
class PasswordChangeForm(BaseForm):
    password = PasswordField(T('New Password'), [
        validators.Required(),
        validators.EqualTo('password2', message=T('Passwords must match'))
    ])
    password2 = PasswordField(
        T('Password confirmation'),
        [validators.Length(max=135),
         validators.Required()])
コード例 #8
0
ファイル: galleries.py プロジェクト: sk1p/camper
class ImageDetailForm(BaseForm):
    """form for image details"""

    _id         = HiddenField()
    title       = TextField(T("Title"))
    alt         = TextField(T("Alt attribute"))
    description = TextAreaField(T("Description"))
    license     = TextField(T("License"))
    copyright   = TextField(T("Copyright Owner"))
コード例 #9
0
ファイル: sessionboard.py プロジェクト: sk1p/camper
class RoomForm(BaseForm):
    """form for adding a new room"""
    name = TextField(T(u"Name"),
                     [validators.Length(max=300),
                      validators.Required()])
    capacity = IntegerField(
        T(u"Capacity"), [validators.NumberRange(min=1),
                         validators.Required()])
    description = TextAreaField(T(u"Description"),
                                [validators.Length(max=200)])
コード例 #10
0
ファイル: pads.py プロジェクト: sk1p/camper
class BlogAddForm(BaseForm):
    """form for adding a new blog link"""
    title = TextField(
        T("Post Title"), [validators.Length(max=1000),
                          validators.Required()],
        description=T('title of the blog post you are linking to'))
    url = TextField(T("Post URL"),
                    [validators.Length(max=1000),
                     validators.Required()],
                    description=T('URL of the blog post you want to link to'))
コード例 #11
0
ファイル: forms.py プロジェクト: cryu/userbase
class EMailLoginForm(Form):
    email = TextField(T('E-Mail'), [
        validators.Length(max=200),
        validators.Email(),
        validators.Required()
    ])
    password = PasswordField(
        T('Password'), [validators.Length(max=135),
                        validators.Required()])
    remember = BooleanField(T('stay logged in'))
コード例 #12
0
ファイル: forms.py プロジェクト: cryu/userbase
class PWEMailForm(Form):
    """form for asking for an email address to send the code to"""
    email = TextField(
        T('E-Mail'), [
            validators.Length(max=200),
            validators.Email(),
            validators.Required()
        ],
        description=
        T("Please enter the email address you registered with to receive a link to reset your password."
          ))
コード例 #13
0
class EMailLoginForm(BaseForm):
    """our own email login form which derives from userbase BaseForm which in turn derives
    from the sf-babel BaseForm in case it is installed
    """

    email = TextField(T('E-Mail'),
                      [validators.Length(max=100),
                       validators.Required()])
    password = PasswordField(
        T('Password'), [validators.Length(max=135),
                        validators.Required()])
    remember = BooleanField(T('remember me'))
コード例 #14
0
ファイル: newsletter.py プロジェクト: sk1p/camper
class NewsletterForm(BaseForm):
    """form for creating a newsletter"""
    # base data
    subject = TextField(T("Subject"), [validators.Length(max=300), validators.Required()],
                #description = T('every barcamp needs a title. examples: "Barcamp Aachen 2012", "JMStVCamp"'),
    )
    body    = TextAreaField(T("Newsletter body"), [validators.Required()],
                #description = T('please describe your barcamp here'),
    )

    testmail = TextField(T("E-Mail address for testing the newsletter"),
                description = T('put your own e-mail address here in order to send the newsletter to this address for testing purposes'),
    )
コード例 #15
0
ファイル: forms.py プロジェクト: cryu/userbase
class UserEditForm(BaseForm):
    username = TextField(T('Username'),
                         [validators.Length(max=200),
                          validators.Required()])
    email = TextField(T('E-Mail'), [
        validators.Length(max=200),
        validators.Email(),
        validators.Required()
    ])
    fullname = TextField(T('Full name'),
                         [validators.Length(max=200),
                          validators.Required()])
    permissions = PermissionSelectField('Permissions')
コード例 #16
0
 def actions(self):
     """return the possible menu actions for a barcamp as well as a flag if it's active or not"""
     actions = []
     uf = self.url_for
     bc = self.barcamp
     # we need to check for barcamp as pages use this handler, too and pages can also be on the top level 
     if bc is not None:
         actions.append(Action('home', T("Home"), uf('barcamps.index', slug = self.barcamp.slug), self.action == 'home'))
         if "sessions" not in bc.hide_tabs:
             actions.append(Action('sessions', T("session proposals"), uf('barcamps.sessions', slug = bc.slug), self.action == 'sessions'))
         # only show events if we actually have any defined
         if bc.events and "events" not in bc.hide_tabs:
             actions.append(Action('events', T("events"), uf('barcamps.user_events', slug = bc.slug), self.action == 'events'))
         if bc.planning_pad_public or self.is_admin:
             actions.append(Action('planning', T("planning"), uf('barcamps.planning_pad', slug = bc.slug), self.action == 'planning'))
         if self.config.dbs.blog.by_barcamp(self.barcamp, only_published = True).count() > 0 and "blog" not in bc.hide_tabs:
             actions.append(Action('blog', T("Blog"), uf('blog.view', slug = bc.slug), self.action == 'blog'))
         for page in self.barcamp_view.pages_for("menu"):
             pid = "page_%s" %page._id
             actions.append(Action(pid, page.menu_title, uf('pages.barcamp_page', slug = bc.slug, page_slug = page.slug), self.action == pid))
         if bc.twitterwall:
             if True:
                 actions.append(Action('twitterwall', T("Twitterwall"), bc.twitterwall, self.action == 'twitterwall'))
             elif bc.twitterwall.find("tweetwally") != -1:
                 actions.append(Action('twitterwall', T("Twitterwall"), uf("barcamps.tweetwally", slug = bc.slug), self.action == 'twitterwall'))
             else:
                 actions.append(Action('twitterwall', T("Twitterwall"), bc.twitterwall, self.action == 'twitterwall'))
     return actions
コード例 #17
0
class EMailForm(BaseForm):
    """form for asking for email to confirm deletion"""
    email = TextField(T(u"E-Mail address"), [
        validators.Length(max=200),
        validators.Email(),
        validators.Required()
    ])
コード例 #18
0
class EMailForm(BaseForm):
    """form for adding a barcamp"""
    user_id = HiddenField()
    email = TextField(T(u"E-Mail address"), [
        validators.Length(max=200),
        validators.Email(),
        validators.Required()
    ])

    def validate_email(form, field):
        if form.app.module_map.userbase.users.find({
                'email': field.data,
                '_id': {
                    '$ne': ObjectId(form.data['user_id'])
                }
        }).count() > 0:
            raise ValidationError(
                form.handler._('this email address is already taken'))

    def validate_username(form, field):
        if form.app.module_map.userbase.users.find({
                'username': field.data,
                '_id': {
                    '$ne': ObjectId(form.data['user_id'])
                }
        }).count() > 0:
            raise ValidationError(
                form.handler._('this url path is already taken'))
コード例 #19
0
ファイル: sponsor.py プロジェクト: sk1p/camper
class ContactForm(BaseForm):
    """form for contacting regarding barcamp sponsorship"""
    name = TextField(
        T(u"Your Name"),
        [validators.Length(max=300),
         validators.Required()],
    )
    email = TextField(
        T(u"Your E-Mail address"), [
            validators.Email(),
            validators.Length(max=300),
            validators.Required()
        ],
        description=T(
            u'please enter your email address so we can contact you'))
    title = TextField(
        T(u"Name of the proposed youth barcamp"),
        [validators.Length(max=300),
         validators.Required()],
    )
    date = TextField(
        T(u"Planned date of barcamp"),
        [validators.Length(max=300),
         validators.Required()],
    )
    reason = TextAreaField(
        T(u"Reason for sponsorship"),
        [validators.Required()],
        description=
        T(u'please describe your barcamp here esp. in regards of youth participation'
          ),
    )
コード例 #20
0
ファイル: ticketeditor.py プロジェクト: sk1p/camper
class TicketClassForm(BaseForm):
    """form for adding a new ticket class"""
    name = TextField(T(u"Name of the ticket"),
                     [validators.Length(max=300),
                      validators.Required()])
    description = TextAreaField(
        T(u"Description"),
        [validators.Length(max=10000)],
        description=
        T(u'Please describe here what you get for obtaining one of these tickets'
          ),
    )
    size = SelectField(T(u"maximum tickets available"),
                       [validators.Required()],
                       choices=[(str(n), str(n)) for n in range(1, 500)])
    events = MultiCheckboxField(
        T(u'Events'),
        description=T(
            u'Please select the events you can attend with this ticket'))
    price = TextField(T(u"Price"), [validators.Length(max=10)])

    start_date = DateField(T("start date"), [], format="%d.%m.%Y")
    end_date = DateField(T("end date"), [], format="%d.%m.%Y")
コード例 #21
0
ファイル: add.py プロジェクト: sk1p/camper
class EntryForm(BaseForm):
    """form for adding an event to a barcamp"""
    title = TextField(T(u"Title"),
                      [validators.Length(max=300),
                       validators.Required()])
    content = WYSIWYGField(T(u"Content"), [])
    seo_description = TextField(
        T('Meta Description'), [validators.Length(max=160)],
        description=
        T('The meta description is used for for search engines and often shows up in search results. It should be no more than 160 characters long.'
          ))
    published = DateTimePickerField(
        T(u"Publishing Date"),
        default=None,
    )
    image = UploadField(T(u"Title image"))
    gallery = SelectField(T(u'Gallery to show on homepage'), default=-1)
コード例 #22
0
ファイル: base.py プロジェクト: cryu/camper
 def actions(self):
     """return the possible menu actions for a barcamp as well as a flag if it's active or not"""
     actions = []
     uf = self.url_for
     bc = self.barcamp
     # we need to check for barcamp as pages use this handler, too and pages can also be on the top level
     if bc is not None:
         actions.append(
             Action('home', T("Home"), uf('barcamp',
                                          slug=self.barcamp.slug),
                    self.action == 'home'))
         actions.append(
             Action('sessions', T("session proposals"),
                    uf('barcamp_sessions', slug=bc.slug),
                    self.action == 'sessions'))
         actions.append(
             Action('participants', T("participants"),
                    uf('barcamp_userlist', slug=bc.slug),
                    self.action == 'participants'))
         if bc.planning_pad_public or self.is_admin:
             actions.append(
                 Action('planning', T("planning"),
                        uf('barcamp_planning_pad', slug=bc.slug),
                        self.action == 'planning'))
         actions.append(
             Action('docs', T("documentation"),
                    uf('barcamp_documentation_pad', slug=bc.slug),
                    self.action == 'docs'))
         for page in self.barcamp_view.pages_for("menu"):
             pid = "page_%s" % page._id
             actions.append(
                 Action(
                     pid, page.menu_title,
                     uf('barcamp_page', slug=bc.slug, page_slug=page.slug),
                     self.action == pid))
         if bc.twitterwall:
             if bc.twitterwall.find("tweetwally") != -1:
                 actions.append(
                     Action('twitterwall', T("Twitterwall"),
                            uf("barcamp_tweetwally", slug=bc.slug),
                            self.action == 'twitterwall'))
             else:
                 actions.append(
                     Action('twitterwall', T("Twitterwall"), bc.twitterwall,
                            self.action == 'twitterwall'))
     return actions
コード例 #23
0
ファイル: ticketeditor.py プロジェクト: sk1p/camper
class TicketConfigurationForm(BaseForm):
    """form for configuring the tickets"""
    ticketmode_enabled = BooleanField(
        T('Enable Ticketing'),
        description=
        T(u"if you enable ticketing the normal registration process per event is replaced by acquiring tickets you define here"
          ))
    paid_tickets = BooleanField(
        T('Paid Tickets'),
        description=
        T(u"Enable this option if you want to charge money for tickets. Please be aware though that barcamptools will not perform any payment processing. You have to do this yourself. You also need a proper imprint and contact email before you can enable this option."
          ))
    preregistration = BooleanField(
        T('Enable Pre-Registration'),
        description=
        T(u'If enabled an administrator needs to confirm the ticket transaction. If you use paid tickets this is always active because you have to check the payments yourself.'
          ))
    max_participants = IntegerField(
        T('Maximum number of participants'), [validators.optional()],
        description=
        T(u"You can define a maximum number if participants over all tickets here. If this amount is reached, no further tickets can be obtained."
          ))
コード例 #24
0
class TicketMailsEditForm(BaseForm):
    """form for defining mail templates specific for tickets"""
    ticket_welcome_subject = TextField(
        T("Subject"),
        [validators.Length(max=300),
         validators.Required()],
    )
    ticket_welcome_text = TextAreaField(
        T("Body"),
        [validators.Required()],
    )
    ticket_pending_subject = TextField(
        T("Subject"),
        [validators.Length(max=300),
         validators.Required()],
    )
    ticket_pending_text = TextAreaField(
        T("Body"),
        [validators.Required()],
    )
    ticket_confirmed_subject = TextField(
        T("Subject"),
        [validators.Length(max=300),
         validators.Required()],
    )
    ticket_confirmed_text = TextAreaField(
        T("Body"),
        [validators.Required()],
    )
    ticket_canceled_subject = TextField(
        T("Subject"),
        [validators.Length(max=300),
         validators.Required()],
    )
    ticket_canceled_text = TextAreaField(
        T("Body"),
        [validators.Required()],
    )
コード例 #25
0
class LegalEditForm(BaseForm):
    """legal edit form"""

    contact_email = TextField(
        T("Contact E-Mail"), [validators.Length(max=200),
                              validators.Email()],
        description=
        T("an email address under which a barcamp admin can be contacted. This address will be publically displayed."
          ))
    imprint = WYSIWYGField(
        T("Imprint"),
        [validators.Required(),
         validators.Length(min=50, max=20000)],
        description=
        T("Please describe in detail who is responsible for this barcamp. This is mandatory for paid barcamps."
          ))
    tos = WYSIWYGField(
        T("Terms of Service"), [validators.Length(min=50, max=20000)],
        description=T("Please enter your terms of service here."))
    cancel_policy = WYSIWYGField(
        T("Cancellation Policy"), [validators.Length(min=50, max=20000)],
        description=
        T("Please describe your cancellation policy (make sure it complies to your local law)."
          ))
コード例 #26
0
class MailsEditForm(BaseForm):
    """form for defining mail templates"""
    # base data
    welcome_subject = TextField(
        T("Subject"),
        [validators.Length(max=300),
         validators.Required()],
        #description = T('the name of the field to be shown in the form, e.g. "t-shirt size"'),
    )
    welcome_text = TextAreaField(
        T("Body"),
        [validators.Required()],
        #description = T('the name of the field to be shown in the form, e.g. "t-shirt size"'),
    )
    onwaitinglist_subject = TextField(
        T("Subject"),
        [validators.Length(max=300),
         validators.Required()],
        #description = T('the name of the field to be shown in the form, e.g. "t-shirt size"'),
    )
    onwaitinglist_text = TextAreaField(
        T("Body"),
        [validators.Required()],
        #description = T('the name of the field to be shown in the form, e.g. "t-shirt size"'),
    )
    fromwaitinglist_subject = TextField(
        T("Subject"),
        [validators.Length(max=300),
         validators.Required()],
        #description = T('the name of the field to be shown in the form, e.g. "t-shirt size"'),
    )
    fromwaitinglist_text = TextAreaField(
        T("Body"),
        [validators.Required()],
        #description = T('the name of the field to be shown in the form, e.g. "t-shirt size"'),
    )
コード例 #27
0
ファイル: galleries.py プロジェクト: sk1p/camper
class ImageForm(BaseForm):
    """form for adding a new image to an image gallery"""
    image       = UploadField(T(u"New Image"), autosubmit = True)
コード例 #28
0
class ParticipantDataEditForm(BaseForm):
    """form for defining a pareticipant data form"""
    # base data
    title = TextField(
        T("Name of field"),
        [validators.Length(max=50),
         validators.Required()],
        description=T(
            'the name of the field to be shown in the form, e.g. "t-shirt size"'
        ),
    )
    description = TextAreaField(
        T("Description"),
        description=T(
            'please describe what the user should enter in this field.'),
    )
    fieldtype = RadioField(
        T("field type"),
        [validators.Required()],
        choices=[('checkbox', T('a yes/no field')),
                 ('textfield', T('1 line of text')),
                 ('textarea', T('multiple lines of text')),
                 ('select', T('select one choice out of many'))],
        description=T(
            'please chose between a one-line text field or multi-line text area'
        ),
    )
    choices = TextAreaField(
        T("Choices"),
        description=T('please put each choice on a separate line.'),
    )
    required = BooleanField(
        T("field required?"),
        description=
        T('If you enable this then the user cannot register before this field has been filled in.'
          ),
    )
コード例 #29
0
ファイル: edit.py プロジェクト: sk1p/camper
class EditForm(BaseForm):
    """form for adding a barcamp"""
    user_id = HiddenField()
    fullname = TextField(T(u"Fullname"))
    username = TextField(
        T(u"url name (username)"), [
            validators.Length(min=3, max=50),
            validators.Required(),
            validators.Regexp('^[a-zA-Z0-9_]+$')
        ],
        description=
        T("this is the url path of your profile page, should only contain letters and numbers"
          ))
    bio = TextAreaField(T(u"About me"))
    organisation = TextField(
        T(u"Organization"), [validators.Length(max=100)],
        description=T(
            "your school, company, institution (max. 100 characters)"))
    twitter = TextField(T(u"Twitter"), [validators.Length(max=100)],
                        description=T("your twitter username"))
    facebook = TextField(
        T(u"Facebook"), [validators.Length(max=255)],
        description=T("path to your facebook profile (without domain)"))
    image = UploadField(T(u"Profile Image (optional)"))

    # TODO: maybe change email, too?
    def validate_email(form, field):
        if form.app.module_map.userbase.users.find({
                'email': field.data
        }).count() > 0:
            raise ValidationError(
                form.handler._('this email address is already taken'))

    def validate_username(form, field):
        if form.app.module_map.userbase.users.find({
                'username': field.data,
                '_id': {
                    '$ne': ObjectId(form.data['user_id'])
                }
        }).count() > 0:
            raise ValidationError(
                form.handler._('this url path is already taken'))
コード例 #30
0
ファイル: barcamp.py プロジェクト: sk1p/camper
class Barcamp(Record):

    schema = BarcampSchema()
    _protected = ['event', 'schema', 'collection', '_protected', '_schemaless', 'default_values', 'admin_users', 'workflow_states', 'initial_workflow_state']
    initial_workflow_state = "created"
    default_values = {
        'created'       : datetime.datetime.utcnow,
        'updated'       : datetime.datetime.utcnow,
        'location'      : {},
        'workflow'      : "created",
        'events'        : {},
        'registration_form'        : [
            { "title" : T("Show on public participants list"),
              "required" : False, 
              "description" : T("Decide whether you want to be displayed on the public list of participants"), 
              "name" : "optin_participant", 
              "fieldtype" : "checkbox" }
        ],
        'registration_data'        : {},
        'planning_pad_public'        : False,
        'background_color'      : '#fcfcfa',
        'link_color'            : '#337CBB',
        'text_color'            : '#333',

        'header_color'          : '#fff',
        'navbar_link_color'     : '#888',
        'navbar_active_bg'      : '#555',
        'navbar_active_color'   : '#eee',
        'navbar_border_color'   : '#f0f0f0',
        'navbar_hover_bg'       : '#f8f8f8',
        'hide_tabs'             : [],
        'hide_barcamp'          : False,
        'seo_description'       : '', 
        'seo_keywords'          : '',
        'wizard_checked'        : [],
        'contact_email'         : '', 
        'imprint'               : '', 
        'tos'                   : '', 
        'cancel_policy'         : '', 
    }

    workflow_states = {
        'created'       : ['public', 'deleted', 'canceled'],
        'public'        : ['created', 'registration', 'deleted', 'canceled'],
        'registration'  : ['deleted', 'canceled', 'created'],
        'canceled'      : ['deleted'],
    }

    def set_workflow(self, new_state):
        """set the workflow to a new state"""
        old_state = self.workflow
        if old_state is None:
            old_state = self.initial_workflow_state
        allowed_states = self.workflow_states[old_state]

        # check if transition is allowed
        if hasattr(self, "check_wf_"+new_state):
            m = getattr(self, "check_wf_"+new_state)
            if not m(old_state = old_state): # this should raise WorkflowError if not allowed otherwise return True
                raise WorkflowError(old_state = old_state, new_state = new_state) # fallback

        if new_state not in allowed_states:
            raise WorkflowError(old_state = old_state, new_state = new_state)

        # Trigger
        if hasattr(self, "on_wf_"+new_state):
            m = getattr(self, "on_wf_"+new_state)
            m(old_state = old_state)
        self.workflow = new_state


    def get_event(self, eid):
        """return the event for the given id or None"""
        e = self.events[eid]
        return Event(e, _barcamp = self)

    @property
    def eventlist(self):
        """return the events as a list sorted by date"""
        events = self.events.values()
        def s(a,b):
            d = cmp(a['date'], b['date'])
            if d==0:
                tpa = a['start_time'].split(":") + ['00']
                ta = int(tpa[0])*60 + int(tpa[1])
                tpb = b['start_time'].split(":") + ['00']
                tb = int(tpb[0])*60 + int(tpb[1])
                return cmp(ta,tb)
            return d
        events.sort(s)
        events = [Event(e, _barcamp = self) for e in events]
        return events

    @property
    def ticketlist(self):
        """return a list of all ticket classes and whether they are full or not"""
        ub = self._collection.md.app.module_map.userbase
        tickets = [TicketClass(tc, _barcamp = self, _userbase = ub) for tc in self.ticket_classes]
        return tickets

    def get_ticket_class(self, tc_id):
        """return a ticket class by it's id or None if it does not exist"""
        for tc in self.ticket_classes:
            if tc['_id'] == tc_id:
                return TicketClass(tc, _barcamp = self, _userbase = self._collection.md.app.module_map.userbase)
        return None

    def update_ticket_class(self, tc):
        """update an existing ticket class by searching for it in the list and replacing it"""
        i = 0
        tc_data = tc.schema.serialize(tc)
        for i in range(0,len(self.ticket_classes)):
            if self.ticket_classes[i]['_id'] == tc._id:
                self.ticket_classes[i] = tc_data
                return        

    def delete_ticket_class(self, tc):
        """delete an existing ticket class by searching for it in the list and removing it"""
        i = 0
        tc_data = tc.schema.serialize(tc)
        for i in range(0,len(self.ticket_classes)):
            if self.ticket_classes[i]['_id'] == tc._id:
                del self.ticket_classes[i]
                return        

    def get_tickets_for_user(self, user_id, status=["confirmed", "pending", "cancel_request"]):
        """return all the ticket class ids which a users owns

        :param user_id: the user id of the user
        :param status: the status which is either a string or a list of strings
        :return: a list of ticket classes
        """

        tickets = self._collection.md.app.config.dbs.tickets
        return tickets.get_tickets(user_id = user_id, barcamp_id = self._id, status = status)

    @property
    def paid_allowed(self):
        """check if all necessary fields are present for paid mode"""
        return self.contact_email \
            and len(self.imprint.strip())>20 \
            and len(self.tos.strip())>20 \
            and len(self.cancel_policy.strip())>20

    @property
    def publish_not_allowed(self):
        """check if publishing a barcamp is allowed. Reasons will be listed in the resulting array. False means
        barcamp can be published"""
        if not self.ticketmode_enabled:
            return False
        reasons = []
        if not self.contact_email:
            reasons.append({
                'reason'    : T('The contact email is not set'),
                'url'       : 'legaledit'
            })
        if not len(self.imprint.strip())>20:
            reasons.append({
                'reason'    : T('The Imprint is missing'),
                'url'       : 'legaledit'
            })
        if not len(self.tos.strip())>20:
            reasons.append({
                'reason'    : T('The terms of service are missing'),
                'url'       : 'legaledit'
            })
        if not len(self.cancel_policy.strip())>20:
            reasons.append({
                'reason'    : T('The cancel policy is missing'),
                'url'       : 'legaledit'
            })

        return reasons
        
    @property
    def has_imprint(self):
        """return whether the barcamp has a proper imprint or not

        basically it needs to be bigger than 20 chars

        """
        return len(self.imprint.strip())>20

    @property
    def registration_active(self):
        """check if registration is active by checking workflow state and end date"""
        if self.workflow != "registration":
            return False

        # check date
        today = datetime.date.today()
        if today > self.end_date:
            return False

        return True

    def is_registered(self, user, states=['going', 'maybe', 'waiting']):
        """check if the given user is registered in any event of this barcamp

        :param user: the user object to test
        :param states: give the list of states which count as registered (defaults to all)
        :returns: ``True`` or ``False``
        """
        if user is None: 
            return False
        uid = user.user_id
        for event in self.eventlist:
            if uid in event.participants and 'going' in states:
                return True
            elif uid in event.maybe and 'maybe' in states:
                return True
            elif uid in event.waiting_list and 'waiting' in states:
                return True
        return False

    @property
    def live_event(self):
        """returns the active event or None"""
        today = datetime.date.today()
        today = datetime.datetime.combine(today, datetime.time.min)

        for event in self.eventlist:
            if event.date == today:
                if len(event.rooms)>0:
                    return event
        return None

    @property
    def public(self):
        """return whether the barcamp is public or not"""
        return self.workflow in ['public', 'registration', 'canceled']

    def add_admin(self, user):
        """add a new admin to the invited admins list"""
        self.admins.append(unicode(user._id))

    def remove_admin_by_id(self, user_id):
        """remove an admin from the list of admins but only if the list is not empty then and the
        creator of the barcamp is still on it."""
        if len(self.admins)<2:
            return
        self.admins.remove(unicode(user_id))

    def activate_admin(self, user):
        """activate an admin by moving from the invited to the actual list"""
        if user._id in self.invited_admins:
            self.invited_admins.remove(user._id)
            if user._id not in self.admins:
                self.admins.append(unicode(user._id))

    @property
    def admin_users(self):
        """return a list of user objects of the admin users"""
        ub = self._collection.md.app.module_map.userbase
        return list(ub.get_users_by_ids(self.admins))

    @property
    def subscriber_users(self):
        """return a list of user objects of the subscribed users"""
        ub = self._collection.md.app.module_map.userbase
        users = []
        for uid in self.subscribers:
            users.append(ub.get_user_by_id(uid))
        return users

    @property
    def event(self):
        """returns the main event object or None in case there is no event"""
        return {}
        raise NotImplemented
        if self.events == []:
            return None
        event = self.events[0]
        event._barcamp = self
        return event

    def get_events(self):
        """return the events wrapped in the ``Event`` class"""
        return [Event(e, _barcamp = self) for e in self.events]

    def add_event(self, event):
        """add an event"""

        if event.get("_id", None) is None:
            eid = event['_id'] = unicode(uuid.uuid4())
        else:
            eid = event['_id']
        self.events[eid] = event
        return event

    @property
    def state(self):
        """the same as the event state which we compute here for the main event.
        If multiple events are possible in the future then this will check all of the events

        If no event is present, ``planning`` will be returned.
        """

        if self.event is None:
            return "planning"
        return self.event.state

    def subscribe(self, user):
        """subscribe a user to the barcamp"""
        uid = unicode(user._id)
        if uid not in self.subscribers:
            self.subscribers.append(uid)
        self.put()

    def unsubscribe(self, user):
        """unsubscribe a user from the barcamp"""
        uid = unicode(user._id)
        if uid in self.subscribers:
            self.subscribers.remove(uid)
        self.put()


    def set_nl_reply_to(self, email_address):
        """set up a new reply to address for the newsletter

        you need to save the barcamp afterwards

        :param email_address: the email address to be set
        :returns: a uuid code for sending to the user to verify
        """

        self.newsletter_reply_to2 = email_address
        self.newsletter_rt_code = unicode(uuid.uuid4())
        return self.newsletter_rt_code


    def verify_nl_reply_to(self, code):
        """verify the reply to verification code

        returns True if it's ok and will set the new reply to address then

        you need to save the barcamp object afterwards
        """

        if self.newsletter_rt_code == code:
            self.newsletter_reply_to = self.newsletter_reply_to2
            self.newsletter_rt_code = ""
            self.newsletter_reply_to2 = ""
            return True
        else:
            return False

    def remove_nl_reply_to(self):
        """remove the reply to address"""
        self.newsletter_reply_to = ""