Example #1
0
 def MakeLinksAllAreas(self):
     q = PrivateArea.query()
     for pa in q.iter():
         logging.info("Kicking off the make links for private area: " +
                      pa.name)
         namespace_manager.set_namespace(pa.name)
         self.MakeLinks()
Example #2
0
    def get(self):
        mode = self.request.get('mode')

        bigMessage = []

        namespace_manager.set_namespace('')
        namespaces = PrivateArea.query()
        for pa in namespaces.iter():
            logging.info("Looking at private area: " + pa.name)
            bigMessage = bigMessage + self.checkNamespace(pa.name)
        bigMessage = bigMessage + self.checkNamespace('')

        template_values = {
            'messages': bigMessage,
            'user': self.current_user,
            'currentArea': self.session.get('currentArea')
        }

        if mode and mode == 'screen':
            self.response.out.write(
                self.template_render('message.html', template_values))
        else:
            path = os.path.join(os.path.dirname(__file__),
                                '../templates/dbcheck.html')

            # old version, delete once the new version is working:
            # mail.send_mail(sender='*****@*****.**',
            #    to='*****@*****.**',
            #    subject='Database Integrity Check Results %s' % str(PST.convert(datetime.datetime.now())),
            #    html=template.render(path, template_values),
            #    body=str(bigMessage),
            #    reply_to="*****@*****.**"
            #    )

            # new version:
            message = mail.EmailMessage(
                sender='*****@*****.**',
                to='*****@*****.**',
                cc='*****@*****.**',
                subject='Database Integrity Check Results %s' %
                str(PST.convert(datetime.datetime.now())),
                body=str(bigMessage),
                reply_to="*****@*****.**")
            if html:
                message.html = template.render(path, template_values),
            message.send()
            # (end of new version)

            self.queueNightlyTask()
            template_values = {
                'message': "Sent email successfully. Queued nightly task.",
                'user': self.current_user,
                'currentArea': self.session.get('currentArea')
            }
            self.response.out.write(
                self.template_render('message.html', template_values))
Example #3
0
    def get(self):
        userNamespace = namespace_manager.get_namespace()
        namespace_manager.set_namespace('')

        user = self.current_user
        if user is None:
            self.response.out.write('Need to login.')
            return

        if not user.isAdmin:
            self.response.out.write('User not authorized.')
            return

        queryUsr = WhysaurusUser.query().order(-WhysaurusUser.lastLogin)
        areas = PrivateArea.query()
        users = []
        i = 0
        for yUser in queryUsr.iter():
            users = users + [{
                'u': yUser,
                'index': i,
                'userKey': yUser.key.urlsafe()
            }]
            i = i + 1

        paginator = Paginator(users, self.USERS_PER_PAGE)
        page = self.request.get('page')

        try:
            paginatedUsers = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            paginatedUsers = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            paginatedUsers = paginator.page(paginator.num_pages)

        template_values = {
            'user': user,
            'users': paginatedUsers,
            'areas': areas,
            'currentArea': self.session.get('currentArea'),
            'currentAreaDisplayName':
            self.session.get('currentAreaDisplayName')
        }

        self.response.out.write(
            self.template_render('admin.html', template_values))

        namespace_manager.set_namespace(userNamespace)
Example #4
0
    def get(self):
        userNamespace = namespace_manager.get_namespace()        
        namespace_manager.set_namespace('')
   
        user = self.current_user
        if user is None:
            self.response.out.write('Need to login.')
            return

        if not user.isAdmin:
            self.response.out.write('User not authorized.')
            return

        queryUsr = WhysaurusUser.query().order(-WhysaurusUser.lastLogin)
        areas = PrivateArea.query()
        users = []
        i = 0
        for yUser in queryUsr.iter():
            users = users + [{'u':yUser, 'index':i, 'userKey': yUser.key.urlsafe()}]
            i = i+1
            
        paginator = Paginator(users, 25) 
        page = self.request.get('page')

        try:
            paginatedUsers = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            paginatedUsers = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            paginatedUsers = paginator.page(paginator.num_pages)

            
        template_values = {
            'user': user,
            'users': paginatedUsers,
            'areas': areas,
            'currentArea':self.session.get('currentArea'),
            'currentAreaDisplayName':self.session.get('currentAreaDisplayName')
        }

        self.response.out.write(
            self.template_render('admin.html', template_values))

        namespace_manager.set_namespace(userNamespace)  
Example #5
0
    def uploadUserPage(self):

        userNamespace = namespace_manager.get_namespace()        
        namespace_manager.set_namespace('')

        areas = PrivateArea.query()        
        user = self.current_user

        template_values = {
            'user': user,
            'areas':areas,
            'currentArea':self.session.get('currentArea'),
            'currentAreaDisplayName':self.session.get('currentAreaDisplayName')
        }
        if user and user.isAdmin:                
            self.response.out.write(
                self.template_render('uploadUsers.html', template_values)) 
        else:
            self.response.out.write('User not authorized. ')
            
        namespace_manager.set_namespace(userNamespace)       
    def get(self):
        user = self.current_user
        queryUsr = WhysaurusUser.query()
        areas = PrivateArea.query().fetch(50)
        users = []
        i = 0
        for yUser in queryUsr.iter():            
            users = users + [{'u':yUser, 'index':i, 'userKey': yUser.key.urlsafe()}]
            i = i+1
        template_values = {
            'user': user,
            'users': users,
            'areas': areas,
            'currentArea':self.session.get('currentArea')
        }

        if user and user.admin:                
            path = os.path.join(constants.ROOT, 'templates/admin.html')
            self.response.out.write(template.render(path, template_values)) 
        else:
            self.response.out.write('User not authorized. ')
    def get(self):
        mode = self.request.get('mode')     

        bigMessage = []
        
        namespace_manager.set_namespace('') 
        namespaces = PrivateArea.query()
        for pa in namespaces.iter():
            logging.info("Looking at private area: " + pa.name)
            bigMessage = bigMessage + self.checkNamespace(pa.name)
        bigMessage = bigMessage + self.checkNamespace('')
         
        template_values = {
            'messages': bigMessage,
            'user': self.current_user,
            'currentArea':self.session.get('currentArea')
        }
                

        if mode and mode == 'screen':
            path = os.path.join(os.path.dirname(__file__), '../templates/message.html')
            self.response.out.write(template.render(path, template_values))
        else:
            path = os.path.join(os.path.dirname(__file__), '../templates/dbcheck.html')
            mail.send_mail(sender='*****@*****.**',
                to='*****@*****.**',
                subject='Database Integrity Check Results %s' % str(PST.convert(datetime.datetime.now())),
                html=template.render(path, template_values),
                body=str(bigMessage),
                reply_to="*****@*****.**"
                )
            self.queueNightlyTask()
            template_values = {
                'message': "Sent email successfully. Queued nightly task.",
                'user': self.current_user,
                'currentArea':self.session.get('currentArea')
            }
            path = os.path.join(os.path.dirname(__file__), '../templates/message.html')
            self.response.out.write(template.render(path, template_values))
Example #8
0
 def MakeLinksAllAreas(self):
     q = PrivateArea.query()
     for pa in q.iter():
         logging.info("Kicking off the make links for private area: " + pa.name)
         namespace_manager.set_namespace(pa.name)         
         self.MakeLinks()