Commit 6a32e82c by Owo Sugiana

Akhiri dependency URL dengan .git agar dipahami git client lama

1 parent c4b347cd
...@@ -13,12 +13,14 @@ from ziggurat_foundations.models.base import BaseModel ...@@ -13,12 +13,14 @@ from ziggurat_foundations.models.base import BaseModel
from ziggurat_foundations.models.external_identity import ExternalIdentityMixin from ziggurat_foundations.models.external_identity import ExternalIdentityMixin
from ziggurat_foundations.models.group import GroupMixin from ziggurat_foundations.models.group import GroupMixin
from ziggurat_foundations.models.group_permission import GroupPermissionMixin from ziggurat_foundations.models.group_permission import GroupPermissionMixin
from ziggurat_foundations.models.group_resource_permission import GroupResourcePermissionMixin from ziggurat_foundations.models.group_resource_permission \
import GroupResourcePermissionMixin
from ziggurat_foundations.models.resource import ResourceMixin from ziggurat_foundations.models.resource import ResourceMixin
from ziggurat_foundations.models.user import UserMixin from ziggurat_foundations.models.user import UserMixin
from ziggurat_foundations.models.user_group import UserGroupMixin from ziggurat_foundations.models.user_group import UserGroupMixin
from ziggurat_foundations.models.user_permission import UserPermissionMixin from ziggurat_foundations.models.user_permission import UserPermissionMixin
from ziggurat_foundations.models.user_resource_permission import UserResourcePermissionMixin from ziggurat_foundations.models.user_resource_permission \
import UserResourcePermissionMixin
from ziggurat_foundations import ziggurat_model_init from ziggurat_foundations import ziggurat_model_init
from . import ( from . import (
Base, Base,
...@@ -32,6 +34,8 @@ ziggurat_foundations.models.DBSession = DBSession ...@@ -32,6 +34,8 @@ ziggurat_foundations.models.DBSession = DBSession
# optional for folks who pass request.db to model methods # optional for folks who pass request.db to model methods
# Base is sqlalchemy's Base = declarative_base() from your project # Base is sqlalchemy's Base = declarative_base() from your project
class Group(GroupMixin, Base, CommonModel): class Group(GroupMixin, Base, CommonModel):
pass pass
...@@ -84,25 +88,6 @@ class User(UserMixin, Base, CommonModel): ...@@ -84,25 +88,6 @@ class User(UserMixin, Base, CommonModel):
class ExternalIdentity(ExternalIdentityMixin, Base): class ExternalIdentity(ExternalIdentityMixin, Base):
pass pass
# you can define multiple resource derived models to build a complex
# application like CMS, forum or other permission based solution
#class Entry(Resource):
# """
# Resource of `entry` type
# """
# __tablename__ = 'entries'
# __mapper_args__ = {'polymorphic_identity': 'entry'}
# resource_id = sa.Column(sa.Integer(),
# sa.ForeignKey('resources.resource_id',
# onupdate='CASCADE',
# ondelete='CASCADE', ),
# primary_key=True, )
# ... your own properties....
# some_property = sa.Column(sa.UnicodeText())
class RootFactory: class RootFactory:
def __init__(self, request): def __init__(self, request):
...@@ -115,7 +100,7 @@ class RootFactory: ...@@ -115,7 +100,7 @@ class RootFactory:
self.__acl__.append((Allow, acl_name, gp.perm_name)) self.__acl__.append((Allow, acl_name, gp.perm_name))
#ziggurat_model_init(User, Group, UserGroup, GroupPermission, passwordmanager=None) ziggurat_model_init(
ziggurat_model_init(User, Group, UserGroup, GroupPermission, UserPermission, User, Group, UserGroup, GroupPermission, UserPermission,
UserResourcePermission, GroupResourcePermission, Resource, UserResourcePermission, GroupResourcePermission, Resource,
ExternalIdentity, passwordmanager=None) ExternalIdentity, passwordmanager=None)
...@@ -14,13 +14,13 @@ class Restore: ...@@ -14,13 +14,13 @@ class Restore:
q = self.db_session.query(self.table) q = self.db_session.query(self.table)
if q.first(): if q.first():
return return
with self.open_file() as f: with self.open_file() as f:
reader = csv.DictReader(f) reader = csv.DictReader(f)
for cf in reader: for cf in reader:
row = self.table() row = self.table()
for fieldname in cf: for fieldname in cf:
val = cf[fieldname] val = cf[fieldname]
if not val: if not val:
continue continue
setattr(row, fieldname, val) setattr(row, fieldname, val)
self.db_session.add(row) self.db_session.add(row)
...@@ -34,7 +34,7 @@ class Append(Restore): ...@@ -34,7 +34,7 @@ class Append(Restore):
self.run() self.run()
def run(self): def run(self):
with self.open_file() as f: with self.open_file() as f:
reader = csv.DictReader(f) reader = csv.DictReader(f)
filter_ = dict() filter_ = dict()
for cf in reader: for cf in reader:
...@@ -47,7 +47,7 @@ class Append(Restore): ...@@ -47,7 +47,7 @@ class Append(Restore):
row = self.table() row = self.table()
for fieldname in cf: for fieldname in cf:
val = cf[fieldname] val = cf[fieldname]
if not val: if not val:
continue continue
setattr(row, fieldname, val) setattr(row, fieldname, val)
self.db_session.add(row) self.db_session.add(row)
import calendar import calendar
from datetime import ( from datetime import (
date, date,
datetime, datetime,
...@@ -12,50 +12,56 @@ def get_timezone(): ...@@ -12,50 +12,56 @@ def get_timezone():
return pytz.timezone(settings['timezone']) return pytz.timezone(settings['timezone'])
def create_datetime(year, month, day, hour=0, minute=7, second=0, def create_datetime(
microsecond=0): year, month, day, hour=0, minute=7, second=0, microsecond=0):
tz = get_timezone() tz = get_timezone()
return datetime(year, month, day, hour, minute, second, return datetime(
microsecond, tzinfo=tz) year, month, day, hour, minute, second, microsecond, tzinfo=tz)
def create_date(year, month, day): def create_date(year, month, day):
return create_datetime(year, month, day) return create_datetime(year, month, day)
def as_timezone(tz_date): def as_timezone(tz_date):
localtz = get_timezone() localtz = get_timezone()
if not tz_date.tzinfo: if not tz_date.tzinfo:
tz_date = create_datetime(tz_date.year, tz_date.month, tz_date.day, tz_date = create_datetime(tz_date.year, tz_date.month, tz_date.day,
tz_date.hour, tz_date.minute, tz_date.second, tz_date.hour, tz_date.minute, tz_date.second,
tz_date.microsecond) tz_date.microsecond)
return tz_date.astimezone(localtz) return tz_date.astimezone(localtz)
def create_now(): def create_now():
tz = get_timezone() tz = get_timezone()
return datetime.now(tz) return datetime.now(tz)
def date_from_str(value): def date_from_str(value):
separator = None separator = None
value = value.split()[0] # dd-mm-yyyy HH:MM:SS value = value.split()[0] # dd-mm-yyyy HH:MM:SS
for s in ['-', '/']: for s in ['-', '/']:
if value.find(s) > -1: if value.find(s) > -1:
separator = s separator = s
break break
if separator: if separator:
t = map(lambda x: int(x), value.split(separator)) t = map(lambda x: int(x), value.split(separator))
y, m, d = t[2], t[1], t[0] y, m, d = t[2], t[1], t[0]
if d > 999: # yyyy-mm-dd if d > 999: # yyyy-mm-dd
y, d = d, y y, d = d, y
else: else:
y, m, d = int(value[:4]), int(value[4:6]), int(value[6:]) y, m, d = int(value[:4]), int(value[4:6]), int(value[6:])
return date(y, m, d) return date(y, m, d)
def dmy(tgl): def dmy(tgl):
return tgl.strftime('%d-%m-%Y') return tgl.strftime('%d-%m-%Y')
def dmyhms(t): def dmyhms(t):
return t.strftime('%d-%m-%Y %H:%M:%S') return t.strftime('%d-%m-%Y %H:%M:%S')
def next_month(year, month): def next_month(year, month):
if month == 12: if month == 12:
month = 1 month = 1
...@@ -63,7 +69,8 @@ def next_month(year, month): ...@@ -63,7 +69,8 @@ def next_month(year, month):
else: else:
month += 1 month += 1
return year, month return year, month
def best_date(year, month, day): def best_date(year, month, day):
try: try:
return date(year, month, day) return date(year, month, day)
...@@ -71,6 +78,7 @@ def best_date(year, month, day): ...@@ -71,6 +78,7 @@ def best_date(year, month, day):
last_day = calendar.monthrange(year, month)[1] last_day = calendar.monthrange(year, month)[1]
return date(year, month, last_day) return date(year, month, last_day)
def next_month_day(year, month, day): def next_month_day(year, month, day):
year, month = next_month(year, month) year, month = next_month(year, month)
return best_date(year, month, day) return best_date(year, month, day)
...@@ -24,7 +24,8 @@ requires = [ ...@@ -24,7 +24,8 @@ requires = [
'ziggurat_foundations', 'ziggurat_foundations',
'psycopg2-binary', 'psycopg2-binary',
'pyramid', 'pyramid',
'opensipkd-jsonrpc @ git+https://git.opensipkd.com/sugiana/opensipkd-jsonrpc', 'opensipkd-jsonrpc @ '
'git+https://git.opensipkd.com/sugiana/opensipkd-jsonrpc.git',
] ]
...@@ -32,7 +33,7 @@ setup( ...@@ -32,7 +33,7 @@ setup(
name='opensipkd-base', name='opensipkd-base',
version=version, version=version,
description='Basis Aplikasi openSIPKD', description='Basis Aplikasi openSIPKD',
long_description=README + '\n\n' + CHANGES, long_description=README + '\n\n' + CHANGES,
classifiers=[ classifiers=[
"Programming Language :: Python", "Programming Language :: Python",
"Framework :: Pylons", "Framework :: Pylons",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!