Exemplo n.º 1
0
 def test_get_speakers_json(self):
     expected = [
         {
             "city": u"Zaragoza3",
             "first_name": u"Bill",
             "last_name": u"Gates",
             "twitter_id": u"",
             "computers_needed": True,
             "speaker": True,
             "email": u"*****@*****.**",
         },
         {
             "city": u"Valencia",
             "first_name": u"Manolo",
             "last_name": u"Bombo",
             "twitter_id": u"",
             "computers_needed": False,
             "speaker": True,
             "email": u"*****@*****.**",
         },
     ]
     self.attendant.set_as_speaker()
     self.attendant.put()
     attendant2 = Attendant.create(
         email="*****@*****.**",
         last_name="Bombo",
         first_name="Manolo",
         city="Valencia",
         computers_needed=False,
     )
     attendant2.set_as_speaker()
     attendant2.put()
     self.assertEquals(expected, Attendant.get_speakers_json())
Exemplo n.º 2
0
 def setUp(self):
     self.init_django_settings()
     self.init_testbed_for_datastore_tests()
     self.attendant = Attendant.create(email='*****@*****.**', last_name='Pantoja', first_name='Isabel', city='Sevilla', computers_needed=False)
     self.attendant.twitter_id = "@pantoja"
     self.attendant.put()
     self.attendant2 = Attendant.create(email='*****@*****.**', last_name='Smith', first_name='Will', city='Los Angeles', computers_needed=True)
     self.attendant2.put()
Exemplo n.º 3
0
 def test_create_attendance_constructor(self):
     attendant = Attendant.create("Asistente2", "Apellido2", "*****@*****.**", "Zaragoza2", False)
     attendant.put()
     db_attendant = Attendant.get_by_key_name("*****@*****.**")
     self.assertEquals("*****@*****.**", db_attendant.email)
     self.assertEquals("Asistente2", db_attendant.first_name)
     self.assertEquals("Apellido2", db_attendant.last_name)
     self.assertEquals("Zaragoza2", db_attendant.city)
     self.assertEquals(False, db_attendant.computers_needed)
Exemplo n.º 4
0
def get_speakers_list(request):
    if request.method == "GET":
        speakers = Attendant.get_speakers()
        return render_to_response(
            "speakers_list.html",
            {
                "attendants": json.dumps(Attendant.get_selection_array()),
                "speakers": speakers,
                "user": request.session.get("user"),
            },
        )
    else:
        speakers = Attendant.get(request.POST.getlist("speakers"))

        return HttpResponseRedirect("admin/speakers")
Exemplo n.º 5
0
 def test_create_attendance_constructor_named(self):
     attendant = Attendant.create(
         email="*****@*****.**",
         last_name="Apellido3",
         first_name="Asistente3",
         city="Zaragoza3",
         computers_needed=True,
     )
     attendant.put()
     db_attendant = Attendant.get_by_key_name("*****@*****.**")
     self.assertEquals("*****@*****.**", db_attendant.email)
     self.assertEquals("Asistente3", db_attendant.first_name)
     self.assertEquals("Apellido3", db_attendant.last_name)
     self.assertEquals("Zaragoza3", db_attendant.city)
     self.assertEquals(True, db_attendant.computers_needed)
Exemplo n.º 6
0
def get_avatar(request):
    if request.method == 'GET':
        email = request.GET.get('email', '')
        if Attendant.is_valid_email(email):
            attendant = Attendant.get_by_key_name(email)
            if attendant.twitter_id:
                if not attendant.twitter_avatar:
                    attendant.fetch_twitter_avatar()
                img_response = HttpResponse(mimetype="image/jpeg")
                img_response.content = attendant.twitter_avatar 
                return img_response
            else:
                return HttpResponse('No twitter account')
        else:
            return HttpResponse('Invalid email')
Exemplo n.º 7
0
def edit_attendant(request):
    email = request.GET.get('email', '')
    attendant = Attendant.get_by_key_name(email)
    if request.method == "GET":
        return show_attendant_form_to_edit(request, AttendantForm(instance=attendant))
    else:
        return save_attendant_form(request, attendant)
Exemplo n.º 8
0
 def test_get_selection_array(self):
     expected = [{"category": "Nombre", "value": "*****@*****.**", "label": "Isabel Pantoja"},
                  {"category": "Nombre", "value": "*****@*****.**", "label": "Will Smith"}, 
                  {"category": "Email", "value": "*****@*****.**", "label": "*****@*****.**"},
                  {"category": "Email", "value": "*****@*****.**", "label": "*****@*****.**"}, 
                  {"category": "Twitter", "value": "*****@*****.**", "label": "@pantoja"}]
     self.assertEqual(expected, Attendant.get_selection_array())
     
     
Exemplo n.º 9
0
 def test_fetch_twitter_avatar(self):
     attendant = Attendant.create(
         email="*****@*****.**",
         last_name="Apellido3",
         first_name="Asistente3",
         city="Zaragoza3",
         computers_needed=True,
     )
     attendant.twitter_id = "@gualison"
     attendant.fetch_twitter_avatar()
     self.assertTrue(attendant.twitter_avatar != None)
Exemplo n.º 10
0
def init_app(request):
    if request.method == 'GET':
        User.create_admin('admin', 'aos').put()
        Room.init_rooms()
        if not Talk.all().count(1) > 0:
            talk = Talk(title = 'Android', session=1)
            talk.set_room(Room.get_rooms()[0])
            talk.put()
            talk = Talk(title = 'Kanban', session=5)
            talk.set_room(Room.get_rooms()[1])
            talk.put()
        if not Attendant.all().count(1) > 0:
            bill = Attendant.create('Bill', 'Gates', '*****@*****.**', 'Zaragoza', False)
            bill.twitter_id = 'fbgblog'
            bill.set_as_speaker()
            bill.put()
            richard = Attendant.create('Richard', 'Stallman', '*****@*****.**', 'Pamplona', True)
            richard.twitter_id = 'GNUplusLINUX'
            richard.set_as_speaker()
            richard.put()
        return HttpResponse("App ready to rumble...", mimetype="text/plain")
Exemplo n.º 11
0
 def setUp(self):
     self.init_testbed_for_datastore_tests()
     self.init_django_settings()
     self.room1 = Room(name="sala1")
     self.room2 = Room(name="sala2")
     room_key1 = self.room1.put()
     room_key2 = self.room2.put()
     self.attendant_key = Attendant.create("Ponente1", "Apellido1", "*****@*****.**", "Zaragoza", False).put()
     self.talk1 = Talk(title="Titulo1", speaker=self.attendant_key, room=room_key1, session=4)
     self.talk1.put()
     Talk(title="Titulo2", speaker=self.attendant_key, room=room_key2).put()
     Talk(title="Titulo3", speaker=self.attendant_key, room=room_key1).put()
     self.talk_key_4 = Talk(title="Titulo4", speaker=self.attendant_key).put()
Exemplo n.º 12
0
    def setUp(self):
        self.init_django_settings()
        self.init_testbed_for_datastore_tests()
        self.init_for_url_fetch_tests()

        self.attendant = Attendant.create(
            email="*****@*****.**",
            last_name="Gates",
            first_name="Bill",
            city="Zaragoza3",
            computers_needed=True,
        )
        self.attendant.twitter_account = "@Billgates"
        self.attendant.put()
Exemplo n.º 13
0
def get_speakers_div():
    speakers = Attendant.get_speakers()
    return render_to_response("speakers.html", {"speakers": speakers})
Exemplo n.º 14
0
def get_attendant(request):
    if request.is_ajax():
        if request.method == "POST":
            email = request.POST.get("email", "")
            if Attendant.is_valid_email(email):
                return Attendant.get_by_key_name(email)
Exemplo n.º 15
0
 def clean(self):
     if not Attendant.is_valid_email(self.data['email']):
         raise ValidationError("Invalid email!")
     return super(AttendantForm, self).clean()
Exemplo n.º 16
0
def get_speakers(request):
    return JsonResponse(Attendant.get_speakers_json())
Exemplo n.º 17
0
 def __init__(self, *args, **kwargs):
     super(TalkForm, self).__init__(*args, **kwargs)
     self.fields['speaker'].query = Attendant.all().filter('speaker', True).fetch(100)
Exemplo n.º 18
0
 def test_fetch_talks_from_attendant(self):
     attendant = Attendant.all().filter("first_name", "Ponente1").get()
     self.assertEquals("Titulo1", attendant.talks[0].title)
     self.assertEquals("Titulo2", attendant.talks[1].title)
Exemplo n.º 19
0
 def test_search_unexisting_attendant(self):
     attendant = Attendant.all().filter("name", "PonenteN").fetch(1000)
     self.assertFalse(attendant)