def test_add_months(self):
		"""
		Test two cases of add_month method
		"""
		date = datetime.datetime(2015, 10, 30, 20, 0, 0)
		self.assertEquals(CommonService.add_months(date, 1), datetime.datetime(2015, 11, 30, 20, 0, 0))
		self.assertEquals(CommonService.add_months(date, 4), datetime.datetime(2016, 02, 29, 20, 0, 0))
Пример #2
0
    def test_add_months(self):
        """
		Test two cases of add_month method
		"""
        date = datetime.datetime(2015, 10, 30, 20, 0, 0)
        self.assertEquals(CommonService.add_months(date, 1),
                          datetime.datetime(2015, 11, 30, 20, 0, 0))
        self.assertEquals(CommonService.add_months(date, 4),
                          datetime.datetime(2016, 02, 29, 20, 0, 0))
Пример #3
0
	def extend_subscription(user_profile, duration):
		"""
		Extend profile subscription
		:param user: User instance
		:param duration: {int} duration in month
		:return:
		"""
		user_profile = UserProfile.objects.get(pk=user_profile.pk)

		if user_profile.date_subscribe_ended and user_profile.date_subscribe_ended.replace(tzinfo=pytz.utc).replace(tzinfo=None) > datetime.datetime.now(tz=pytz.timezone(pytz.country_timezones['RU'][1])).replace(tzinfo=None):
			new_date = CommonService.add_months(user_profile.date_subscribe_ended, duration)
		else:
			new_date = CommonService.add_months(datetime.datetime.now(), duration)

		user_profile.date_subscribe_ended = new_date
		user_profile.save()
	def confirm(self, **kwargs):
		"""
		Execute confirm transaction
		:return: transact
		"""
		self.__transact.status_id = 2
		self.__transact.expiration_date = CommonService.add_months(datetime.datetime.now(), self.__transact.duration)
		return self.__save(self.__extend_subscription)
Пример #5
0
    def confirm(self, **kwargs):
        """
		Execute confirm transaction
		:return: transact
		"""
        self.__transact.status_id = 2
        self.__transact.expiration_date = CommonService.add_months(
            datetime.datetime.now(), self.__transact.duration)
        return self.__save(self.__extend_subscription)