コード例 #1
0
ファイル: models.py プロジェクト: shula/citytree
 def make_sure_workshop_exists(self):
     # basically a gradual update measure - posts that are on a blog that is a workshop
     # should always have a Workshop instance pointing at them, but it didn't use to be that way.
     if self.blog.is_workshop() and self.workshop_set.count() == 0:
         from workshop.models import Workshop
         self.workshop_set.add(Workshop.create_workshop_by_post(self))
         self.save()
コード例 #2
0
ファイル: views.py プロジェクト: shula/citytree
    def _create_new(self):
        # TODO: check that user has permissions (easy to do here, but must make sure its actually
        # set at the right point.

        # take initial values from another event of the same workshop first
        base_event = None
        if self.workshop.workshopevent_set.count() > 0:
            events = self.workshop.workshopevent_set.order_by('-workshopeventpart__start_time')
            if len(events) > 0:
                base_event = events[0]
        if base_event is None:
            # last, take initial values from the default workshop event
            default_workshop = Workshop.get_default_workshop()
            base_event = default_workshop.workshopevent_set.get()
        self._initial.update(base_event.get_new_event_dict())
コード例 #3
0
from workshop.models import Workshop
import json

with open('workshopDetails.json') as workshopData:

    dataObject = json.load(
        workshopData)  # load in the registrant data from the JSON file

    # for each object in the list with key registrants, create a new Registrant object and add it to a list of objects
    for workshop in dataObject['workshops']:
        r = Workshop(**workshop)
        r.save()