Merge branch 'flectra-license-server' into 'master'
[ADD] Online delayed release support See merge request flectra-hq/flectra!166
This commit is contained in:
commit
32353100ea
@ -134,7 +134,7 @@ class ResConfigSettings(models.TransientModel):
|
|||||||
if self.activator_key and self.contract_id:
|
if self.activator_key and self.contract_id:
|
||||||
try:
|
try:
|
||||||
set_param = self.env['ir.config_parameter'].sudo().set_param
|
set_param = self.env['ir.config_parameter'].sudo().set_param
|
||||||
binary = json.loads(base64.decodestring(self.activator_key)).encode('ascii')
|
binary = json.loads(base64.decodestring(self.activator_key).decode('utf-8')).encode('ascii')
|
||||||
binary = base64.decodestring(binary)
|
binary = base64.decodestring(binary)
|
||||||
enc = json.dumps(decrypt(binary, self.contract_id))
|
enc = json.dumps(decrypt(binary, self.contract_id))
|
||||||
if enc:
|
if enc:
|
||||||
|
@ -1867,7 +1867,8 @@ class ReportController(http.Controller):
|
|||||||
|
|
||||||
class LicensingController(http.Controller):
|
class LicensingController(http.Controller):
|
||||||
@http.route('/flectra/licensing', type='http', auth="user")
|
@http.route('/flectra/licensing', type='http', auth="user")
|
||||||
def download(self, binary='', **kwargs):
|
def download(self, contract_id=None, type=None, binary='', **kwargs):
|
||||||
|
if type == 'offline':
|
||||||
filename = '%s.%s' % (FILENAME, EXT)
|
filename = '%s.%s' % (FILENAME, EXT)
|
||||||
content = binary
|
content = binary
|
||||||
return request.make_response(
|
return request.make_response(
|
||||||
@ -1877,3 +1878,33 @@ class LicensingController(http.Controller):
|
|||||||
('Content-Disposition', content_disposition(filename))
|
('Content-Disposition', content_disposition(filename))
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
elif type == 'online':
|
||||||
|
error = {
|
||||||
|
'code': 200,
|
||||||
|
'message': "Invalid License Key",
|
||||||
|
'data': ''
|
||||||
|
}
|
||||||
|
try:
|
||||||
|
if contract_id:
|
||||||
|
data = {
|
||||||
|
'data': binary,
|
||||||
|
'contract_id': contract_id
|
||||||
|
}
|
||||||
|
p = requests.post(
|
||||||
|
server_url + '/my/contract/validate/online',
|
||||||
|
params=data,
|
||||||
|
headers={'Content-type': 'plain/text' or 'application/octet-stream'})
|
||||||
|
content = json.loads(p.content.decode('utf-8'))
|
||||||
|
if 'activation_key' in content:
|
||||||
|
date = datetime.datetime.now() + datetime.timedelta(days=(12 * 30 * 1))
|
||||||
|
set_param = request.env['ir.config_parameter'].sudo().set_param
|
||||||
|
set_param('database.expiration_date', date)
|
||||||
|
set_param('contract.validity',
|
||||||
|
base64.encodestring(
|
||||||
|
encrypt(json.dumps(str(date)),str(date))))
|
||||||
|
if 'error_in_key' in content:
|
||||||
|
return request.make_response(html_escape(json.dumps(error)))
|
||||||
|
except Exception as e:
|
||||||
|
error['code'] = 400
|
||||||
|
error['message'] = 'Flectra Error!'
|
||||||
|
return request.make_response(html_escape(json.dumps(error)))
|
@ -61,17 +61,28 @@ class Http(models.AbstractModel):
|
|||||||
currencies = Currency.search([]).read(['symbol', 'position', 'decimal_places'])
|
currencies = Currency.search([]).read(['symbol', 'position', 'decimal_places'])
|
||||||
return { c['id']: {'symbol': c['symbol'], 'position': c['position'], 'digits': [69,c['decimal_places']]} for c in currencies}
|
return { c['id']: {'symbol': c['symbol'], 'position': c['position'], 'digits': [69,c['decimal_places']]} for c in currencies}
|
||||||
|
|
||||||
def get_contracted_modules(self, contract_key='', ir_module_module_ids=None):
|
def get_contracted_modules(self, type=None, contract_key=None, ir_module_module_ids=None):
|
||||||
if ir_module_module_ids:
|
if ir_module_module_ids:
|
||||||
|
contract_key = contract_key or ''
|
||||||
contracted_module_list = ir_module_module_ids.mapped('name')
|
contracted_module_list = ir_module_module_ids.mapped('name')
|
||||||
contracts = encrypt(json.dumps(contracted_module_list), contract_key)
|
warrant = self.env['publisher_warranty.contract'].sudo()._get_message()
|
||||||
|
warrant.update({
|
||||||
|
'contracts': contracted_module_list,
|
||||||
|
'contract_id': contract_key
|
||||||
|
})
|
||||||
|
if type != 'online':
|
||||||
|
contracts = encrypt(json.dumps(warrant), contract_key)
|
||||||
|
else:
|
||||||
|
contracts = str.encode(json.dumps(warrant))
|
||||||
return contracts
|
return contracts
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def contract_validate_file(self, contract_id):
|
def contract_validate_file(self, contract_id, type):
|
||||||
|
contracts = []
|
||||||
|
if contract_id:
|
||||||
ir_module_module_ids = self.env['ir.module.module'].sudo().search(
|
ir_module_module_ids = self.env['ir.module.module'].sudo().search(
|
||||||
[('contract_certificate', '!=', False), ('state', '=', 'installed')])
|
[('contract_certificate', '!=', False), ('state', '=', 'installed')])
|
||||||
contracts = self.get_contracted_modules(contract_id,ir_module_module_ids)
|
contracts = self.get_contracted_modules(type, contract_id, ir_module_module_ids)
|
||||||
return json.dumps(base64.encodestring(contracts).decode('ascii'))
|
return json.dumps(base64.encodestring(contracts).decode('ascii'))
|
||||||
|
|
||||||
def check_validate_date(self, config):
|
def check_validate_date(self, config):
|
||||||
|
@ -24,15 +24,16 @@ flectra.define('FlectraLicensing.DialogRegisterContract', function (require) {
|
|||||||
save: function () {
|
save: function () {
|
||||||
var contract_id = this.$el.find('#contract_id').val();
|
var contract_id = this.$el.find('#contract_id').val();
|
||||||
var self = this;
|
var self = this;
|
||||||
if (!contract_id) {
|
var type = this.$el.find("input[name='activate']:checked").val();
|
||||||
|
if (!contract_id || !type) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rpc.query({
|
rpc.query({
|
||||||
model: 'ir.http',
|
model: 'ir.http',
|
||||||
method: 'contract_validate_file',
|
method: 'contract_validate_file',
|
||||||
args: [contract_id]
|
args: [contract_id,type]
|
||||||
}).done(function (bin) {
|
}).done(function (bin) {
|
||||||
self.trigger('get_key', {'key': contract_id, 'binary': bin});
|
self.trigger('get_key', {'key': contract_id, 'binary': bin, 'type': type});
|
||||||
self.close();
|
self.close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,17 @@ return AbstractWebClient.extend({
|
|||||||
session.get_file({
|
session.get_file({
|
||||||
url: '/flectra/licensing',
|
url: '/flectra/licensing',
|
||||||
data: {
|
data: {
|
||||||
'binary': key['binary']
|
'binary': key['binary'],
|
||||||
|
'type': key['type'],
|
||||||
|
'contract_id': key['key']
|
||||||
|
},
|
||||||
|
error: function (err) {
|
||||||
|
new require('web.Dialog').alert(null,err['message']);
|
||||||
|
},
|
||||||
|
success:function () {
|
||||||
|
if (key['type'] === 'online') {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -291,7 +301,7 @@ return AbstractWebClient.extend({
|
|||||||
overlayCSS: {cursor: 'auto'}
|
overlayCSS: {cursor: 'auto'}
|
||||||
});
|
});
|
||||||
self.contract_expired();
|
self.contract_expired();
|
||||||
}, 15000);
|
}, 150000);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -122,6 +122,14 @@
|
|||||||
<div t-name="FlectraLicense.dialog_contract_registration" >
|
<div t-name="FlectraLicense.dialog_contract_registration" >
|
||||||
<div id="register_contract_form">
|
<div id="register_contract_form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
<div>
|
||||||
|
<label for="activate_online">
|
||||||
|
<input id="activate_online" type="radio" name="activate" value="online">Online</input>
|
||||||
|
</label>
|
||||||
|
<label for="activate_offline">
|
||||||
|
<input id="activate_offline" type="radio" name="activate" value="offline" checked="">Offline</input>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<label for="contract_id">Contract ID</label>
|
<label for="contract_id">Contract ID</label>
|
||||||
<input type="text" class="form-control" id="contract_id" placeholder="Contract ID"/>
|
<input type="text" class="form-control" id="contract_id" placeholder="Contract ID"/>
|
||||||
<input type="hidden" value=""/>
|
<input type="hidden" value=""/>
|
||||||
|
Loading…
Reference in New Issue
Block a user