Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: manual CDR import on Admin (csv, json, yaml)
- Loading branch information
Showing
10 changed files
with
149 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
switch,cdr_source_type,callid,caller_id_number,caller_id_name,destination_number,dialcode,state,channel,starting_date,duration,billsec,progresssec,answersec,waitsec,hangup_cause_id,hangup_cause,direction,country_code,accountcode,buy_rate,buy_cost,sell_rate,sell_cost,extradata | ||
127.0.0.1,1,96aa82fe-7bd1-11e5-a230-5c514f6a0f72,904151440,CallerIDName,+34798400122,34,,,2015-10-21 12:13:10,55,50,,,,16,,1,,1000,,,,,{} | ||
127.0.0.1,1,c9135e4a-7bd1-11e5-a230-5c514f6a0f72,904234320,CallerIDName,+34798401111,34,,,2015-10-21 12:33:15,15,10,,,,16,,1,,1000,,,,,{} | ||
127.0.0.1,1,cfaf8b56-7bd1-11e5-a230-5c514f6a0f72,901110380,CallerIDName,+34650104877,34,,,2015-10-21 12:53:16,41,34,,,,16,,1,,1000,,,,,{} | ||
127.0.0.1,1,3c64a168-7bd2-11e5-a230-5c514f6a0f72,904234320,CallerIDName,+34798401111,34,,,2015-10-21 12:53:16,16,11,,,,16,,1,,1000,,,,,{} | ||
127.0.0.1,1,41b20dd9-7bd2-11e5-a230-5c514f6a0f72,904231111,CallerIDName,+34650104877,34,,,2015-10-21 12:53:16,8,5,,,,16,,1,,1000,,,,,{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# | ||
# CDR-Stats License | ||
# http://www.cdr-stats.org | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# | ||
# Copyright (C) 2011-2015 Star2Billing S.L. | ||
# | ||
# The Initial Developer of the Original Code is | ||
# Arezqui Belaid <info@star2billing.com> | ||
# | ||
|
||
|
||
""" | ||
We implemented a router cause django-import-export doesn't have a mechanism | ||
to specify the database with `using` | ||
https://github.com/django-import-export/django-import-export | ||
""" | ||
|
||
|
||
class CDRImportRouter(object): | ||
""" | ||
A router to control all database operations on models. | ||
""" | ||
def db_for_read(self, model, **hints): | ||
""" | ||
Attempts to read auth models go to import_cdr. | ||
""" | ||
if model._meta.app_label == 'import_cdr': | ||
return 'import_cdr' | ||
return None | ||
|
||
def db_for_write(self, model, **hints): | ||
""" | ||
Attempts to write auth models go to import_cdr. | ||
""" | ||
if model._meta.app_label == 'import_cdr': | ||
return 'import_cdr' | ||
return None | ||
|
||
def allow_relation(self, obj1, obj2, **hints): | ||
""" | ||
Allow relations if a model in the import_cdr app is involved. | ||
""" | ||
if obj1._meta.app_label == 'import_cdr' or \ | ||
obj2._meta.app_label == 'import_cdr': | ||
return True | ||
return None | ||
|
||
def allow_migrate(self, db, app_label, model=None, **hints): | ||
""" | ||
Make sure the auth app only appears in the 'import_cdr' | ||
database. | ||
""" | ||
if app_label == 'import_cdr': | ||
return db == 'import_cdr' | ||
return None |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters