Пример #1
0
 def get(self, organization=None):
     if not self.user.is_admin:
         raise HttpErrorException.forbidden()
     temp_data = {
         'user': {
             'display_name': self.user.display_name,
             'super_admin': self.user.is_super_admin,
         },
         'org': False,
         'org_json': None,
     }
     if not self.user.is_org_admin or (self.user.is_super_admin
                                       and organization is not None):
         if not organization:
             raise HttpErrorException.forbidden()
         org = Organization.get_by_id(organization)
         if not org:
             raise HttpErrorException.bad_request('invalid organization id')
         if not self.user.is_super_admin and self.user.organization != org.key:
             raise HttpErrorException.forbidden()
         temp_data['org'] = True
         temp_data['org_id'] = org.key.id()
         temp_data['org_json'] = json.dumps(org.to_dict())
         groups = org.get_all_groups()
         groups += org.get_all_hidden_groups()
         temp_data['groups'] = json.dumps(groups)
     template_index = JINJA_ENVIRONMENT.get_template(
         'admin_panel/index.html')
     self.response.write(template_index.render(temp_data))
Пример #2
0
    def get_publish(self, document, group):
        document = Document.get_by_id(document)
        if not document:
            raise HttpErrorException.bad_request('invalid document id')
        if not document.has_permission_read(self.user):
            raise HttpErrorException.forbidden()

        group = Group.get_by_id(group)
        if not group:
            raise HttpErrorException.bad_request('invalid group id')

        self.project = document.project.get()
        version = self.request.get('v', 'latest')
        pub = PublishDocument.get(document, group, version)

        if not pub:
            raise HttpErrorException.not_found()

        if pub.group not in self.user.groups and pub.group != Group.get_worldshare_key(
        ):
            raise HttpErrorException.forbidden()

        self._create_analytic_session()
        self.project.record_analytic('pro_opn', self.analytic_session)

        template_index = JINJA_ENVIRONMENT.get_template('document_public.html')
        return template_index.render({
            'title': self.project.title,
            'version': pub.version,
            'created_at': pub.created_ts,
            'published_to': pub.group.get().name,
            'an_token': self.analytic_session.key.id(),
            'project_id': self.project.id,
            'html': pub.html,
        })
Пример #3
0
 def get(self, organization=None):
     if not self.user.is_admin:
         raise HttpErrorException.forbidden()
     temp_data = {}
     template_index = JINJA_ENVIRONMENT.get_template(
         'admin_panel/dashboard.html')
     self.response.write(template_index.render(temp_data))
Пример #4
0
 def get(self, username=None):
     try:
         checkout_info = payment.get_checkout_data(self.user, GlobalConfig.get_configs())
         if checkout_info == 'free':
             self.redirect('/', abort=True)
     except payment.coupon.InActiveCouponExpcetion as e:
         lr = tt_logging.construct_log(msg_short='Error Processing User\'s Checkout',
                                       msg=e.message,
                                       log_type=tt_logging.PAYMENT, request=self.request, request_user=self.user)
         log.error(lr['dict_msg']['msg'], extra=lr)
         raise HttpErrorException.bad_request('There was an error processing your checkout')
     except Exception as e:
         lr = tt_logging.construct_log(msg_short='Error Processing User\'s Checkout',
                                       msg=e.message,
                                       log_type=tt_logging.PAYMENT, request=self.request, request_user=self.user)
         log.error(lr['dict_msg']['msg'], extra=lr)
         raise
     template_data = {
         'title': 'thinkTank Checkout',
         'nav_bar_title': 'thinkTank',
         'domain': self.request.host_url,
         'merchant': self.user.merchant,
         'payment_plan': checkout_info['items']['pay_plan'],
         'jwt_token': checkout_info['jwt_token'],
         'production': server.PRODUCTION,
     }
     if 'adjusted_plan' in checkout_info['items']:
         template_data['adjusted_plan'] = checkout_info['items']['adjusted_plan']
     template_index = JINJA_ENVIRONMENT.get_template('checkout.html')
     self.response.write(template_index.render(template_data))
Пример #5
0
    def get(self):
        gc = GlobalConfig.get_configs()
        if gc.allow_user_registration:
            self.redirect('/', abort=True)

        template_index = JINJA_ENVIRONMENT.get_template('register_disabled.html')
        self.response.write(template_index.render())
Пример #6
0
    def get(self):
        self._create_analytic_session()
        projects = Project.get_user_projects(self.user)

        debug_level = 0
        if os.environ.get('SERVER_SOFTWARE', '').startswith('Development'):
            debug_level = 3
        try:
            debug_level = int(self.request.get('debug_level', debug_level))
        except ValueError:
            debug_level = 0

        template_data = {
            'title': 'thinkTank',
            'display_name': self.user.display_name,
            'nav_bar_title': 'thinkTank',
            'projects': projects,
            'data': {
                'page': 'home',
                'user': json.dumps(self.user.to_dict(user=self.user)),
                'projects': json.dumps(projects),
                'an_token': self.analytic_session.key.id(),
                'debug_level': debug_level,
            },
            'domain': self.request.host_url,
        }
        template_index = JINJA_ENVIRONMENT.get_template('index.html')
        self.response.write(template_index.render(template_data))
Пример #7
0
 def get(self, organization=None):
     if not self.user.is_admin:
         raise HttpErrorException.forbidden()
     temp_data = {}
     template_index = JINJA_ENVIRONMENT.get_template(
         'admin_panel/thinktank/logging/app_engine_logs.html')
     self.response.write(template_index.render(temp_data))
Пример #8
0
    def _serve_project_page(
        self,
        doc,
        act_con_path,
    ):
        open_chal = False
        if self.request.get('open_chal').lower() == 'false':
            open_chal = False

        context_menu = True
        if self.request.get('context_menu').lower() == 'false':
            context_menu = False

        template_index = JINJA_ENVIRONMENT.get_template('project.html')

        display_name = self.user.display_name
        short_name = (display_name[:14] +
                      '...') if len(display_name) > 17 else display_name

        debug_level = 0
        if os.environ.get('SERVER_SOFTWARE', '').startswith('Development'):
            debug_level = 3
        try:
            debug_level = int(self.request.get('debug_level', debug_level))
        except ValueError:
            debug_level = 0

        template_data = {
            'data':
            json.dumps({
                'project': self.project.to_dict(self.user),
                'user': self.user.to_dict(),
                'act_con_path': act_con_path,
                'doc': doc.key.id() if doc else None,
                'page': 'project',
                'debug': self.client_debug,
                'check_auth': self.client_check_auth,
                'loader_configs': self.loader_configs,
                'open_chal': open_chal,
                'context_menu': context_menu,
                'an_token': self.analytic_session.key.id(),
                'debug_level': debug_level,
            }),
            'display_name':
            short_name,
            'project':
            self.project,
        }

        lr = tt_logging.construct_log(msg_short='Opened Project',
                                      log_type=tt_logging.USER,
                                      request=self.request,
                                      artifact=self.project,
                                      request_user=self.user)
        log.info(lr['dict_msg']['msg'], extra=lr)

        self.response.write(template_index.render(template_data))
Пример #9
0
    def get(self):
        agent = self.request.headers.get('user_agent')
        if agent.find('MSIE') != -1:
            browser = 'MSIE'
            template_index = JINJA_ENVIRONMENT.get_template('login_no_soop_for_you.html')
        elif agent.find('Firefox') != -1:
            browser = 'FIREFOX'
            template_index = JINJA_ENVIRONMENT.get_template('login.html')
        elif agent.find('Chrome') != -1:
            browser = 'CHROME'
            template_index = JINJA_ENVIRONMENT.get_template('login.html')
        else:
            browser = "UNKNOWN"
            template_index = JINJA_ENVIRONMENT.get_template('login.html')

        template_data = {
            'title': 'thinkTank',
            'browser': browser,
        }

        self.response.write(template_index.render(template_data))
Пример #10
0
 def get(self, organization=None):
     if not self.user.is_admin:
         raise HttpErrorException.forbidden()
     if organization:
         organization = Organization.get_by_id(organization)
         if not organization:
             raise HttpErrorException.bad_request('invalid org id')
     temp_data = {}
     if organization:
         temp_data['org'] = organization
     template_index = JINJA_ENVIRONMENT.get_template(
         'admin_panel/organization.html')
     self.response.write(template_index.render(temp_data))
Пример #11
0
 def get(self, organization=None):
     if organization:
         self.organization = Organization.get_by_id(organization)
         if not self.organization:
             raise HttpErrorException.bad_request('invalid organization id')
     if (not self.user.is_super_admin
             or (self.organization and not self.user.is_org_admin
                 and self.organization.key != self.user.organization)):
         raise HttpErrorException.forbidden()
     temp_data = {}
     template_index = JINJA_ENVIRONMENT.get_template(
         'admin_panel/thinktank/analytics.html')
     self.response.write(template_index.render(temp_data))
Пример #12
0
    def get(self, secret=None):
        if not secret:
            raise HttpErrorException.bad_request('no password secret given')

        user = User.query(User.password_reset_secret == secret).get()
        if not user:
            raise HttpErrorException.bad_request('could not find user for password reset')

        reset_url = ('/account/password/reset/' + user.password_reset_secret)
        template_data = {
            'title': 'Password Reset',
            'reset_url': reset_url,
        }

        template_index = JINJA_ENVIRONMENT.get_template('password_reset.html')
        self.response.write(template_index.render(template_data))
Пример #13
0
    def get(self, request=None):
        gc = GlobalConfig.get_configs()
        if not gc.allow_user_registration:
            self.redirect('/register/disabled/', abort=True)
            return

        coupon_code = self.request.get('coupon_code')
        coupon_obj = None

        if coupon_code != '':
            try:
                coupon_obj = coupon.Coupon.get_coupon(coupon_code.lower())
                if not coupon_obj.is_active():
                    raise HttpErrorException.bad_request('coupon is not active')
            except coupon.InvalidCouponCodeException:
                raise HttpErrorException.bad_request('invalid coupon code')

        payment_plans = payment_plan.get_payment_plan_list()
        pay_plan = self.request.get('payment_plan')

        if pay_plan != '':
            try:
                pay_plan = payment_plan.get_payment_plan(pay_plan)
            except payment_plan.InvalidPaymentPlanException as e:
                raise HttpErrorException.bad_request(e.message)
        else:
            pay_plan = payment_plans[0]

        template_data = {
            'title': 'thinkTank Registration',
            'nav_bar_title': 'thinkTank',
            'domain': self.request.host_url,
            'payment_plans': payment_plans,
            'active_payment_plan': pay_plan['id'],
        }

        if coupon_obj:
            template_data['coupon'] = coupon_code

        template_index = JINJA_ENVIRONMENT.get_template('register.html')
        self.response.write(template_index.render(template_data))
Пример #14
0
    def get(self, user_id=None):
        if not user_id:
            raise HttpErrorException.bad_request('no user id given')

        user = User.get_by_id(user_id)
        if not user:
            raise HttpErrorException.bad_request('invalid user id given')

        if user != self.user and not self.user.is_super_admin:
            lr = tt_logging.construct_log(
                msg_short='Non-Admin User try to Alter Another User\'s Billing',
                msg='User (%s) attemped to change another user\'s (%s) '
                    'billing information' % (self.user.key.id(), user.key.id()),
                log_type=tt_logging.SECURITY, request_user=self.user, affected_user=user,
                request=self.request
            )
            log.warning(lr['dict_msg']['msg'], extra=lr)
            raise HttpErrorException.forbidden()

        template_data = {
            'title': 'thinkTank',
            'display_name': self.user.display_name,
            'nav_bar_title': 'thinkTank',
            'domain': self.request.host_url,
            'payment_plans': payment_plan.get_payment_plan_list(),
            'data': {
                'user': json.dumps(self.user.to_dict(user=self.user))
            },
        }

        if user.is_billable_account():
            template_data['billable_account'] = True
        else:
            template_data['billable_account'] = False

        if user.is_admin:
            template_data['admin'] = True

        template_index = JINJA_ENVIRONMENT.get_template('user_billing.html')
        self.response.write(template_index.render(template_data))
Пример #15
0
    def get(self, username=None):
        if not username:
            raise HttpErrorException.bad_request('no username given')

        user = User.get_by_id(username)
        if not user:
            raise HttpErrorException.bad_request('invalid username given')
        if user != self.user:
            raise HttpErrorException.bad_request('Getting someone else user account info is not supported right now')

        template_data = {
            'title': 'thinkTank',
            'display_name': self.user.display_name,
            'nav_bar_title': 'thinkTank',
            'domain': self.request.host_url,
            'first_name': user.first_name,
            'last_name': user.last_name,
            'email': user.email,
            'main_phone': user.get_phone_number('main') if user.get_phone_number('main') else 'Main Phone',
            'cell_phone': user.get_phone_number('cell') if user.get_phone_number('cell') else 'Cell Phone',
            'birthday': user.birthday,
            'street1': user.address['street1'] if user.address else 'Street1',
            'street2': user.address['street2'] if user.address else 'Street2',
            'city': user.address['city'] if user.address else 'City',
            'state': user.address['state'] if user.address else 'State',
            'zipecode': user.address['zip_code'] if user.address else 'Zip Code',
            'spectra_count': self.user.spectra_count,
            'data': {
                'user': json.dumps(user.to_dict(user=self.user))
            },
        }

        if user.in_org():
            template_data['organization'] = True
        if user.is_admin:
            template_data['admin'] = True

        template_index = JINJA_ENVIRONMENT.get_template('user_profile.html')
        self.response.write(template_index.render(template_data))
Пример #16
0
    def _serve_worldshare_page(self, doc, act_con_path):
        template_index = JINJA_ENVIRONMENT.get_template(
            'worldshare_project.html')

        if not doc:
            doc = self.project.distilled_document.get()

        if doc.project != self.project.key:
            raise HttpErrorException.bad_request('invalid doc id given')

        if not doc.has_permission_read(self.user):
            self.redirect('/', abort=True)

        tree = False
        if self.request.get('tree') != '':
            if self.request.get('tree') == 'true':
                tree = True

        nav = True
        if self.request.get('nav') != '' and not tree and act_con_path is None:
            if self.request.get('nav') == 'false':
                nav = False

        depth = -1
        if self.request.get('depth') not in ['all', 'max', '']:
            depth = self._to_int(self.request.get('depth'))

        debug_level = 0
        if os.environ.get('SERVER_SOFTWARE', '').startswith('Development'):
            debug_level = 3
        try:
            debug_level = int(self.request.get('debug_level', debug_level))
        except ValueError:
            debug_level = 0

        template_data = {
            'data':
            json.dumps({
                'project': self.project.to_dict(self.user),
                'user': self.user.to_dict(),
                'act_con_path': act_con_path,
                'doc': doc.key.id(),
                'page': 'world',
                'tree': tree,
                'nav': nav,
                'depth': depth,
                'debug': self.client_debug,
                'check_auth': self.client_check_auth,
                'loader_configs': self.loader_configs,
                'an_token': self.analytic_session.key.id(),
                'debug_level': debug_level,
            }),
            'display_name':
            self.user.display_name,
            'tree':
            tree,
            'nav':
            nav,
        }

        self.response.write(template_index.render(template_data))
Пример #17
0
 def get(self):
     gc = GlobalConfig.get_configs()
     if gc.allow_non_admin_user_login:
         self.redirect('/', abort=True)
     template_index = JINJA_ENVIRONMENT.get_template('login_disabled.html')
     self.response.write(template_index.render())
Пример #18
0
 def get(self, username=None):
     template_index = JINJA_ENVIRONMENT.get_template('email_unverified.html')
     self.response.write(template_index.render())