예제 #1
0
파일: api.py 프로젝트: javanna2000/udata
 def post(self, org):
     """Create a new badge for a given organization"""
     Form = badge_form(Organization)
     form = api.validate(Form)
     badge = Badge(created=datetime.now(), created_by=current_user.id)
     form.populate_obj(badge)
     for existing_badge in org.badges:
         if existing_badge.kind == badge.kind:
             return existing_badge
     org.add_badge(badge)
     return badge, 201
예제 #2
0
파일: api.py 프로젝트: javanna2000/udata
 def post(self, dataset):
     '''Create a new badge for a given dataset'''
     Form = badge_form(Dataset)
     form = api.validate(Form)
     badge = Badge(created=datetime.now(),
                   created_by=current_user.id)
     form.populate_obj(badge)
     for existing_badge in dataset.badges:
         if existing_badge.kind == badge.kind:
             return existing_badge
     dataset.add_badge(badge)
     return badge, 201