-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wysyłaj zakres stron do PBN API (#1176)
- Loading branch information
1 parent
7b9b8bb
commit 087ade0
Showing
4 changed files
with
64 additions
and
1 deletion.
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
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,23 @@ | ||
import json | ||
|
||
from pbn_api.adapters.wydawnictwo import WydawnictwoPBNAdapter | ||
from pbn_api.management.commands.util import PBNBaseCommand | ||
|
||
from django.contrib.contenttypes.models import ContentType | ||
|
||
|
||
class Command(PBNBaseCommand): | ||
help = "pokaż kod JSON wygenerowany dla publikacji" | ||
|
||
def add_arguments(self, parser): | ||
super().add_arguments(parser) | ||
parser.add_argument("model_name") | ||
parser.add_argument("id", type=int) | ||
|
||
def handle(self, model_name, id, *args, **kw): | ||
obj = ContentType.objects.get( | ||
app_label="bpp", model=model_name | ||
).get_object_for_this_type(id=id) | ||
adapted = WydawnictwoPBNAdapter(obj) | ||
data = adapted.pbn_get_json() | ||
print(json.dumps(data, indent=4, sort_keys=True)) |
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