from time import sleep, time from pyramid.view import view_config from pyramid.renderers import render from intranet3.utils.views import BaseView from intranet3.models import User, TimeEntry, Tracker, TrackerCredentials, Project, Client, ApplicationConfig from intranet3.forms.times import ProjectsTimeForm, TimeEntryForm from intranet3.asyncfetchers import get_fetcher from intranet3.helpers import groupby, partition from intranet3.log import INFO_LOG, WARN_LOG, ERROR_LOG, DEBUG_LOG, EXCEPTION_LOG from intranet3.lib.times import TimesReportMixin, HTMLRow, dump_entries_to_excel LOG = INFO_LOG(__name__) WARN = WARN_LOG(__name__) ERROR = ERROR_LOG(__name__) DEBUG = DEBUG_LOG(__name__) EXCEPTION = EXCEPTION_LOG(__name__) MAX_TIMEOUT = 20 # DON'T WAIT LONGER THAN DEFINED TIMEOUT MAX_TICKETS_PER_REQUEST = 50 # max number of ticket ids to include in a single request to tracker @view_config(route_name='times_tickets_excel', permission='client') class Excel(BaseView): def get(self): client = self.request.user.get_client() form = ProjectsTimeForm(formdata=self.request.GET, client=client) if not form.validate(): return render('time/tickets_report/projects_report.html', dict(form=form))
import datetime import requests from collections import defaultdict from pyramid.decorator import reify from sqlalchemy import Column, ForeignKey, orm, or_ from sqlalchemy.types import String, Boolean, Integer, Date, Enum, Text from sqlalchemy.schema import UniqueConstraint from sqlalchemy.dialects import postgresql from sqlalchemy.sql.expression import exists from intranet3 import memcache, config from intranet3.log import ERROR_LOG from intranet3.models import Base, DBSession ERROR = ERROR_LOG(__name__) INFO = ERROR_LOG(__name__) GOOGLE_ACCESS_TOKEN_MEMCACHE_KEY = 'google-access-token-userid-%s' levels = [ ('1', 'INTERN'), ('2', 'P1'), ('4', 'P2'), ('8', 'P3'), ('16', 'P4'), ('32', 'FED'), ('64', 'ADMIN'), ('128', 'Expert zew.'), ('256', 'Android Dev'), ('512', 'Tester'),