def index_view(self):
        if request.method == 'POST':
            DataManager.update_permissions(request.form)

        perms = dict()
        roles = DataGetter.get_roles()
        services = DataGetter.get_services()
        get_permission = DataGetter.get_permission_by_role_service

        for role in roles:
            perms[role] = dict()
            for service in services:
                perms[role][service.name] = dict()
                p = get_permission(role=role, service=service)
                if not p:
                    perms[role][service.name]['c'] = False
                    perms[role][service.name]['r'] = False
                    perms[role][service.name]['u'] = False
                    perms[role][service.name]['d'] = False
                else:
                    perms[role][service.name]['c'] = p.can_create
                    perms[role][service.name]['r'] = p.can_read
                    perms[role][service.name]['u'] = p.can_update
                    perms[role][service.name]['d'] = p.can_delete

        return self.render(
            '/gentelella/admin/super_admin/permissions/permissions.html',
            perms=sorted(perms.iteritems(),
                         key=lambda (k, v): k.name))
    def index_view(self):
        if request.method == 'POST':
            DataManager.update_permissions(request.form)

        perms = dict()
        roles = DataGetter.get_roles()
        services = DataGetter.get_services()
        get_permission = DataGetter.get_permission_by_role_service

        for role in roles:
            perms[role] = dict()
            for service in services:
                perms[role][service.name] = dict()
                p = get_permission(role=role, service=service)
                if not p:
                    perms[role][service.name]['c'] = False
                    perms[role][service.name]['r'] = False
                    perms[role][service.name]['u'] = False
                    perms[role][service.name]['d'] = False
                else:
                    perms[role][service.name]['c'] = p.can_create
                    perms[role][service.name]['r'] = p.can_read
                    perms[role][service.name]['u'] = p.can_update
                    perms[role][service.name]['d'] = p.can_delete

        return self.render(
            '/gentelella/admin/super_admin/permissions/permissions.html',
            perms=sorted(perms.iteritems(), key=lambda (k, v): k.name))
 def index_view(self):
     mails = DataGetter.get_all_mails(count=300)
     activities = DataGetter.get_all_activities(count=600)
     return self.render(
         '/gentelella/admin/super_admin/logs/logs.html',
         mails=mails,
         activities=activities
     )
예제 #4
0
 def index_view(self):
     mails = DataGetter.get_all_mails(count=300)
     notifications = DataGetter.get_all_notifications(count=300)
     activities = DataGetter.get_all_activities(count=600)
     return self.render(
         '/gentelella/admin/super_admin/logs/logs.html',
         mails=mails,
         notifications=notifications,
         activities=activities
     )
 def validate(self, data, event_id, check_required=True):
     form = DataGetter.get_custom_form_elements(event_id)
     model = None
     if form:
         model = model_custom_form(form.session_form, self.post_api_model)
     return ServiceDAO.validate(
         self, data, model=model, check_required=check_required)
예제 #6
0
class SessionLanguageField(fields.ChoiceString):
    __schema_example__ = DataGetter.get_language_list()[51]

    def __init__(self, **kwargs):
        super(SessionLanguageField, self).__init__(
            choice_list=DataGetter.get_language_list(),
            **kwargs)
예제 #7
0
class EventTypeField(fields.ChoiceString):
    __schema_example__ = DataGetter.get_event_types()[0]

    def __init__(self, **kwargs):
        super(EventTypeField, self).__init__(
            choice_list=DataGetter.get_event_types(),
            **kwargs)
 def test_scheduler_publish(self):
     with app.test_request_context():
         event = ObjectMother.get_event()
         save_to_db(event, "Event saved")
         rv = self.app.get(url_for('event_scheduler.publish', event_id=event.id), follow_redirects=True)
         event = DataGetter.get_event(event.id)
         self.assertTrue(event.schedule_published_on is not None, msg=rv.data)
 def validate(self, value):
     topic = self.payload.get('topic')
     if not topic:
         self.choice_list = []
     else:
         self.choice_list = DataGetter.get_event_subtopics().get(topic, [])
     return super(EventSubTopicField, self).validate(value)
 def test_event_publish(self):
     with app.test_request_context():
         event = ObjectMother.get_event()
         save_to_db(event, "Event saved")
         url = url_for('events.publish_event', event_id=event.id)
         rv = self.app.get(url, follow_redirects=True)
         event = DataGetter.get_event(event.id)
         self.assertEqual("Published", event.state, msg=event.state)
 def test_event_publish(self):
     with app.test_request_context():
         event = ObjectMother.get_event()
         save_to_db(event, "Event saved")
         url = url_for('events.publish_event', event_id=event.id)
         rv = self.app.get(url, follow_redirects=True)
         event = DataGetter.get_event(event.id)
         self.assertEqual("Published", event.state, msg=event.state)
 def __call__(self, form, field):
     event = DataGetter.get_object(Event, get_event_id())
     session_start = form['start_time'].data
     session_end = form['end_time'].data
     if session_start != None and session_end != None:
         if not (event.start_time <= session_start and session_end <= event.end_time and session_start < session_end):
             self.message = "Session date should be between Event date"
             raise ValidationError(self.message)
 def test_scheduler_publish(self):
     with app.test_request_context():
         event = ObjectMother.get_event()
         save_to_db(event, "Event saved")
         rv = self.app.get(url_for('event_scheduler.publish',
                                   event_id=event.id),
                           follow_redirects=True)
         event = DataGetter.get_event(event.id)
         self.assertTrue(event.schedule_published_on is not None,
                         msg=rv.data)
예제 #14
0
 def __call__(self, form, field):
     event = DataGetter.get_object(Event, get_event_id())
     session_start = form['start_time'].data
     session_end = form['end_time'].data
     if session_start != None and session_end != None:
         if not (event.start_time <= session_start
                 and session_end <= event.end_time
                 and session_start < session_end):
             self.message = "Session date should be between Event date"
             raise ValidationError(self.message)
예제 #15
0
 def test_event_unpublish(self):
     with app.test_request_context():
         event = ObjectMother.get_event()
         event.state = "Published"
         register(self.app, u'*****@*****.**', u'test2')
         login(self.app, '*****@*****.**', 'test2')
         save_to_db(event, "Event saved")
         url = url_for('events.unpublish_event', event_id=event.id)
         rv = self.app.get(url, follow_redirects=True)
         event = DataGetter.get_event(event.id)
         self.assertEqual("Draft", event.state, msg=event.state)
 def test_event_unpublish(self):
     with app.test_request_context():
         event = ObjectMother.get_event()
         event.state = "Published"
         register(self.app, u'*****@*****.**', u'test2')
         login(self.app, '*****@*****.**', 'test2')
         save_to_db(event, "Event saved")
         url = url_for('events.unpublish_event', event_id=event.id)
         rv = self.app.get(url, follow_redirects=True)
         event = DataGetter.get_event(event.id)
         self.assertEqual("Draft", event.state, msg=event.state)
def locations():
    names = []
    for event in DataGetter.get_all_live_events():
        if not string_empty(event.location_name) and not string_empty(event.latitude) and not string_empty(event.longitude):
            response = requests.get("https://maps.googleapis.com/maps/api/geocode/json?latlng=" + str(event.latitude) + "," + str(
                event.longitude)).json()
            if response['status'] == u'OK':
                for addr in response['results'][0]['address_components']:
                    if addr['types'] == ['locality', 'political']:
                        names.append(addr['short_name'])

    cnt = Counter()
    for location in names:
        cnt[location] += 1
    return dict(locations=[v for v, k in cnt.most_common()][:10])
def locations():
    names = []
    for event in DataGetter.get_all_live_events():
        if not string_empty(event.location_name) and not string_empty(
                event.latitude) and not string_empty(event.longitude):
            response = requests.get(
                "https://maps.googleapis.com/maps/api/geocode/json?latlng=" +
                str(event.latitude) + "," + str(event.longitude)).json()
            if response['status'] == u'OK':
                for addr in response['results'][0]['address_components']:
                    if addr['types'] == ['locality', 'political']:
                        names.append(addr['short_name'])

    cnt = Counter()
    for location in names:
        cnt[location] += 1
    return dict(locations=[v for v, k in cnt.most_common()][:10])
 def test_role_update(self):
     with app.test_request_context():
         event = ObjectMother.get_event()
         event.creator = self.super_admin
         save_to_db(event, "Event saved")
         user = ObjectMother.get_user()
         save_to_db(user, "New user saved")
         populate()
         role = Role.query.filter_by(name='coorganizer').first()
         uer = UsersEventsRoles(user, event, role)
         save_to_db(uer, "UER Saved")
         data = {
             'user_email': user.email,
             'user_role': 'track_organizer'
         }
         rv = self.app.post(url_for('event_roles.edit_view', uer_id=uer.id, event_id=event.id, data=data),
                            follow_redirects=True)
         uer = DataGetter.get_user_event_roles_by_role_name(event.id, 'track_organizer').first()
         self.assertTrue(uer is not None, msg=rv.data)
def get_or_create_super_admin():
    user = DataGetter.get_user_by_email("*****@*****.**")
    if not user:
        user = create_super_admin("*****@*****.**", "test_super_admin")
    return user
예제 #21
0
 def index_view(self):
     mails = DataGetter.get_all_mails(count=300)
     return self.render('/gentelella/admin/super_admin/mails/mails.html',
                        mails=mails)
예제 #22
0
 def validate(self, data, event_id, model=None):
     form = DataGetter.get_custom_form_elements(event_id)
     if form:
         model = model_custom_form(form.speaker_form, self.post_api_model)
     return ServiceDAO.validate(self, data, model)
 def get_user_name(transaction_object):
     if transaction_object and transaction_object.user_id:
         user = DataGetter.get_user(transaction_object.user_id)
         return user.email
     return '*****@*****.**'
예제 #24
0
 def index_view(self):
     mails = DataGetter.get_all_mails(count=300)
     return self.render('/gentelella/admin/super_admin/mails/mails.html', mails=mails)
def event_types():
    event_types = DataGetter.get_event_types()
    return dict(event_typo=event_types[:10])
예제 #26
0
def get_or_create_super_admin():
    user = DataGetter.get_user_by_email("*****@*****.**")
    if not user:
        user = create_super_admin("*****@*****.**",
                                  "test_super_admin")
    return user
예제 #27
0
 def __init__(self, **kwargs):
     super(EventTypeField, self).__init__(
         choice_list=DataGetter.get_event_types(),
         **kwargs)
예제 #28
0
 def __init__(self, **kwargs):
     super(SessionLanguageField, self).__init__(
         choice_list=DataGetter.get_language_list(),
         **kwargs)
 def __init__(self, **kwargs):
     super(SessionLanguageField, self).__init__(
         choice_list=DataGetter.get_language_list(),
         **kwargs)
def event_types():
    event_types = DataGetter.get_event_types()
    return dict(event_typo=event_types[:10])
 def get_user_name(transaction_object):
     if transaction_object and transaction_object.user_id:
         user = DataGetter.get_user(transaction_object.user_id)
         return user.email
     return '*****@*****.**'
 def __init__(self, **kwargs):
     super(EventTypeField, self).__init__(
         choice_list=DataGetter.get_event_types(),
         **kwargs)