Esempio n. 1
0
    def on_post(self, req, resp):
        try:
            user = req.context['user']
            year = req.context['year']

            # Vytvorit novou vlnu mohou jen admini.
            if (not user.is_logged_in()) or (not user.is_admin()):
                resp.status = falcon.HTTP_400
                return

            data = json.loads(req.stream.read().decode('utf-8'))['wave']

            wave = model.Wave(year=year,
                              index=data['index'],
                              caption=data['caption'],
                              garant=data['garant'],
                              time_published=dateutil.parser.parse(
                                  data['time_published']))

            session.add(wave)
            session.commit()
            req.context['result'] = {'wave': util.wave.to_json(wave)}
        except SQLAlchemyError:
            session.rollback()
            raise
        finally:
            session.close()
Esempio n. 2
0
    def setUp(self):
        self.test_wave_data = TEST_WAVE_DATA.copy()
        self.test_wavelet_data = TEST_WAVELET_DATA.copy()
        self.test_blip_data = TEST_BLIP_DATA.copy()

        self.wave = model.Wave(self.test_wave_data)
        self.wavelet = model.Wavelet(self.test_wavelet_data)
        self.blip = model.Blip(self.test_blip_data)

        self.test_context = model.Context()
        self.test_context.waves[self.wave.waveId] = self.wave
        self.test_context.wavelets[self.wavelet.waveletId] = self.wavelet
        self.test_context.blips[self.blip.blipId] = self.blip
Esempio n. 3
0
 def testDefaults(self):
     empty_json = {}
     self.verifySameAttributes(self.blip, model.Blip(empty_json))
     self.verifySameAttributes(self.wave, model.Wave(empty_json))
     self.verifySameAttributes(self.wavelet, model.Wavelet(empty_json))
 def testWaveFields(self):
     w = model.Wave(self.test_wave_data)
     self.assertEquals(self.test_wave_data.id, w.GetId())
     self.assertEquals(self.test_wave_data.wavelet_ids, w.GetWaveletIds())