def askme_command(self, message=None): im_from = db.IM("xmpp", message.sender) currently_answering = self._GetAnswering(im_from) question = Question.assignQuestion(im_from) if question: message.reply(TELLME_MSG % (question.question, )) else: message.reply(EMPTYQ_MSG) # Don't unassign their current question until we've picked a new one. if currently_answering: currently_answering.unassign(im_from)
def feeds_cmd(jid): """FEEDS Get list of feeds. """ account = Account.get_or_insert(jid, jid=db.IM('xmpp', jid)) q = account.accountfeed_set count = q.count() if count == 0: return "You have no feeds.\n" return "List of your feeds:\n" + "\n".join([ '%s %s' % (af.feed.url, af.keywords) if af.keywords else af.feed.url for af in q.fetch(count) ]) + '\n'
def setting(request): settings = UserSettings.getByCurrentUser() im_protocol = settings.im.protocol if settings.im is not None else '' im_address = settings.im.address if settings.im is not None else '' if request.method == 'GET': form = UserSettingsForm({ 'firstname': settings.firstname, 'lastname': settings.lastname, 'gender': settings.gender, 'profile': settings.profile, 'language': settings.language, 'birthdate': settings.birthdate, 'website': settings.website, 'home_phone': settings.home_phone, 'work_phone': settings.work_phone, 'mobile': settings.mobile, 'fax': settings.fax, 'address': settings.address }) if request.method == 'POST': form = UserSettingsForm(request.POST) logging.getLogger().debug(form) if form.is_valid(): modified_settings = form.save(commit=False) settings.lastname = modified_settings.lastname settings.firstname = modified_settings.firstname settings.gender = modified_settings.gender settings.profile = modified_settings.profile settings.language = modified_settings.language settings.birthdate = modified_settings.birthdate settings.website = modified_settings.website settings.home_phone = modified_settings.home_phone settings.work_phone = modified_settings.work_phone settings.mobile = modified_settings.mobile settings.fax = modified_settings.fax settings.address = modified_settings.address if request.POST['im_address'] is not u'': settings.im = db.IM(request.POST['im_protocol'], request.POST['im_address']) settings.put() return HttpResponseRedirect('/') return render_to_response('setting.html', { 'im_protocol': im_protocol, 'im_address': im_address, 'form': form }, context_instance=RequestContext(request))
def tellme_command(self, message=None): im_from = db.IM("xmpp", message.sender) asked_question = self._GetAsked(im_from) currently_answering = self._GetAnswering(im_from) if asked_question: # Already have a question message.reply(WAIT_MSG) else: # Asking a question asked_question = Question(question=message.arg, asker=im_from) asked_question.put() if not currently_answering: # Try and find one for them to answer question = Question.assignQuestion(im_from) if question: message.reply(TELLME_MSG % (question.question, )) return message.reply(PONDER_MSG)
def text_message(self, message=None): im_from = db.IM("xmpp", message.sender) question = self._GetAnswering(im_from) question2 = Question.get_by_id(6003) message.reply('___________\n') message.reply(question2.answer) message.reply('test') message.reply('___________\n') if question: other_assignees = question.assignees other_assignees.remove(im_from) # Answering a question question.answer = message.arg question.answerer = im_from question.assignees = [] question.answered = datetime.datetime.now() question.put() # Send the answer to the asker xmpp.send_message([question.asker.address], ANSWER_INTRO_MSG % (question.question, )) xmpp.send_message([question.asker.address], ANSWER_MSG % (message.arg, )) # Send acknowledgement to the answerer asked_question = self._GetAsked(im_from) if asked_question: message.reply(TELLME_THANKS_MSG) else: message.reply(THANKS_MSG) # Tell any other assignees their help is no longer required if other_assignees: xmpp.send_message([x.address for x in other_assignees], SOMEONE_ANSWERED_MSG) else: self.unhandled_command(message)
bool=True, int=10, float=5.05, datetime=d, date=d.date(), time=d.time(), list=[1, 2, 3], strlist=["hello", u'world'], user=users.User("*****@*****.**"), blob=db.Blob("somerandomdata"), text=db.Text("some random text"), category=db.Category("awesome"), link=db.Link("http://www.10gen.com"), email=db.Email("*****@*****.**"), geopt=db.GeoPt(40.74067, -73.99367), im=db.IM("http://aim.com/", "example"), phonenumber=db.PhoneNumber("1 (999) 123-4567"), postaladdress=db.PostalAddress("40 W 20th St., New York, NY"), rating=db.Rating(99), ) out = db.get(e1.put()) def failIfNot(reference, value, type): assert value == reference assert isinstance(value, type) failIfNot(e1.str, out.str, types.UnicodeType) failIfNot(e1.bool, out.bool, types.BooleanType)
def by_jid(cls, jid): return cls.get_or_insert(jid, jid=db.IM('xmpp', jid))
def _get_current_follower(self, message): im_from = db.IM("xmpp", get_bare_jid(message.sender)) return FollowerId.create(im_from)
def _get_current_followers(self, message): im_from = db.IM("xmpp", get_bare_jid(message.sender)) return Follower2.all().filter('follower', im_from)