def create(self, request): """docstring for create""" title = request.POST["title"] start_time = parse_date(request.POST["date1"] + " " + request.POST["time1"]) end_time = parse_date(request.POST["date2"] + " " + request.POST["time2"]) event = Event(title=title, start_time=start_time, end_time=end_time).save() return event
def test_parse_data_method(self): dates = [ '2005-09-19', '2007-09-24', '2004-09-22', '2011-06-23', '2011-09-20', '2010-10-31', '2007-12-05', '2015-6-5' ] for date in dates: self.assertNotEqual(utils.parse_date(date), None) self.assertEqual(utils.parse_date("invalid date"), None)
def create(self, request, cal_id): """docstring for create""" title = request.POST["title"] start_time = parse_date(request.POST["date1"] + " " + request.POST["time1"]) end_time = parse_date(request.POST["date2"] + " " + request.POST["time2"]) event = Event.objects.get(id=cal_id) event.title = title event.start_time = start_time event.end_time = end_time event.save() return event
def get_show_data(self): episodes = {} for episode_data in parse_epguides_data(self.epguide_name): try: season_number = int(episode_data['season']) except ValueError: continue try: number = int(episode_data['number']) except ValueError: continue try: title = "".join(episode_data['title']).encode("utf-8") except ValueError: continue if not title: continue if season_number not in episodes: episodes[season_number] = [] parsed_date = parse_date(episode_data['release_date']) if not parsed_date: continue episode = Episode( self, season_number, { 'number': number, 'title': episode_data['title'], 'release_date': parsed_date }) episodes[season_number].append(episode) return episodes