def send(self): """Send issues to the user.""" # Basic algorithm is similar to the one for `sendsub` # # * Get the number of issues processed during the last 24hs # for an user, and calculate the remaining number of # issues to send to this user. # # * Get the list Issues to send in order. # # * From the list, send the Issues that are allowed. # user = self.cleaned_data['subscription'].user remains = user.userprofile.remains() issues = self.cleaned_data['issues'] send(issues[:remains], user)
def send(self, issues, user_profile, accounts, loglevel, do_not_send): """Send a list of issues to an user.""" user = user_profile.user if do_not_send: # If the user have a subscription but we are not sending # issues, mark them as sent try: for issue in issues: subscription = Subscription.actives.get(user=user, manga=issue.manga) self.stdout.write("Marking '%s' as sent" % issue) subscription.add_sent(issue) except: msg = 'The user %s does not have a '\ 'subscription to %s' % (user, issue.manga) self.stdout.write(msg) else: send(issues, user, accounts, loglevel)