Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ compile various needed Python modules later on. Here is the list:
* Python ``virtualenv`` package

- In Fedora/RHEL/CentOS: package ``python-virtualenv``
- In Debian/Ubuntu/Mint: package ``python3-virtualenv`` or ``python-virtualenv``
- In Debian/Ubuntu/Mint: package ``virtualenv`` and one of
(``python3-virtualenv``, ``python-virtualenv``)
- In Arch: package ``python-virtualenv`` or ``python2-virtualenv``
- In Gentoo: package ``dev-python/virtualenv``

Expand Down
4 changes: 3 additions & 1 deletion netprofile/netprofile/ext/direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ def _do_route(self, action_name, method_name, params, trans_id, request):
except Exception as e:
# Let a user defined view for specific exception prevent returning
# a server error.
exception_view = render_view_to_response(e, request)
exception_view = None
if not isinstance(e, AccessDeniedException):
exception_view = render_view_to_response(e, request)
if exception_view is not None:
ret['result'] = exception_view
return ret
Expand Down
10 changes: 9 additions & 1 deletion netprofile_core/netprofile_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2568,6 +2568,9 @@ def check_old_session(self, req, user, npsess, ts=None):
def check_password_age(self, req, user, npsess, ts):
last_pwh = user.last_password_change
if last_pwh:
if self.pw_age_max is None:
req.session['sess.pwage'] = 'ok'
return True
days = (ts - last_pwh.timestamp).days
if days > self.pw_age_max:
if self.pw_age_action == SecurityPolicyOnExpire.drop:
Expand All @@ -2583,7 +2586,12 @@ def check_password_age(self, req, user, npsess, ts):
else:
req.session['sess.pwage'] = 'ok'
else:
req.session['sess.pwage'] = 'ok'
if self.pw_age_action == SecurityPolicyOnExpire.none:
req.session['sess.pwage'] = 'ok'
elif self.pw_age_max is None:
req.session['sess.pwage'] = 'ok'
else:
req.session['sess.pwage'] = 'force'
return True

def __str__(self):
Expand Down
122 changes: 106 additions & 16 deletions netprofile_entities/netprofile_entities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
contains_eager,
joinedload,
relationship,
validates
validates,
column_property
)

from sqlalchemy.ext.associationproxy import association_proxy
Expand Down Expand Up @@ -1368,13 +1369,32 @@ class PhysicalEntity(Entity):
template='<img class="np-block-img" src="{grid_icon}" />'
),
'entityid',
'nick', 'name_family', 'name_given'
'nick',
HybridColumn('fullname',
header_string=_('Full Name'),
column_flex=4,
template=TemplateObject('netprofile_entities:templates/entity_fullname.mak')
),
HybridColumn('addrs',
header_string=_('Address'),
column_flex=4,
template=TemplateObject('netprofile_entities:templates/entity_address.mak')
),
HybridColumn('phns',
header_string=_('Phone'),
column_flex=4,
template=TemplateObject('netprofile_entities:templates/entity_phone.mak')
),
),
'grid_hidden' : ('entityid',),
'form_view' : (
'nick', 'parent', 'state', 'flags', 'contractid',
'nick',
'addresses', 'phones',
'parent', 'state',
'flags', 'contractid',
'stashes',
'name_family', 'name_given', 'name_middle',
'gender',
'gender',
'email', 'icq', 'homepage', 'birthdate',
'pass_series', 'pass_num', 'pass_issuedate', 'pass_issuedby',
'descr'
Expand Down Expand Up @@ -1561,19 +1581,24 @@ class PhysicalEntity(Entity):
'header_string' : _('Pass. Issue Date')
}
)
#@property
#def data(self):
# return {
# 'flags' : [(ft.id, ft.name) for ft in self.flags]
# }

def data(self, req):
loc = get_localizer(req)
#def data(self, req):
# loc = get_localizer(req)

ret = super(PhysicalEntity, self).data
# ret = super(PhysicalEntity, self).data

ret['addrs'] = []
ret['phones'] = []
for obj in self.addresses:
ret['addrs'].append(str(obj))
for obj in self.phones:
ret['phones'].append(obj.data)
return ret
# ret['addrs'] = []
# ret['phones'] = []
# for obj in self.addresses:
# ret['addrs'].append(str(obj))
# for obj in self.phones:
# ret['phones'].append(obj.data)
# return ret

def template_vars(self, req):
ret = super(PhysicalEntity, self).template_vars(req)
Expand All @@ -1587,11 +1612,33 @@ def template_vars(self, req):
'homepage' : self.homepage,
'passport_series' : self.passport_series,
'passport_number' : self.passport_number,
'passport_issued_by' : self.passport_issued_by
'passport_issued_by' : self.passport_issued_by,
})
# TODO: add birthdate, pass_issuedate
return ret

@property
def addrs(self):
addr = []
for a in self.addresses:
addr.append(str(a))
return "; ".join(addr)

@property
def phns(self):
phn = []
for p in self.phones:
phn.append(str(p))
return "; ".join(phn)

@property
def fullname(self):
fname = []
for n in [self.name_family, self.name_middle, self.name_given]:
if n is not None:
fname.append(n)
return " ".join(fname)

def grid_icon(self, req):
return req.static_url('netprofile_entities:static/img/physical.png')

Expand All @@ -1605,6 +1652,7 @@ def __str__(self):
strs.append(self.name_middle)
return ' '.join(strs)


class LegalEntity(Entity):
"""
Legal entity. Describes a company.
Expand Down Expand Up @@ -1641,11 +1689,28 @@ class LegalEntity(Entity):
template='<img class="np-block-img" src="{grid_icon}" />'
),
'entityid',
'nick', 'name', 'cp_name_family', 'cp_name_given'
'nick',
HybridColumn('fullname',
header_string=_('Full Name'),
column_flex=4,
template=TemplateObject('netprofile_entities:templates/entity_fullname.mak')
),
HybridColumn('addrs',
header_string=_('Address'),
column_flex=4,
template=TemplateObject('netprofile_entities:templates/entity_address.mak')
),
HybridColumn('phns',
header_string=_('Phone'),
column_flex=4,
template=TemplateObject('netprofile_entities:templates/entity_phone.mak')
),
#'name', 'cp_name_family', 'cp_name_given'
),
'grid_hidden' : ('entityid',),
'form_view' : (
'nick', 'parent', 'state', 'flags', 'contractid',
'stashes',
'name',
'cp_name_family', 'cp_name_given', 'cp_name_middle', 'cp_title',
'cp_email', 'cp_icq', 'homepage', 'address_legal',
Expand Down Expand Up @@ -1889,6 +1954,31 @@ def data(self, req):
ret['phones'].append(obj.data)
return ret

@property
def addrs(self):
addr = []
for a in self.addresses:
addr.append(str(a))
if len(addr)> 0:
return "; ".join(addr)
else:
return self.address_legal

@property
def phns(self):
phn = []
for p in self.phones:
phn.append(str(p))
return "; ".join(phn)

@property
def fullname(self):
fname = []
for n in [self.contact_name_family, self.contact_name_middle, self.contact_name_given]:
if n is not None:
fname.append(n)
return " ".join(fname)

def grid_icon(self, req):
return req.static_url('netprofile_entities:static/img/legal.png')

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{phns
<tpl if="data.flags && data.flags.length">
<br />
<tpl for="data.flags">
<img class="np-inline-img" src="${req.static_url('netprofile_entities:static/img/flags/')}{0}.png" alt="{1}" />
</tpl>
</tpl>

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{addrs}
<tpl if="data.flags && data.flags.length">
<br />
<tpl for="data.flags">
<img class="np-inline-img" src="${req.static_url('netprofile_entities:static/img/flags/')}{0}.png" alt="{1}" />
</tpl>
</tpl>

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{fullname}
<tpl if="data.flags && data.flags.length">
<br />
<tpl for="data.flags">
<img class="np-inline-img" src="${req.static_url('netprofile_entities:static/img/flags/')}{0}.png" alt="{1}" />
</tpl>
</tpl>

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{phns}
<tpl if="data.flags && data.flags.length">
<br />
<tpl for="data.flags">
<img class="np-inline-img" src="${req.static_url('netprofile_entities:static/img/flags/')}{0}.png" alt="{1}" />
</tpl>
</tpl>

3 changes: 3 additions & 0 deletions netprofile_ldap/netprofile_ldap/ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
asbool,
aslist
)
from pyramid.threadlocal import get_current_request
from netprofile.common.hooks import (
IHookManager,
register_hook
Expand Down Expand Up @@ -144,6 +145,8 @@ def _gen_ldap_object_load(em, info, settings, hm):
object_classes = '(objectClass=' + ')(objectClass='.join(object_classes) + ')'
get_rdn = _gen_ldap_object_rdn(em, rdn_attr)
def _ldap_object_load(tgt, ctx):
if getattr(tgt, '__req__', None) is None:
tgt.__req__ = get_current_request()
ret = None
rdn = get_rdn(tgt)
flt = '(&(%s)%s)' % (rdn, object_classes)
Expand Down
2 changes: 1 addition & 1 deletion netprofile_stashes/netprofile_stashes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class Stash(Base):
'default_sort' : ({ 'property': 'name', 'direction': 'ASC' },),
'grid_view' : ('stashid', 'entity', 'name', 'amount', 'credit'),
'grid_hidden' : ('stashid',),
'form_view' : ('entity', 'name', 'amount', 'credit', 'alltime_min', 'alltime_max'),
'form_view' : ('entity', 'name', 'amount', 'credit', 'operations','alltime_min', 'alltime_max'),
'easy_search' : ('name',),
'detail_pane' : ('netprofile_core.views', 'dpane_simple'),
'create_wizard' : SimpleWizard(title=_('Add new stash'))
Expand Down
20 changes: 18 additions & 2 deletions netprofile_tickets/netprofile_tickets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
]

import importlib
import json
import datetime as dt
from dateutil.parser import parse as dparse

Expand Down Expand Up @@ -96,6 +97,7 @@
populate_related_list
)
from netprofile.ext.data import ExtModel
from netprofile.tpl import TemplateObject
from netprofile.ext.columns import (
HybridColumn,
MarkupColumn
Expand Down Expand Up @@ -725,7 +727,8 @@ def _wizfld_ticket_state(fld, model, req, **kwargs):
sess = DBSession()
loc = get_localizer(req)
data = []
for ts in sess.query(TicketState).filter(TicketState.is_start == True).order_by('title', 'subtitle'):
#for ts in sess.query(TicketState).filter(TicketState.is_start == True).order_by('title', 'subtitle'):
for ts in sess.query(TicketState).order_by('title', 'subtitle'):
data.append({
'id' : ts.id,
'value' : str(ts)
Expand Down Expand Up @@ -851,7 +854,14 @@ class Ticket(Base):
'menu_main' : True,
'default_sort' : ({ 'property': 'ctime' ,'direction': 'DESC' },),
'grid_view' : (
'ticketid', 'entity', 'state',
'ticketid', 'entity',
HybridColumn(
'tstate',
header_string=_('State'),
column_flex=4,
column_name=_('State'),
template=TemplateObject('netprofile_tickets:templates/ticket_template.mak'),
),
'assigned_time', 'assigned_group', 'name'
),
'grid_hidden' : ('ticketid',),
Expand All @@ -868,6 +878,7 @@ class Ticket(Base):
Step(
'entity', 'name',
ExtJSWizardField(_wizfld_ticket_state),
#'state',
'show_client',
'flags', 'descr',
id='generic'
Expand Down Expand Up @@ -1220,6 +1231,11 @@ class Ticket(Base):
def __str__(self):
return '%s' % self.name

@property
def tstate(self):
tstr = """%s.png" /> <font color=%s>%s</font>"""
return tstr % (self.state.image, self.state.style, self.state)

@classmethod
def __augment_query__(cls, sess, query, params, req):
flist = []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img class="np-inline-img" src="${req.static_url('netprofile_core:static/img/')}{tstate}