Пример #1
0
class BadgeForm(ModelForm):
    model_class = ReuseBadge

    kind = fields.RadioField(
        _('Kind'), [validators.required()],
        choices=REUSE_BADGE_KINDS.items(),
        description=_('Kind of badge (dataconnexions, etc)'))
Пример #2
0
 def test_list(self):
     response = self.get(url_for('api.available_reuse_badges'))
     self.assertStatus(response, 200)
     self.assertEqual(len(response.json), len(REUSE_BADGE_KINDS))
     for kind, label in REUSE_BADGE_KINDS.items():
         self.assertIn(kind, response.json)
         self.assertEqual(response.json[kind], label)
Пример #3
0
 def test_create_2nd(self):
     # Explicitely setting the kind to avoid collisions given the
     # small number of choices for kinds.
     kinds_keys = REUSE_BADGE_KINDS.keys()
     self.reuse.badges.append(
         ReuseBadgeFactory(kind=kinds_keys[0]))
     self.reuse.save()
     data = ReuseBadgeFactory.attributes()
     data['kind'] = kinds_keys[1]
     with self.api_user():
         response = self.post(
             url_for('api.reuse_badges', reuse=self.reuse), data)
     self.assertStatus(response, 201)
     self.reuse.reload()
     self.assertEqual(len(self.reuse.badges), 2)
Пример #4
0
def reuse_badge_labelizer(label, kind):
    return REUSE_BADGE_KINDS.get(kind, '')
Пример #5
0
def reuse_badge_labelizer(label, kind):
    return REUSE_BADGE_KINDS.get(kind, '')