Пример #1
0
    def set_lang(self, language, **kw):
        set_lang(language)

        if request.referrer is None:
            redirect('/')
        else:
            redirect(request.referrer)
Пример #2
0
 def index(self):
     """Handle the front-page."""
     set_lang("th"); 
     session['lang'] = "th";
     session.save();
     
     return dict(page='index')
Пример #3
0
    def index(self):
        reload(sys)
        sys.setdefaultencoding("utf-8")
        print "Index maintenance"
        """Handle the front-page."""
        set_lang("th")
        session['lang'] = "th"
        session.save()
        userid = ""
        sectionid = ""
        level = "1"
        #Admin;  0 user;
        if request.identity:
            userid = request.identity['repoze.who.userid']

            section = app_model.UserRiskSection.getByUserName(userid)
            if (section):
                sectionid = section.risk_section_id
                section = app_model.RiskSection.listBySectionbyId(sectionid)
                if (section):
                    userid = section.description
                    level = "0"

            print "section : " + str(sectionid)
        else:
            #redirect('/computer/add');
            pass

        log.info("computer")
        #print "user : " + str(userid);

        return dict(page='computer',
                    user=str(userid),
                    sectionid=str(sectionid),
                    level=level)
Пример #4
0
    def report2(self, **kw):
        reload(sys)
        sys.setdefaultencoding("utf-8")
        set_lang("th")
        session['lang'] = "th"
        session.save()

        year = self.util.isValue(kw.get('year'))
        disabledSelect = False
        sectionTeamId = 0
        log.info(year)
        if year is None:
            year = 2558

        listYear = self.util.getRangeYear(year)

        listHash = app_model.IndicatorsService.listReport2Indicator(year)

        #log_view_report
        self.saveLogView()

        return dict(page='indicator',
                    year=year,
                    listYear=listYear,
                    listHash=listHash)
Пример #5
0
 def report2(self,**kw):
     reload(sys);
     sys.setdefaultencoding("utf-8");
     set_lang("th");
     session['lang'] = "th";
     session.save();
     
     year = self.util.isValue(kw.get('year'));
     
     log.info(year);
     if year is None:
         year = self.defaultyear;
         
     listYear = self.util.getRangeYear(year);
             
     section=[];
     if(year):
         startDate = str(int(year)-543 -1) + '-10-01';
         stopDate = str(int(year)-543) + '-09-30';
         log.info(startDate);
         section = RiskManagement.listSectionReport(startDate,stopDate);
         #log_view_report
         self.saveLogView();
         
     return dict(page='risk',util=self.util,year=year,listYear = listYear,section = section);
Пример #6
0
 def index(self):
     reload(sys);
     sys.setdefaultencoding("utf-8");
     print "Index maintenance";
     """Handle the front-page."""
     set_lang("th"); 
     session['lang'] = "th";
     session.save();
     userid = "";
     sectionid ="";
     level = "1"; #Admin;  0 user;
     if request.identity:
         userid = request.identity['repoze.who.userid'];
         
         section = UserRiskSection.getByUserName(userid);
         if(section):
             sectionid = section.risk_section_id;
             section = RiskSection.listBySectionbyId(sectionid);
             if(section):
                 userid = section.description;
                 level = "0";
             
         print "section : " + str(sectionid);
     else:
         #redirect('/computer/add');
         pass;
     
     log.info("computer");
     #print "user : " + str(userid);
          
         
     return dict(page='computer',user=str(userid),sectionid=str(sectionid),level=level);
Пример #7
0
 def report1(self,**kw):
     reload(sys);
     sys.setdefaultencoding("utf-8");
     set_lang("th");
     session['lang'] = "th";
     session.save();
     
     year = self.util.isValue(kw.get('year'));
     
     self.team_id =  self.util.numValue( kw.get('team_id')) ; 
     
     log.info( "team id " + str(self.team_id) );
     
     disabledSelect = False;
     level = "1";
     userid = None;
     sectionTeamId = 0;
     sectionid = 0;
     if request.identity:
         userid = request.identity['repoze.who.userid'];
         section = UserRiskSection.getByUserName(userid);
         if(section):
             sectionid = section.risk_section_id;
             
             self.team_id =   sectionid;
            
             disabledSelect = True;
     else:
         userid = None;       
   
     log.info( "team id " + str(self.team_id) ); 
    
     
      
     if year is None:
         year = 2558;
         
     listYear = self.util.getRangeYear(year);
     
     self.teamName ="";
     
     self.listTeam = RiskSection.listAll();
     self.listTeamCrom = [];
     for temp in self.listTeam:
         if( int(self.team_id) == int(temp.risk_section_id)    ):
             self.teamName = temp.description;
             self.listTeamCrom.append( { "risk_team_id" : temp.risk_section_id ,  "description"  :temp.description , "selected" : True });
         else:
             self.listTeamCrom.append( { "risk_team_id" : temp.risk_section_id ,  "description"  :temp.description , "selected" : False });
    
    
     listHash =  IndicatorsService.listReport1Indicator(self.team_id,year);
    
     #log_view_report
     self.saveLogView();
      
     return dict(page='indicator',listteam = self.listTeamCrom,util=self.util,year=year ,listYear = listYear,teamName = self.teamName,disabledSelect =disabledSelect ,listHash=listHash  );   
Пример #8
0
    def _before(self, *args, **kw):
        tgl = request_local.context._current_obj()
        session_ = tgl.session
        if session_:
            current_lang = session_.get(tgl.config.get('lang_session_key', 'lang'))

            if not current_lang and tgl.config.has_key('lang'):
                i18n.set_lang(tgl.config.get('lang'))

        tmpl_context.project_name = _("parsidan")
Пример #9
0
    def index(self):
        print "Index maintenance"
        """Handle the front-page."""
        set_lang("th")
        session['lang'] = "th"
        session.save()
        userid = ""

        #print "user : " + str(userid);
        return dict(page='datacenter')
Пример #10
0
 def report1(self,**kw):
     reload(sys);
     sys.setdefaultencoding("utf-8");
     set_lang("th");
     session['lang'] = "th";
     session.save();
     
     year = self.util.isValue(kw.get('year'));
     
     month = self.util.isValue(kw.get('month'));
     
     log.info("risk");
     listMonth =[];
     listMonth.append({'id':'1','value':'มกราคม'});
     listMonth.append({'id':'2','value':'กุมภาพันธ์'});
     listMonth.append({'id':'3','value':'มีนาคม'});
     listMonth.append({'id':'4','value':'เมษายน'});
     listMonth.append({'id':'5','value':'พฤษภาคม'});
     listMonth.append({'id':'6','value':'มิถุนายน'});
     listMonth.append({'id':'7','value':'กรกฎาคม'});
     listMonth.append({'id':'8','value':'สิงหาคม'});
     listMonth.append({'id':'9','value':'กันยายน'});
     listMonth.append({'id':'10','value':'ตุลาคม'});
     listMonth.append({'id':'11','value':'พฤศจิกายน'});
     listMonth.append({'id':'12','value':'ธันวาคม'});
     
     log.info(year);
     if year is None:
         year = 2558;
         
     listYear = self.util.getRangeYear(year);
     print listYear;
     
     section = None;
     pro_clinic = None;
     pro_physic = None;
     priority10 =None;
     if (month and year):
         print month;
         print year;
         date = '1/'+str(month)+'/'+str(int(year)-543);
         startDate = util.convertStringToDate(date);
         stopDate = util.last_day_of_month(startDate);
         
         startDate = startDate.strftime("%Y-%m-%d");
         stopDate = stopDate.strftime("%Y-%m-%d");
          
     
         section = RiskManagement.showSumSectionReport(startDate,stopDate);
         pro_clinic = RiskManagement.showProgramClinicReport(startDate,stopDate,1);
         pro_physic = RiskManagement.showProgramClinicReport(startDate,stopDate,2);
         priority10 = RiskManagement.listRiskPriority10(startDate,stopDate);
      
     return dict(page='risk',util=self.util,year=year,month=month,listMonth=listMonth,listYear = listYear,section=section,pro_clinic=pro_clinic ,pro_physic=pro_physic,priority10=priority10);
Пример #11
0
def init_lang():
    default_lang = extract_lang(get_lang(), r'^[a-z]{2}$')
    _language = config.get('app.language_cookie', 'sp_language')
    lang = request.cookies.get(_language)
    if not lang:
        lang = default_lang
        save_language(lang)

    set_lang(lang)

    return lang
Пример #12
0
 def summary(self):
     print "Index maintenance"
     """Handle the front-page."""
     set_lang("th")
     session['lang'] = "th"
     session.save()
     userid = ""
     if request.identity:
         userid = request.identity['repoze.who.userid']
         #print "user : " + str(userid);
     return dict(page='project_summary')
Пример #13
0
 def index(self):
     print "Index maintenance";
     """Handle the front-page."""
     set_lang("th"); 
     session['lang'] = "th";
     session.save();
     userid = "";
     if request.identity:
         userid = request.identity['repoze.who.userid']
         print "user : " + str(userid);
     return dict(page='index')
Пример #14
0
def init_lang():
    default_lang = extract_lang(get_lang(), r'^[a-z]{2}$')
    _language = config.get('app.language_cookie', 'sp_language') 
    lang = request.cookies.get(_language)
    if not lang:
        lang = default_lang
        save_language(lang)
        
    set_lang(lang)
    
    return lang
Пример #15
0
 def index(self):
     print "Index maintenance";
     """Handle the front-page."""
     set_lang("th"); 
     session['lang'] = "th";
     session.save();
     userid = "";
     if request.identity:
         userid = request.identity['repoze.who.userid']
         print "user : " + str(userid);
     return dict(page='index')
Пример #16
0
    def index(self):
        print "Index maintenance"
        """Handle the front-page."""
        set_lang("th")
        session['lang'] = "th"
        session.save()
        userid = ""
        if request.identity:
            userid = request.identity['repoze.who.userid']
        else:
            redirect('/project/summary')

        log.info("project")
        #print "user : " + str(userid);
        return dict(page='project')
Пример #17
0
 def index(self):
     print "Index revenue";
     """Handle the front-page."""
     set_lang("th"); 
     session['lang'] = "th";
     session.save();
     userid = "";
     if request.identity:
         userid = request.identity['repoze.who.userid']
   #  else:
   #      redirect('/revenue/summary');
         
     
     log.info("dental");
         #print "user : " + str(userid);
     return dict(page='dental');
Пример #18
0
 def index(self):
     print "Index maintenance";
     """Handle the front-page."""
     set_lang("th"); 
     session['lang'] = "th";
     session.save();
     userid = "";
     if request.identity:
         userid = request.identity['repoze.who.userid']
     else:
         redirect('/expend/summary');
         
     
     log.info("revenue");
         #print "user : " + str(userid);
     return dict(page='expend');
Пример #19
0
    def add(self):
        reload(sys)
        sys.setdefaultencoding("utf-8")
        set_lang("th")
        session['lang'] = "th"
        session.save()

        sectionid = ""
        userid = ""
        level = "1"
        #Admin;  0 user;

        if request.identity:
            userid = request.identity['repoze.who.userid']

            section = app_model.UserRiskSection.getByUserName(userid)
            if (section):
                sectionid = section.risk_section_id
                section = app_model.RiskSection.listBySectionbyId(sectionid)
                if (section):
                    userid = section.description
                    level = "0"

            print "section : " + str(sectionid)
        else:
            redirect('/indicator/')

        log.info("indicator")

        dates = datetime.now()
        dyear = dates.strftime("%Y")
        dmonth = dates.strftime("%m")

        #if(dmonth >= 10):
        #    dyear = int(dyear) + 1;

        year = str(int(dyear) + 543)
        month = str(dmonth)
        #log.info("year : " + str(year) );
        #log.info("month : " + str(month) );
        return dict(page='indicator',
                    user=str(userid),
                    sectionid=str(sectionid),
                    level=level,
                    year=year,
                    month=month)
Пример #20
0
 def listIndicatorBySection(self,**kw):
     reload(sys);
     sys.setdefaultencoding("utf-8");
     set_lang("th"); 
     session['lang'] = "th";
     session.save();
     
     sectionid = self.util.isValue(kw.get('riskSection'));
     years_id = self.util.isValue(kw.get('year'));
     months_id = self.util.isValue(kw.get('month'));
     start_year = self.util.isValue(kw.get('year'));
     
     print sectionid;
     print years_id;
     print months_id;
     
     
     dates = datetime.now();
     dyear = dates.strftime("%Y");
     dmonth = dates.strftime("%m");
     
     if(years_id is None):
         years_id =str( int(dyear) + 543  );
    
     if (months_id is None):
        months_id = str(dmonth);
    
     
     session['months_id'] = months_id;
     session['years_id'] = years_id;
     session.save();
     
     #sectionid = 2;
     #years_id = 2556;
     #months_id = 11;
     
     #if ( int(months_id) >9 ) :
      #   #years_id = int(years_id) + 1;
     #    years_id = int(years_id) - 1;
     
     #log.info(str(years_id));
     
     self.List = IndicatorsService.listIndicatorBySection(sectionid , years_id,start_year, months_id);
     
     return dict(root = self.List,total=str(len(self.List)));
Пример #21
0
    def listIndicatorBySection(self, **kw):
        reload(sys)
        sys.setdefaultencoding("utf-8")
        set_lang("th")
        session['lang'] = "th"
        session.save()

        sectionid = self.util.isValue(kw.get('riskSection'))
        years_id = self.util.isValue(kw.get('year'))
        months_id = self.util.isValue(kw.get('month'))
        start_year = self.util.isValue(kw.get('year'))

        print sectionid
        print years_id
        print months_id

        dates = datetime.now()
        dyear = dates.strftime("%Y")
        dmonth = dates.strftime("%m")

        if (years_id is None):
            years_id = str(int(dyear) + 543)

        if (months_id is None):
            months_id = str(dmonth)

        session['months_id'] = months_id
        session['years_id'] = years_id
        session.save()

        #sectionid = 2;
        #years_id = 2556;
        #months_id = 11;

        #if ( int(months_id) >9 ) :
        #   #years_id = int(years_id) + 1;
        #    years_id = int(years_id) - 1;

        #log.info(str(years_id));

        self.List = app_model.IndicatorsService.listIndicatorBySection(
            sectionid, years_id, start_year, months_id)

        return dict(root=self.List, total=str(len(self.List)))
Пример #22
0
    def add(self):
        reload(sys);
        sys.setdefaultencoding("utf-8");
        set_lang("th"); 
        session['lang'] = "th";
        session.save();
        
        sectionid ="";
        userid = "";
        level = "1"; #Admin;  0 user;
        
        if request.identity:
            userid = request.identity['repoze.who.userid'];
            
            section = UserRiskSection.getByUserName(userid);
            if(section):
                sectionid = section.risk_section_id;
                section = RiskSection.listBySectionbyId(sectionid);
                if(section):
                    userid = section.description;
                    level = "0";
                
            print "section : " + str(sectionid);
        else:
            redirect('/indicator/');
        
        log.info("indicator");
        
        dates = datetime.now();
        dyear = dates.strftime("%Y");
        dmonth = dates.strftime("%m");

        #if(dmonth >= 10):
        #    dyear = int(dyear) + 1;

        
        year =str( int(dyear) + 543  );
        month =  str(dmonth);  
        #log.info("year : " + str(year) );
        #log.info("month : " + str(month) );
        return dict(page='indicator',user=str(userid),sectionid=str(sectionid),level=level,year = year,month = month);
Пример #23
0
 def index(self):
     reload(sys);
     sys.setdefaultencoding("utf-8");
     print "Index maintenance";
     """Handle the front-page."""
     set_lang("th"); 
     session['lang'] = "th";
     session.save();
     userid = "";
     sectionid ="";
     level = "1"; #Admin;  0 user;
     user_display ="";
     ip=request.environ.get("X_FORWARDED_FOR", request.environ["REMOTE_ADDR"]);
     print ip;
     
     if request.identity:
         userid = request.identity['repoze.who.userid'];
         user_login = User.by_user_name(userid);
         section = UserRiskSection.getByUserName(userid);
         if(section):
             sectionid = section.risk_section_id;
             #display =section.display_name;
             section = RiskSection.listBySectionbyId(sectionid);
             if(section):
                 userid = section.description;
                 level = "0";
             #else:
             #    userid = display;
         
         user_display = user_login.display_name;
         print "section : " + str(sectionid);
     else:
         redirect('/risk/add');
     
     log.info("risk");
     #print "user : " + str(userid);
          
         
     return dict(page='risk',user=str(userid),user_display= str(user_display),sectionid=str(sectionid),level=level);
Пример #24
0
 def report2(self,**kw):
     reload(sys);
     sys.setdefaultencoding("utf-8");
     set_lang("th");
     session['lang'] = "th";
     session.save();
     
     year = self.util.isValue(kw.get('year'));
     disabledSelect = False;
     sectionTeamId = 0;
     log.info(year);
     if year is None:
         year = 2558;
         
     listYear = self.util.getRangeYear(year);
    
     listHash =  IndicatorsService.listReport2Indicator(year);
    
     #log_view_report
     self.saveLogView();
      
     return dict(page='indicator',util=self.util,year=year ,listYear = listYear,  listHash=listHash  );   
Пример #25
0
 def force_german(self, **kw):
     i18n.set_lang('de')
     return 'OK'
Пример #26
0
 def mainreport(self):
     set_lang("th");
     session['lang'] = "th";
     session.save();
     log.info("risk");
     return dict(page='risk');
Пример #27
0
 def add(self):
     set_lang("th");
     session['lang'] = "th";
     session.save();
     log.info("risk");
     return dict(page='risk',user='',sectionid='',level=0);
Пример #28
0
  def report5(self,**kw):
      
      reload(sys);
      sys.setdefaultencoding("utf-8");
      set_lang("th");
      session['lang'] = "th";
      session.save();
      
      sectionListTeam = None;
      sectionTeamId = 0;
      disabledSelect = False;
      userid = None;
      level = "1";
      
      self.team_id =  self.util.numValue( kw.get('team_id')) ;        
      self.datepickerStart =   self.util.isValue(kw.get('datepickerStart') );
      self.datepickerStop =   self.util.isValue(kw.get('datepickerStop') ); 
      
      #search section team id 
      if request.identity:
          userid = request.identity['repoze.who.userid'];
          section = UserRiskSection.getByUserName(userid);
          if(section):
              sectionid = section.risk_section_id;
              section = RiskSection.listBySectionbyId(sectionid);
              if(section):
                  userid = section.description;
                  level = "0";
                  sectionListTeam = SectionListTeam.getSectionBySectionId(section.risk_section_id);
                  sectionTeamId = sectionListTeam.risk_team_id;
                  self.team_id = sectionTeamId;
                  disabledSelect = True;
      else:
          userid = None;       
      
      
      #convert date
      if( self.datepickerStart and self.datepickerStop) :
          self.datepickerStart  = self.util.convertStringDateToString(  self.datepickerStart,  "%Y-%m-%d") ;
          self.datepickerStop =self.util.convertStringDateToString( self.datepickerStop,  "%Y-%m-%d");
      else:
          if(self.datepickerStart ):
              self.datepickerStart  = self.util.convertStringDateToString(  self.datepickerStart,  "%Y-%m-%d") ;
          if(self.datepickerStop ): 
              self.datepickerStop =self.util.convertStringDateToString( self.datepickerStop,  "%Y-%m-%d");
          if(self.datepickerStart is None and self.datepickerStop is None) :
              self.datepickerStart  = self.util.convertStringDateToString(  self.datepickerStart,  "%Y-%m-%d") ;
              self.datepickerStop =self.util.convertStringDateToString( self.datepickerStop,  "%Y-%m-%d");
      
      
      #find listteam
      self.listTeam = RiskTeam.listTeamCrom();
      
      self.listTeamCrom = [];
      self.teamName = "";
      self.listRiskTeamCrom = []
      
      for temp in self.listTeam:
          if( int(self.team_id) == int(temp.risk_team_id)  or int(sectionTeamId) == int(temp.risk_team_id) ):
              self.teamName = temp.description;
              self.listTeamCrom.append( { "risk_team_id" : temp.risk_team_id ,  "description"  :temp.description , "selected" : True });
          else:
              self.listTeamCrom.append( { "risk_team_id" : temp.risk_team_id ,  "description"  :temp.description , "selected" : False });
     
     #search risk in team crom
      if self.team_id :            
          self.listRiskTeamCrom = RiskManagement.showRiskRespTeamCromManage(self.team_id, self.datepickerStart, self.datepickerStop);          
 
      
      #log_view_report
      self.saveLogView();
          
      
      return dict(listteam = self.listTeamCrom,disabledSelect =disabledSelect, level = level ,util=self.util,teamName = self.teamName , start = self.datepickerStart , stop = self.datepickerStop, riskTeamCrom = self.listRiskTeamCrom  );
Пример #29
0
    def index(self, status=None, interest=None, recruiter=None, **kw):
        set_lang('it')

        rstatus = [
            {"value": "none", "text": "Da decidere"},
            {"value": "approved", "text": "Approvato"},
            {"value": "rejected", "text": "Scartato"},
            {"value": "contact", "text": "Da contattare"},
            {"value": "done", "text": "Contattato"}
        ]

        interests = [
            {"value": "hardware", "text": "Riparazione Hardware"},
            {"value": "electronics", "text": "Elettronica"},
            {"value": "software", "text": "Sviluppo Software"},
            {"value": "sysadmin", "text": "Sysadmin"},
            {"value": "designvc", "text": "Design e comunicazione visiva"},
            {"value": "designreuse", "text": "Design per il riuso"},
            {"value": "publicrel", "text": "Pubbliche relazioni"},
            {"value": "other", "text": "Altro"}
        ]

        recruiters = DBSession.query(Recruiter).all()

        if status == 'none':
            users = DBSession.query(User).filter(User.user_id != 1).filter_by(status=None).all()
        elif status == 'approved':
            users = DBSession.query(User).filter(User.user_id != 1) \
                .filter_by(status=True).filter_by(published=False).all()
        elif status == 'rejected':
            users = DBSession.query(User).filter(User.user_id != 1).filter_by(status=False).all()
        elif status == 'contact':
            users = DBSession.query(User).filter(User.user_id != 1) \
                .filter_by(status=True) \
                .filter_by(published=True) \
                .filter_by(recruiter=None).all()
        elif status == 'done':
            users = DBSession.query(User).filter(User.user_id != 1) \
                .filter_by(status=True) \
                .filter_by(published=True) \
                .filter(User.recruiter).all()
        else:
            users = DBSession.query(User).filter(User.user_id != 1).all()

        if interest:
            interest = next((i for i in interests if i['value'] == interest))['text']
            users = [u for u in users if u.interest == interest]

        if recruiter:
            recruiter = Recruiter.by_id(recruiter)
            users = [u for u in users if u.recruiter == recruiter]

        counter = len(users)
        notify = Option.get_value('new_request_notify')
        recruiting = Option.get_value('recruiting')
        return dict(page='soviet-index',
                    users=users,
                    interests=interests,
                    rstatus=rstatus,
                    recruiters=recruiters,
                    counter=counter,
                    notify=notify,
                    recruiting=recruiting
                    )
Пример #30
0
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        # TGController.__call__ dispatches to the Controller method
        # the request is routed to. This routing information is
        # available in environ['pylons.routes_dict']

        identity = request.environ.get('repoze.who.identity')
        request.identity = identity
        tmpl_context.identity = identity
        tmpl_context.user = identity and identity['user'] or False

        # get settings from the db
        settings = dict([(s.id, s.value) for s in DBSession.query(Setting)])

        # set theme, title and copyright notice
        tmpl_context.theme = (settings.get('theme') or
                              config.get('theme') or
                              'default'
                             )
        tmpl_context.title = (settings.get('title') or
                              config.get('title', '').strip('\"') or
                              ''
                             )
        tmpl_context.copyright = (settings.get('copyright') or
                                  config.get('copyright', '').strip('\"') or
                                  ''
                                 )
        tmpl_context.cc = (settings.get('cc') or
                           config.get('cc', '').strip('\"') or
                           ''
                          )

        # load javascripts
        jquery_js.inject()
        jquery_tools_js.inject()
        tagger_js.inject()
        springs_js.inject()
        mjs_js.inject()

        # add languages and categories to template context (used in the header)
        tmpl_context.languages = DBSession.query(Language)
        tmpl_context.categories = DBSession.query(Category)

        # set language
        if 'lang' in request.cookies:
            tmpl_context.lang = request.cookies['lang']
            i18n.set_lang(tmpl_context.lang)
        else:
            tmpl_context.lang = config.get('lang', None)
            i18n.set_lang(None)

        # add current url to template context
        tmpl_context.current_url = request.url

        # set logo
        l_mediaid = settings.get(u'logo_media', None)
        l_media = l_mediaid and DBSession.query(Media).get(l_mediaid)
        l_mediaurl = l_media and url('/%s/%s' % (G.upload_prefix, l_media.uri))
        tmpl_context.logo_mediaurl = l_mediaurl

        # set banner link and background image
        tmpl_context.w_link = w_link
        tmpl_context.w_media = w_media
        tmpl_context.banner_linkid = settings.get(u'banner_link', None)
        b_mediaid = settings.get(u'banner_media', None)
        b_media = b_mediaid and DBSession.query(Media).get(b_mediaid)
        b_mediaurl = b_media and url('/%s/%s' % (G.upload_prefix, b_media.uri))
        tmpl_context.banner_mediaurl = b_mediaurl

        # add Sidebar widgets
        tmpl_context.w_sideobj = w_sideobj

        return TGController.__call__(self, environ, start_response)
Пример #31
0
 def setlang(self, lang, came_from=lurl('/')):
     if lang:
         set_lang(lang)
     redirect(came_from)
Пример #32
0
 def setlang(self, lang='en'):
     save_language(lang)
     set_lang(lang)
Пример #33
0
    def report1(self, **kw):
        reload(sys)
        sys.setdefaultencoding("utf-8")
        set_lang("th")
        session['lang'] = "th"
        session.save()

        year = self.util.isValue(kw.get('year'))
        print "year : %s" % year
        self.team_id = self.util.numValue(kw.get('team_id'))

        log.info("team id " + str(self.team_id))

        disabledSelect = False
        level = "1"
        userid = None
        sectionTeamId = 0
        sectionid = 0
        if request.identity:
            userid = request.identity['repoze.who.userid']
            section = app_model.UserRiskSection.getByUserName(userid)
            if (section):
                sectionid = section.risk_section_id

                self.team_id = sectionid

                disabledSelect = True
        else:
            userid = None

        log.info("team id " + str(self.team_id))

        if year is None:
            year = 2558

        listYear = self.util.getRangeYear(year)

        self.teamName = ""

        self.listTeam = app_model.RiskSection.listAll()
        self.listTeamCrom = []
        for temp in self.listTeam:
            if (int(self.team_id) == int(temp.risk_section_id)):
                self.teamName = temp.description
                self.listTeamCrom.append({
                    "risk_team_id": temp.risk_section_id,
                    "description": temp.description,
                    "selected": True
                })
            else:
                self.listTeamCrom.append({
                    "risk_team_id": temp.risk_section_id,
                    "description": temp.description,
                    "selected": False
                })

        listHash = app_model.IndicatorsService.listReport1Indicator(
            self.team_id, year)

        #log_view_report
        self.saveLogView()

        return dict(page='indicator',
                    listteam=self.listTeamCrom,
                    util=self.util,
                    year=year,
                    listYear=listYear,
                    teamName=self.teamName,
                    disabledSelect=disabledSelect,
                    listHash=listHash)
Пример #34
0
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        # TGController.__call__ dispatches to the Controller method
        # the request is routed to. This routing information is
        # available in environ['pylons.routes_dict']

        identity = request.environ.get('repoze.who.identity')
        request.identity = identity
        tmpl_context.identity = identity
        tmpl_context.user = identity and identity['user'] or False

        # get settings from the db
        settings = dict([(s.id, s.value) for s in DBSession.query(Setting)])

        # set theme, title and copyright notice
        tmpl_context.theme = (settings.get('theme') or config.get('theme')
                              or 'default')
        tmpl_context.title = (settings.get('title')
                              or config.get('title', '').strip('\"') or '')
        tmpl_context.copyright = (settings.get('copyright')
                                  or config.get('copyright', '').strip('\"')
                                  or '')
        tmpl_context.cc = (settings.get('cc')
                           or config.get('cc', '').strip('\"') or '')

        # load javascripts
        jquery_js.inject()
        jquery_tools_js.inject()
        tagger_js.inject()
        springs_js.inject()
        mjs_js.inject()

        # add languages and categories to template context (used in the header)
        tmpl_context.languages = DBSession.query(Language)
        tmpl_context.categories = DBSession.query(Category)

        # set language
        if 'lang' in request.cookies:
            tmpl_context.lang = request.cookies['lang']
            i18n.set_lang(tmpl_context.lang)
        else:
            tmpl_context.lang = config.get('lang', None)
            i18n.set_lang(None)

        # add current url to template context
        tmpl_context.current_url = request.url

        # set logo
        l_mediaid = settings.get(u'logo_media', None)
        l_media = l_mediaid and DBSession.query(Media).get(l_mediaid)
        l_mediaurl = l_media and url('/%s/%s' % (G.upload_prefix, l_media.uri))
        tmpl_context.logo_mediaurl = l_mediaurl

        # set banner link and background image
        tmpl_context.w_link = w_link
        tmpl_context.w_media = w_media
        tmpl_context.banner_linkid = settings.get(u'banner_link', None)
        b_mediaid = settings.get(u'banner_media', None)
        b_media = b_mediaid and DBSession.query(Media).get(b_mediaid)
        b_mediaurl = b_media and url('/%s/%s' % (G.upload_prefix, b_media.uri))
        tmpl_context.banner_mediaurl = b_mediaurl

        # add Sidebar widgets
        tmpl_context.w_sideobj = w_sideobj

        return TGController.__call__(self, environ, start_response)
Пример #35
0
 def setlang(self, lang='en'):
     save_language(lang)
     set_lang(lang)
Пример #36
0
 def report4(self,**kw):
     reload(sys);
     sys.setdefaultencoding("utf-8");
     set_lang("th");
     session['lang'] = "th";
     session.save();
     
     year = self.util.isValue(kw.get('year'));
     
     log.info(year);
     if year is None:
         year = self.defaultyear;
         
     listYear = self.util.getRangeYear(year);
             
     section=[];
     self.listSectionTeam = [];
     if(year):
         
         self.riskSectionTeam = RiskTeam.listTeam(2);
         
         row=1;
         for sectionTeam in self.riskSectionTeam:
             self.listSectionTeam.append({'row':row,'risk_team_id':sectionTeam.risk_team_id ,
                                          'description':sectionTeam.description,
                                          'reported1':0,'total1':0,'reported2':0,'total2':0,
                                          'reported3':0,'total3':0,'reported4':0,'total4':0,
                                          'reported5':0,'total5':0,'reported6':0,'total6':0,
                                          'reported7':0,'total7':0,'reported8':0,'total8':0,
                                          'reported9':0,'total9':0,'reported10':0,'total10':0,
                                          'reported11':0,'total11':0,'reported12':0,'total12':0 ,
                                          'total_reported':0 ,'total':0});
             row = row+1;
                                     
         
         log.info("leng : " + str(len(self.listSectionTeam)));                            
         for month in range(10,13) :
             
             date = '1/'+str(month)+'/'+str(int(year)-543 - 1);
             log.info("start : " + date);
             startDate = util.convertStringToDate(date);
             stopDate = util.last_day_of_month(startDate);
             
             startDate = startDate.strftime("%Y-%m-%d");
             stopDate = stopDate.strftime("%Y-%m-%d");
              
             section = RiskManagement.listSectionReported(startDate,stopDate);
             
             
             for sec in section:
                 for secTeam in self.listSectionTeam:
                     if(str(sec.get('risk_team_id')) == str(secTeam.get('risk_team_id'))):
                         log.info("same11111111");
                         secTeam['reported'+str(month) ] = sec.get('reported')  ;
                         secTeam['total'+ str(month)]   = sec.get('total')   ;
                         break;
                     
         for month in range(1,10) :
             
             date = '1/'+str(month)+'/'+str(int(year)-543);
             log.info("start : " + date);
             startDate = util.convertStringToDate(date);
             stopDate = util.last_day_of_month(startDate);
             
             startDate = startDate.strftime("%Y-%m-%d");
             stopDate = stopDate.strftime("%Y-%m-%d");
              
             section = RiskManagement.listSectionReported(startDate,stopDate);
             
             
             for sec in section:
                 for secTeam in self.listSectionTeam:
                     if(str(sec.get('risk_team_id')) == str(secTeam.get('risk_team_id'))):
                         log.info("same11111111");
                         secTeam['reported'+str(month) ] = sec.get('reported')  ;
                         secTeam['total'+ str(month)]   = sec.get('total')   ;
                         break; 
                          
         
         for secTeam in self.listSectionTeam:
                 secTeam['total_reported']= int(secTeam['reported1'])+int(secTeam['reported2'])+int(secTeam['reported3'])+int(secTeam['reported4'])+int(secTeam['reported5'])+int(secTeam['reported6'])+int(secTeam['reported7'])+int(secTeam['reported8'])+int(secTeam['reported9'])+int(secTeam['reported10'])+int(secTeam['reported11'])+int(secTeam['reported12']);
                 secTeam['total']= int(secTeam['total1'])+int(secTeam['total2'])+int(secTeam['total3'])+int(secTeam['total4'])+int(secTeam['total5'])+int(secTeam['total6'])+int(secTeam['total7'])+int(secTeam['total8'])+int(secTeam['total9'])+int(secTeam['total10'])+int(secTeam['total11'])+int(secTeam['total12']);
         
          
         #log_view_report
         self.saveLogView();
         
         
     return dict(page='risk',util=self.util,year=year,listYear = listYear,section = self.listSectionTeam);
Пример #37
0
 def force_german(self, **kw):
     i18n.set_lang('de')
     return 'OK'
Пример #38
0
 def lang(self, l, came_from=lurl('/')):
     """Changes the language for the current session"""
     set_lang(l)
     return redirect(came_from)