loadTags.py 571 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from backend_app.models.tag import Tag
Florent Chehab's avatar
Florent Chehab committed
2 3 4 5 6 7 8 9 10 11 12 13

import os
import json
from .loadGeneric import LoadGeneric


class LoadTags(LoadGeneric):
    def __init__(self, admin):
        self.admin = admin

    def load(self):

14
        tmp = os.path.join(os.path.realpath(__file__), "../../assets/tags.json")
Florent Chehab's avatar
Florent Chehab committed
15 16 17 18
        tags_path = os.path.abspath(tmp)
        with open(tags_path) as f:
            tags = json.load(f)
            for tag in tags:
19
                t = Tag(name=tag["name"], config=tag["config"])
Florent Chehab's avatar
Florent Chehab committed
20
                t.save()
21
                self.add_info_and_save(t, self.admin)