def handle_noargs(self, **options): logging.info('cron_bonus.py started @ %s' % str(datetime.datetime.now())) b = Bonus() b.start() logging.info('cron_bonus.py finished @ %s' % str(datetime.datetime.now()))
def handle_noargs(self, **options): logging.info('cron_cash_per_day.py started @ %s' % str(datetime.datetime.now())) cpd = CashPerDay() cpd.start() logging.info('cron_cash_per_day.py finished @ %s' % str(datetime.datetime.now()))
def handle_noargs(self, **options): logging.info('cron_credits.py started @ %s' % str(datetime.datetime.now())) fc = FreeCredit() fc.start() logging.info('cron_credits.py finished @ %s' % str(datetime.datetime.now()))
def start(self): auctions = AuctionModel.objects.filter(end_at__lt=datetime.datetime.now, is_refunded=False) for self.auction in auctions: logging.info("Finishing auction of %s" % self.auction.title) self.bids = AuctionOffer.objects.get_by_auction(auction=self.auction) self.finish_auction(self.auction.id)
def handle_noargs(self, **options): opts, args = getopt.getopt(sys.argv[1:], "clstu") logging.info('cron_sql_purge.py started @ %s' % str(datetime.datetime.now())) s = Sql() s.start() logging.info('cron_sql_purge.py finished @ %s' % str(datetime.datetime.now()))
def offerpal(request, site): """The callback server URL is how our servers ping your servers on offer completions. Notes: The callback URL format you will receive from our servers is as shown below: http://www.yourserver.com/anypath/reward.php?snuid=[Facebook user ID]¤cy=[currency credit to user] snuid is the users id value of the Facebook user ID currency is the positive whole number Security: For security you can optionally white list Offerpal Media server IPs: 74.205.58.114 99.132.162.242 99.132.162.243 99.132.162.244 99.132.162.245 """ from crims.main.models import Payment from crims.userprofile.models import UserProfile from django.core.mail import send_mail pay = Payment() pay.user_id = request.GET['snuid'] pay.site = site pay.provider = 'offerpal' pay.details = str(request.GET) pay.credits = request.GET['currency'] pay.total_credits = 0 if site == 'fb': profile = UserProfile.objects.get_by_fb_id(request.GET['snuid']) else: profile = UserProfile.objects.get_by_id(request.GET['snuid']) if profile is None: pay.status = 'user_not_found' pay.save() send_mail("Payment failure: user_not_found: %s" % request.GET['snuid'], '', 'Crime Corp <*****@*****.**>', ("*****@*****.**",), fail_silently=True) return HttpResponse(0) profile.earn('credit', request.GET['currency']) pay.status = 'ok' pay.save() logging.info("Dodano %s kredytów" % str(pay.credits)) if int(pay.credits) > 3: send_mail("Payment success at %s by %s" % (pay.site, str(pay.user_id)), "%s credits added. %s do far payed by him" % (str(pay.credits), str(pay.total_credits)), 'Crime Corp <*****@*****.**>', ("*****@*****.**",), fail_silently=True) return HttpResponse(1)
def handle_noargs(self, **options): logging.info('cron_auto_auction.py started @ %s' % str(datetime.datetime.now())) CONFIG = {'6': 1, '5': 1, '4': 3, '3': 3, '2': 5, '1': 5} tier = {} for x in xrange(1, 7): tier[str(x)] = Item.objects.filter(is_active=True, is_premium=False, is_unique=False, tier=x, type='vehicle') for k, v in CONFIG.iteritems(): if not tier.has_key(k) or len(tier[k]) == 0: continue [self.__add_auction(random.choice(tier[k])) for x in xrange(0, v)] logging.info('cron_auto_auction.py finished @ %s' % str(datetime.datetime.now()))
def _send_to_user(self, sender, user, txt, gang=False): msg = Msg() msg.sender = sender msg.receiver = user if txt.startswith('@'): msg.is_public = False else: msg.is_public = True msg.content = txt msg.is_gang = gang msg.save() logging.info('sent message from %s to %s' % (sender, user)) return True
def srpoints(request, site): """ On the postback, we send the following query arguments: new - user earned by filling out offer 'oid' total - total amount of accumulated by this user uid - the site's user uid (facebook, myspace, etc) oid - SuperRewards offer identifier You must reply: 1 - if you updated your system successfully 0 - if there is a problem on your end (we'll wait and resend the postback again) The reply should be just 1 digit (no xml, no tags, just 1 byte reply) Example: http://www.domain.com/postback.cgi?app=mygreatapp&new=25&total=1000&uid=1234567&oid=123 Important 1. 'oid' + 'uid' is not a unique cominbation. There are offers that users can fill out several times and get credited for them. 2. Please always rely on total value in your calculations. """ import md5 valid = md5.new( request.GET['id'] + ':' + request.GET['new'] + ':' + request.GET['uid'] + ':' + settings.SRPOINTS_SECRET[ str(site)]).hexdigest() from crims.main.models import Payment from crims.userprofile.models import UserProfile from django.core.mail import send_mail pay = Payment() pay.user_id = request.GET['uid'] pay.site = site pay.provider = 'srpoints' pay.details = str(request.GET) pay.credits = request.GET['new'] pay.total_credits = request.GET['total'] if valid != request.GET['sig']: pay.status = 'invalid_transaction' pay.save() send_mail("Payment failure: invalid_transaction by %s" % request.GET['uid'], '', 'Crime Corp <*****@*****.**>', ("*****@*****.**",), fail_silently=True) return HttpResponse(0) if site == 'fb': profile = UserProfile.objects.get_by_fb_id(request.GET['uid']) else: profile = UserProfile.objects.get_by_id(request.GET['uid']) if profile is None: pay.status = 'user_not_found' pay.save() send_mail("Payment failure: user_not_found: %s" % request.GET['uid'], '', 'Crime Corp <*****@*****.**>', ("*****@*****.**",), fail_silently=True) return HttpResponse(0) profile.earn('credit', request.GET['new']) pay.status = 'ok' pay.save() logging.info("Dodano %s kredytów" % str(pay.credits)) if int(pay.credits) > 3: send_mail("Payment success at %s by %s" % (pay.site, str(pay.user_id)), "%s credits added. %s do far payed by him" % (str(pay.credits), str(pay.total_credits)), 'Crime Corp <*****@*****.**>', ("*****@*****.**",), fail_silently=True) return HttpResponse(1)
def register(request): message = None form = RegistrationForm() if request.method == 'POST' and request.POST['action_type'] == 'login': username = slughifi(request.POST['username']) password = request.POST['password'] user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) response = HttpResponseRedirect(reverse('home')) # get_invite_cookie(request, response, user) return response else: message = _("Account inactive.") else: message = _("Entered nickname and password combination is not correct") if request.method == 'POST' and request.POST['action_type'] == 'register': form = RegistrationForm(request.POST) if form.is_valid(): profile = UserProfile() profile.user = User.objects.create_user(form.cleaned_data['username'], form.cleaned_data['email'], form.cleaned_data['password1']) profile.username = form.cleaned_data['username'] profile.add_log(log_type='register', log_type_id=profile.user.id, log='from web', ip=request.META.get('REMOTE_ADDR')) # create city from crims.city.models import CityMap, Sector city = CityMap() city.owner_id = profile.user.id city.orig_owner_id = profile.user.id city.name = profile.username city.population = settings.DEFAULT_CITY_POPULATION city.sector, city.position = Sector.objects.next_cords() city.save() profile.default_city_id = city.id profile.active_city_id = city.id profile.save() # profile.user.is_active = False # profile.user.save() # refresh city task from crims.common.models import Task task = Task() task.source = 'city' task.user_id = profile.user.id task.task = city.id task.save() user = authenticate(username=form.cleaned_data['username'], password=form.cleaned_data['password1']) login(request, user) logging.info("%s registered on the web" % form.cleaned_data['username']) response = HttpResponseRedirect(reverse('home')) # get_invite_cookie(request, response, profile) return response # extra actions # message="Account created. Check your email and wait for link to activate your account." return render_to_response('main/preview.html', { 'form': form, 'message': message, }, context_instance=RequestContext(request))