class Role(couchdb.mapping.Document):
    rolename = TextField()
    permissions = ListField(TextField())
    create_date = DateTimeField()
    created_by = TextField()
    change_date = DateTimeField()
    type = TextField()
Exemple #2
0
def	GetProcList():

    scheme_db = server['scheme']

    db = server['proc']
    map_fun = '''function(doc) {
	emit(doc.proc_num,[doc._id,doc.proc_name,doc.status,doc.create,doc.scheme_link,doc.next_step,doc.author_name]);
    }'''

    data = []

    field = DateTimeField()

    for row in db.query(map_fun):
	if row.value[4] == '':
	    scheme = ''
	    step = ''
	    user = {'person':'','phone':''}
	else:
	    doc = scheme_db[row.value[4]]
	    scheme = doc['scheme_name']
	    user = NextPerson(row.value[0])

	if row.value[5] == 0:
	    next_step = 'Start'
	elif row.value[5] == 1000:
	    next_step = 'End'
	else:
	    next_step = row.value[5]
	author = row.value[6].split()[1]+' '+row.value[6].split()[0]
	data.append([row.key,row.value[0],row.value[1],row.value[2],field._to_python(row.value[3]),scheme,next_step,user['person']+' ('+user['phone']+')',author])

    data.reverse()

    return data
class User(couchdb.mapping.Document):
    username = TextField()
    description = TextField()
    birth_date = DateField()
    assigned_rolename = TextField()
    create_date = DateTimeField()
    change_date = DateTimeField()
    type = TextField()
class DB_Structure(Document):
    _id = TextField()
    url = TextField()
    ref = TextField()
    Discovered = DateTimeField()
    LastAccessed = DateTimeField()
    title = TextField()
    is_alive = BooleanField()
    raw_code = TextField()
Exemple #5
0
class DocumentBase(Document):
    created_at = DateTimeField()
    updated_at = DateTimeField()

    db = None

    def __init__(self, db=None):
        if db:
            self.db = db

        Document.__init__(self)

    @classmethod
    def wrapper(cls, row):
        if 'doc' in row:
            doc = row['doc']
        elif 'value' in row:
            doc = row['value']
        else:
            doc = row

        return cls.wrap(doc)

    @classmethod
    def find(cls, db, doc_id):
        doc = cls.load(db, doc_id)

        if doc:
            doc.db = db

        return doc

    @classmethod
    def all(cls, db):
        view = db.view('_all_docs', cls.wrapper, **{'include_docs': True})
        rows = list(view)

        for row in view:
            row.db = db

        return rows

    def doc_db(self):
        raise NotImplementedError(
            'Method should be defined in the child class.')

    def save(self):
        if not self.created_at:
            self.created_at = datetime.now()
        else:
            self.updated_at = datetime.now()

        self.store(self.db)

    def destroy(self):
        self.db.delete(self)
Exemple #6
0
class Role(couchdb.mapping.Document):
    rolename = TextField()
    permissions = ListField(TextField())
    create_date = DateTimeField()
    created_by = TextField()
    change_date = DateTimeField()
    type = TextField()
    previous_versions = ListField(
        DictField(
            Mapping.build(permissions=ListField(TextField()),
                          version_create_date=DateTimeField(),
                          version_created_by=TextField(),
                          version_valid_until=DateTimeField())))
Exemple #7
0
 class UsageData(Document):
     """
     Document that represents the stored data.
     """
     url = TextField()
     ua_browser = TextField()
     ua_language = TextField()
     ua_platform = TextField()
     ua_version = TextField()
     blueprint = TextField()
     view_args = TextField()
     status = IntegerField()
     remote_addr = TextField()
     authorization = BooleanField()
     ip_info = TextField()
     path = TextField()
     speed = FloatField()
     datetime = DateTimeField(default=datetime.now)
     username = TextField()
     track_var = TextField()
     by_date = ViewField(
         'start-end', '''function(doc, req) {
         if (!doc._conflicts) {
             emit(doc.datetime, doc);
         }
     }''')
Exemple #8
0
class RingsSchema(Document):
    _id = TextField()
    added = DateTimeField(default=datetime.now)
    license = TextField()
    public = BooleanField(default=False)
    rings = ListField(
        DictField(
            Mapping.build(RingName=TextField(),
                          RingLabel=TextField(),
                          RingDescription=TextField(),
                          RingVersion=TextField(),
                          RingURI=TextField(),
                          RingBuild=TextField(),
                          RingParent=TextField())))
    fields = ListField(
        DictField(
            Mapping.build(
                FieldId=TextField(),
                FieldName=TextField(),
                FieldLabel=TextField(),
                FieldSemantic=TextField(),
                FieldType=TextField(),
                FieldSource=TextField(),
                FieldWidget=TextField(),
                FieldOrder=IntegerField(),
                FieldCardinality=TextField(),
                FieldMultilingual=BooleanField(),
                FieldRequired=BooleanField(),
                FieldDefault=TextField(),
                FieldHint=TextField(),
                FieldLayer=IntegerField(),
            )))
Exemple #9
0
class Volts(Document):
    sensor_sn = TextField()
    logger_sn = IntegerField()
    location = TextField()
    gps = TextField()
    date = DateTimeField()
    volts = TextField()
Exemple #10
0
class Session(Document):
    object_id = TextField()
    bag_id = TextField()
    added = DateTimeField(default=datetime.now)
    Type = TextField(default="Session")
    all = ViewField(
        'sessions', '''\
        function(doc) {
            if(doc.Type == "Session")
                emit(null,doc)
        }
    ''')
    by_object_id = ViewField(
        'sessions', '''\
        function(doc) {
            if(doc.Type == "Session")
                emit(doc.object_id,doc)
        }
    ''')
    by_bag_id = ViewField(
        'sessions', '''\
        function(doc) {
            if(doc.Type == "Session")
                emit(doc.bag_id,doc)
        }
    ''')

    @classmethod
    def sync(cls, db):
        cls.all.sync(db)
        cls.by_object_id.sync(db)
        cls.by_bag_id.sync(db)
class DepartureRecord(Document):
    departs_at = TextField()
    dest = TextField()
    track = TextField()
    line = TextField()
    train_id = TextField()
    status = TextField()
    at = DateTimeField()
    color = TextField()

    def __eq__(self, other):
        return self.__dict__ == other.__dict__

    def __hash__(self):
        return self.__dict__.__hash__()

    def __str__(self):
        return self.__dict__.__str__()

    @staticmethod
    def from_departure(d):
        print(d.__dict__)
        return DepartureRecord(departs_at=d.departs_at,
                               dest=d.dest,
                               track=d.track,
                               line=d.line,
                               train_id=d.train_id,
                               status=d.status,
                               at=d.at,
                               color=d.color)
Exemple #12
0
def	GetList(search):

    db = server['client']

    map_fun = '''function(doc) {
	if(doc._id != 'c83695ba59310ae945108de54b05def1')
	emit(doc._id,[doc.name,doc.address,doc.status,doc.creator_name,doc.creator_phone,doc.create,doc.manager_name,doc.manager_phone,doc.priority]);
    }'''
    data = []

    field = DateTimeField()


    for row in db.query(map_fun):
	if search == '':
	    data.append([
		row.key,
		row.value[0],
		row.value[1],
		row.value[2],
		row.value[3].split()[1]+' '+row.value[3].split()[0],
		row.value[4],
		field._to_python(row.value[5]),
		row.value[6],
		row.value[7],
		row.value[8]
		])
#	elif Compare(row.value[0],search) or Compare(row.value[1],search) or Compare(row.value[2],search) or Compare(row.value[3],search) or Compare(row.value[4],search) or Compare(row.value[6],search) or Compare(row.value[7],search) or Compare(row.value[8],search):
	elif Compare(row.value[0],search) or Compare(row.value[1],search) or Compare(row.value[2],search) or Compare(row.value[3],search) or Compare(row.value[4],search) or Compare(row.value[8],search):
	    data.append([
		row.key,
		row.value[0],
		row.value[1],
		row.value[2],
		row.value[3].split()[1]+' '+row.value[3].split()[0],
		row.value[4],
		field._to_python(row.value[5]),
		row.value[6],
		row.value[7],
		row.value[8]
		])

    data = sorted(data,key=itemgetter(6))
    data.reverse()

    return data
Exemple #13
0
class User(Document):
    '''Class for handling workspace documents in db'''
    name = TextField()
    type = TextField(default="user")
    email = TextField()
    uid = IntegerField()
    gid = IntegerField()
    creation_date = DateTimeField(default=datetime.now)
Exemple #14
0
class Picture(Document):
    name = TextField()
    width = IntegerField()
    height = IntegerField()
    mime_type = TextField()
    size = IntegerField()
    phash = TextField()
    created = DateTimeField(default=datetime.now)
Exemple #15
0
class User(couchdb.mapping.Document):
    username = TextField()
    description = TextField()
    birth_date = DateField()
    assigned_rolename = TextField()
    create_date = DateTimeField()
    change_date = DateTimeField()
    type = TextField()
    previous_versions = ListField(
        DictField(
            Mapping.build(
                description=TextField(),
                assigned_rolename=TextField(),
                version_create_date=DateTimeField(),
                version_created_by=TextField(),
                version_valid_until=DateTimeField(),
            )))
Exemple #16
0
class HistoryData(Document):
    client_id = TextField(name='client_id')
    text = TextField(name='text')
    language = TextField(name='language')
    created_on = DateTimeField(name='created_on', default=datetime.now)

    def __str__(self):
        return id
Exemple #17
0
class User(Document):
    name = TextField()
    password = TextField()
    exclusions = ListField(TextField())
    dataInstances = ListField(
        DictField(
            Mapping.build(task_name=TextField(),
                          start_time=DateTimeField(),
                          end_time=DateTimeField(),
                          suggested_time=IntegerField(),
                          pre_energy=IntegerField(),
                          user_feedback=IntegerField(),
                          auto_rating=BooleanField())))
    breakInstances = ListField(
        DictField(
            Mapping.build(break_start_time=DateTimeField(),
                          break_end_time=DateTimeField())))

    usernameView = ViewField(
        'users', '''\
         function(doc) {
             emit(doc.name, doc);
         }''')

    def get_favorites(self):
        favs = []
        for inst in self.dataInstances:
            if inst.task_name not in favs and inst.task_name not in self.exclusions:
                favs.append(inst.task_name)
        return favs

    @property
    def is_active(self):
        return True

    @property
    def is_authenticated(self):
        return True

    @property
    def is_anonymous(self):
        return False

    def get_id(self):
        return unicode(self.name)
Exemple #18
0
class Test_Run(Document):
    status = TextField()
    slot = TextField()
    test_runner = TextField()
    test_group = TextField()
    trigger_on = DateTimeField()
    build_id = TextField()
    hash_key = TextField()
    os_label = TextField()
    handlers = ListField(TextField(), name='handler')
    finish_time = DateTimeField()
    count = IntegerField()
    filename = TextField()
    project = TextField()
    platform = TextField()
    test_env = TextField()
    type = TextField()
    start_time = DateTimeField()
class Snapshot(Document):
    '''Class for handling snapshot documents in db'''
    name = TextField()
    type = TextField(default="snapshot")
    volume = TextField()
    project = TextField()
    jenkins_build = IntegerField()
    build_status = TextField()
    creation_date = DateTimeField(default=datetime.now)
Exemple #20
0
class Project(Document):
    '''Class for handling project documents in db'''
    name = TextField()
    type = TextField(default="project")
    volume = TextField()
    scm_url = TextField()
    jenkins_url = TextField()
    workspace_purge_limit = IntegerField(default=21)
    creation_date = DateTimeField(default=datetime.now)
    ci_purge_limit = IntegerField(default=50)
    export_policy = TextField()
Exemple #21
0
class UsersData(Document):
    email = TextField(name='id')
    first_name = TextField(name='first_name')
    last_name = TextField(name='last_name')
    organization = TextField(name='organization')
    password = TextField(name='passcode')
    phone_number = TextField(name='phone_number')
    wallet = IntegerField(name='wallet', default=100)
    per_request = IntegerField(name='per_requests', default=1)
    status = TextField(name='status', default='active')
    email_verified = TextField(name='email_verified', default=False)
    created_on = DateTimeField(default=datetime.now)
    last_modified = DateTimeField(default=datetime.now, name='last_modified')
    last_login = DateTimeField(default=datetime.now, name='last_login')
    client_id = TextField(default=uuid.uuid4)
    client_secret = TextField(name='client_secret', default=secret_key)
    verification_code = TextField(name='verification_code')

    def __str__(self):
        return self._rev
class Workspace(Document):
    '''Class for handling workspace documents in db'''
    name = TextField()
    type = TextField(default="workspace")
    project = TextField()
    parent_snapshot = TextField()
    uid = IntegerField()
    gid = IntegerField()
    username = TextField()
    creation_date = DateTimeField(default=datetime.now)
    ide_url = TextField()
    pod_name = TextField()
Exemple #23
0
def	ListContract(search):

    db = server['costcontract']
    map_fun = '''function(doc) {
	    emit(doc._id,[doc.contragent,doc.contract,doc.tema,doc.block,doc.author_name,doc.author_phone,doc.summ,doc.added]);
    }'''

    data = []

    field = DateTimeField()

    for row in db.query(map_fun):
	author = row.value[4].split()[1].encode('utf-8')+' '+row.value[4].split()[0].encode('utf-8')
	if search == '':
	    data.append({
		'rec_id':row.key,
		'contragent':row.value[0].encode('utf-8'),
		'contract':row.value[1].encode('utf-8'),
		'tema':row.value[2].encode('utf-8'),
		'block':row.value[3].encode('utf-8'),
		'author':author,
		'phone':row.value[5].encode('utf-8'),
		'sum':row.value[6],
		'added':field._to_python(row.value[7])
		})
	else:
	    if Compare(row.value[0],search) or Compare(row.value[1],search) or Compare(row.value[2],search) or Compare(row.value[3],search) or Compare(author.decode('utf-8'),search):
		data.append({
		    'rec_id':row.key,
		    'contragent':row.value[0].encode('utf-8'),
		    'contract':row.value[1].encode('utf-8'),
		    'tema':row.value[2].encode('utf-8'),
		    'block':row.value[3].encode('utf-8'),
		    'author':author,
		    'phone':row.value[5].encode('utf-8'),
		    'sum':row.value[6],
		    'added':field._to_python(row.value[7])
		    })

    return data
Exemple #24
0
def	Edit(request):

    try:
	if CheckAccess(request,'23') != 'OK':
	    return render_to_response("mtmc/notaccess/mtmc.html")
    except:
	return HttpResponseRedirect('/')

    try:
	eq_id = request.GET['eq_id']
	request.session['eq_id'] = eq_id
    except:
	pass

    try:
	eq_id = request.session['eq_id']
    except:
	return HttpResponseRedirect('/mtmc')
	

    if request.method == 'POST':
	form = NameForm(request.POST)
	if form.is_valid():
	    name = form.cleaned_data['name']
	    EditName(eq_id,name)

    eq = GetEq(eq_id)

    form = NameForm(None)
    form.fields['name'].initial = eq['name']
    
    field = DateTimeField()
    create = field._to_python(eq['create'])
    author = eq['author_name'].split()[1]+' '+eq['author_name'].split()[0]

    c = RequestContext(request,{'form':form,'eq':eq,'create':create,'author':author,'tmc':TmcUrl(eq)})
    c.update(csrf(request))
    return render_to_response("mtmc/edit.html",c)
Exemple #25
0
def openSession(request,user) :
  print 'trying to open session for ',user.login
  t = loader.get_template('index.html')
  sessionExpire = getTomorowDatetime()
  #print sessionExpire
  field=DateTimeField()
  #field._to_
  #user.sessionExpire=sessionExpire
  user.sessionId= encode(user.login+user.email+str(sessionExpire)+str(uuid.uuid1()))
  user.update()

  #Todo add an expiration date!
  response= HttpResponseRedirect("/");
  response.set_cookie(userauth.COOKIE_KEY, user.sessionId)
  return response
Exemple #26
0
def	GetSchemeList():

    db = server['scheme']
    map_fun = '''function(doc) {
	emit(doc.scheme_id,[doc._id,doc.scheme_name,doc.author_name,doc.added,doc.attrs_list]);
    }'''

    data = []

    field = DateTimeField()

    for row in db.query(map_fun):
	data.append([row.key,row.value[0],row.value[1],row.value[2].split()[1]+' '+row.value[2].split()[0],field._to_python(row.value[3]),row.value[4]])

    sorted(data)


    return data
Exemple #27
0
class Workspace(Document):
    '''Class for handling workspace documents in db'''
    name = TextField()
    clone = TextField()
    mount = TextField()
    type = TextField(default="workspace")
    pipeline = TextField()
    build_name = TextField()
    pvc = TextField()
    source_pvc = TextField()
    service = TextField()
    pod = TextField()
    pv = TextField()
    uid = IntegerField()
    gid = IntegerField()
    username = TextField()
    creation_date = DateTimeField(default=datetime.now)
    source_workspace_pvc = TextField()
    ide_url = TextField()
Exemple #28
0
class Per_Conf(Document):
    id = TextField()
    build_id = TextField()
    count = IntegerField()
    hash_key = TextField()
    os_label = TextField()
    test_runner = TextField()
    handlers = ListField(TextField(), name='handler')
    schedule_time = DateTimeField()
    shedule = ListField(TextField(), name='day')
    to_run = BooleanField()
    slot = TextField()
    filename = TextField()
    project = TextField()
    platform = TextField()
    test_group = ListField(TextField(), name='group')
    schedule_type = TextField()
    test_env = TextField()
    type = TextField()
Exemple #29
0
def	ListFile(author,search):
    author = author.encode("utf-8")

    db = server['userfiles']
    map_fun = '''function(doc) {
	if (doc.author == '%s')
	    emit(doc._id,[doc.filename,doc.comment,doc.access,doc.added,doc.filesize]);
    }''' % author

    data = []

    field = DateTimeField()

    for row in db.query(map_fun):
	if search == '':
	    data.append([row.key,row.value[0].encode('utf-8'),row.value[1].encode('utf-8'),row.value[2].encode('utf-8'),field._to_python(row.value[3]),row.value[4]])
	else:
	    if Compare(row.value[0],search) or Compare(row.value[1],search):
		data.append([row.key,row.value[0].encode('utf-8'),row.value[1].encode('utf-8'),row.value[2].encode('utf-8'),field._to_python(row.value[3]),row.value[4]])
    return data
Exemple #30
0
class Object(Document):
    object_name = TextField()
    description = TextField()
    tags = ListField(TextField())
    author_name = TextField()
    author_email = TextField()
    added = DateTimeField(default=datetime.now)
    Type = TextField(default="Object")

    all = ViewField(
        'objects', '''\
        function(doc) {
            if(doc.Type == "Object")
                emit(doc.object_name,doc)
        }
    ''')
    by_object_name = ViewField(
        'objects', '''\
        function(doc) {
            if(doc.Type == "Object")
                emit(doc.object_name, doc)
        }
    ''')

    by_tag = ViewField(
        'objects', '''\
        function(doc) {
            if(doc.Type == "Object")
                for( tag in doc.tags )
                {
                    emit(doc.tags[tag], doc)
                }
        }
    ''')

    @classmethod
    def sync(cls, db):
        cls.all.sync(db)
        cls.by_object_name.sync(db)
        cls.by_tag.sync(db)
Exemple #31
0
class URL(Document):
    target = TextField()
    public = BooleanField()
    added = DateTimeField(default=datetime.utcnow())
    shorty_id = TextField(default=None)
    db = None

    @classmethod
    def load(cls, id):
        return super(URL, cls).load(URL.db, id)

    @classmethod
    def query(cls, code):
        return URL.db.query(code)

    def store(self):
        if getattr(self._data, "id", None) is None:
            new_id = self.shorty_id if self.shorty_id else None
            while 1:
                id = new_id if new_id else get_random_uid()
                try:
                    docid = URL.db.resource.put(content=self._data,
                                                path="/%s/" % str(id))["id"]
                except Exception:
                    continue
                if docid:
                    break
            self._data = URL.db.get(docid)
        else:
            super(URL, self).store(URL.db)
        return self

    @property
    def short_url(self):
        return url_for("link", uid=self.id, _external=True)

    def __repr__(self):
        return "<URL %r>" % self.id
Exemple #32
0
class CampaignDoc(Document):
    doctype = TextField(default='Campaign')
    campaign_type = TextField(default='Base')
    config = DictField()
    added = DateTimeField(default=datetime.now())
Exemple #33
0
def	RealBuild(request):
    
    try:
	client_id = request.session['client_id']
    except:
	return HttpResponseRedirect('/clientlist')


    if request.method == 'POST':

	try:
	    file_link = request.POST['file_link']
	    if file_link != '':
		AddRealFile('build',client_id,file_link)
	except:
	    pass

	form = RealBuildForm(request.POST)
	if form.is_valid():
	    smartasr_order = form.cleaned_data['smartasr_order']
	    date_order = form.cleaned_data['date_order']
	    date_tmc = form.cleaned_data['date_tmc']
	    date_doc = form.cleaned_data['date_doc']
	    date_tmc_out = form.cleaned_data['date_tmc_out']
	    date_end = form.cleaned_data['date_end']
	    sz = form.cleaned_data['sz']
	    iss = form.cleaned_data['iss']
	    date_real = form.cleaned_data['date_real']
	    date_realend = form.cleaned_data['date_realend']
	    comment = form.cleaned_data['comment']

	    a = GetFio(request)
	    author = a.split()[1]+' '+a.split()[0]

	    BuildEdit( client_id,smartasr_order,date_order,
		date_tmc, date_doc, date_tmc_out, date_end, sz, iss,
		date_real, date_realend, comment, author
		)
	    StatusHistory(client_id,'Реализация',request)


    if request.method == 'GET':

	try:
	    delete_file = request.GET['delete_file']
	    DelRealFile('build',client_id,delete_file)
	except:
	    pass

	try:
	    in_real = request.GET['in_real']
	    InReal(request,client_id)
	    StatusHistory(client_id,'Принято в реализацию',request)
	except:
	    pass


    field = DateTimeField()

    client = GetClient(client_id)
    creator = client['creator_name'].split()[1]+' '+client['creator_name'].split()[0]
    create = field._to_python(client['create'])

    real = pickle.loads(client['realization_data'])
    build = real['build']

    form = RealBuildForm(None)    
    form.fields['smartasr_order'].initial = build['smartasr_order']
    form.fields['date_order'].initial = build['date_order']
    form.fields['date_tmc'].initial = build['date_tmc']
    form.fields['date_doc'].initial = build['date_doc']
    form.fields['date_tmc_out'].initial = build['date_tmc_out']
    form.fields['date_end'].initial = build['date_end']
    form.fields['sz'].initial = build['sz']
    form.fields['iss'].initial = build['iss']
    form.fields['date_real'].initial = build['date_real']
    form.fields['date_realend'].initial = build['date_realend']
    form.fields['comment'].initial = build['comment']

    fform = FileForm(None)
    filelist = ListFile(GetUserKod(request))
    filelist.insert(0,['',''])
    fform.fields['file_link'].choices = filelist

    #--- Список файлов ---
    realfiles = GetRealFiles('build',client_id)

    c = RequestContext(request,{'fform':fform,'form':form,'client':client,'creator':creator,'create':create,'realfiles':realfiles})
    c.update(csrf(request))
    return render_to_response("client/build.html",c)
Exemple #34
0
def parse_timestamp(ts):
    """Convert a JSON-friendly timestamp back to a python datetime object."""
    return DateTimeField()._to_python(ts)
Exemple #35
0
def timestamp():
    """Return the current time as a JSON-friendly timestamp."""
    return DateTimeField()._to_json(datetime.datetime.now())
Exemple #36
0
class Result(Document):
   name = TextField()
   question = TextField()
   score = IntegerField()
   added = DateTimeField(default=datetime.datetime.now())
            return self.couch[name]
        except couchdb.http.ResourceNotFound:
            return self.__init_db(name)

    def __init_db(self, name):
        db = self.couch.create(name)
        return db


DEPARTURE_RECORD_MAPPING = Mapping.build(departs_at=TextField(),
                                         dest=TextField(),
                                         track=TextField(),
                                         line=TextField(),
                                         train_id=TextField(),
                                         status=TextField(),
                                         at=DateTimeField(),
                                         color=TextField())


class Event(Document):
    action = TextField()
    context = TextField()
    new = DictField(DEPARTURE_RECORD_MAPPING)
    old = DictField(DEPARTURE_RECORD_MAPPING)

    @staticmethod
    def changed_departure(context, old, new):
        return Event(action='changed',
                     context=context,
                     new=new.__dict__,
                     old=old.__dict__)