示例#1
0
    def register(self, request, **kwargs):
        """
        Given a username, email address and password, register a new
        user account, which will initially be inactive.

        Along with the new ``User`` object, a new
        ``registration.models.RegistrationProfile`` will be created,
        tied to that ``User``, containing the activation key which
        will be used for this account.

        An email will be sent to the supplied email address; this
        email should contain an activation link. The email will be
        rendered using two templates. See the documentation for
        ``RegistrationProfile.send_activation_email()`` for
        information about these templates and the contexts provided to
        them.

        After the ``User`` and ``RegistrationProfile`` are created and
        the activation email is sent, the signal
        ``registration.signals.user_registered`` will be sent, with
        the new ``User`` as the keyword argument ``user`` and the
        class of this backend as the sender.

        """
        username, email, password, first_name, last_name = kwargs['username'], kwargs['email'], kwargs['password1'], kwargs['first_name'], kwargs['last_name']
        if Site._meta.installed:
            site = Site.objects.get_current()
        else:
            site = RequestSite(request)

        try:
            new_user = RegistrationProfile.objects.create_inactive_user(username, email,
                                                                        password, site, first_name, last_name)
        except:
            new_user = User.objects.get(username=username)
            logging.error("user creation failed, probably email related")
            
        new_station = Station()
        new_station.user = new_user
        new_station.address = kwargs['address']
        new_station.city = kwargs['city']
        new_station.country = kwargs['country']
        new_station.name = kwargs['name']
        new_station.license_number = kwargs['license_number']
        new_station.website_url = kwargs['website_url']
        new_station.number_of_taxis = kwargs['number_of_taxis']
        new_station.description = kwargs['description']
        new_station.logo = kwargs['logo']
        new_station.language = kwargs['language']
        new_station.save()

        phone = Phone()
        phone.station = new_station
        phone.local_phone = kwargs['local_phone']
        phone.save()

        signals.user_registered.send(sender=self.__class__,
                                     user=new_user,
                                     request=request)
        return new_user
def create_test_stations():
    # one in Tel Aviv
    station_name = STATION_NAMES[0]

    station = Station()
    station.name = station_name
    station.user = User.objects.get(username=station_name)
    station.number_of_taxis = 5
    station.country = Country.objects.filter(code="IL").get()
    station.city = City.objects.get(name="תל אביב יפו")
    station.address = 'דיזנגוף 99 תל אביב יפו'
    station.lat = 32.07938
    station.lon = 34.773896
    station.save()

    phone = Phone(local_phone=u'1234567', station=station)
    phone.save()

    # and one in Jerusalem
    station_name = STATION_NAMES[1]

    station = Station()
    station.name = station_name
    station.user = User.objects.get(username=station_name)
    station.number_of_taxis = 5
    station.country = Country.objects.filter(code="IL").get()
    station.city = City.objects.get(name="ירושלים")
    station.address = 'בן יהודה 35 ירושלים'
    station.lat = 31.780725
    station.lon = 35.214161
    station.save()

    phone = Phone(local_phone=u'1234567', station=station)
    phone.save()
示例#3
0
def create_selenium_station(user):
    selenium_station = Station(name="selenium_station",
                               user=user,
                               number_of_taxis=5,
                               country=Country.objects.filter(code="IL").get(),
                               city=City.objects.get(name=SELENIUM_CITY_NAME),
                               address=SELENIUM_ADDRESS,
                               lat=32.105137,
                               lon=35.198071,
                               license_number="1234",
                               postal_code='1234',
                               website_url="http://selenium.waybetter.com")
    selenium_station.save()

    phone = Phone(local_phone=SELENIUM_PHONE, station=selenium_station)
    phone.save()

    #    selenium_station.build_workstations()

    return selenium_station
def create_test_stations():
    # one in Tel Aviv
    station_name = STATION_NAMES[0]

    station = Station()
    station.name = station_name
    station.user = User.objects.get(username=station_name)
    station.number_of_taxis = 5
    station.country = Country.objects.filter(code="IL").get()
    station.city = City.objects.get(name="תל אביב יפו")
    station.address = 'דיזנגוף 99 תל אביב יפו'
    station.lat = 32.07938
    station.lon = 34.773896
    station.save()

    phone = Phone(local_phone=u'1234567', station=station)
    phone.save()

    # and one in Jerusalem
    station_name = STATION_NAMES[1]

    station = Station()
    station.name = station_name
    station.user = User.objects.get(username=station_name)
    station.number_of_taxis = 5
    station.country = Country.objects.filter(code="IL").get()
    station.city = City.objects.get(name="ירושלים")
    station.address = 'בן יהודה 35 ירושלים'
    station.lat = 31.780725
    station.lon = 35.214161
    station.save()

    phone = Phone(local_phone=u'1234567', station=station)
    phone.save()
示例#5
0
def create_selenium_station(user):
    selenium_station = Station(
        name="selenium_station",
        user=user,
        number_of_taxis=5,
        country=Country.objects.filter(code="IL").get(),
        city=City.objects.get(name=SELENIUM_CITY_NAME),
        address=SELENIUM_ADDRESS,
        lat=32.105137,
        lon=35.198071,
        license_number="1234",
        postal_code="1234",
        website_url="http://selenium.waybetter.com",
    )
    selenium_station.save()

    phone = Phone(local_phone=SELENIUM_PHONE, station=selenium_station)
    phone.save()

    #    selenium_station.build_workstations()

    return selenium_station
示例#6
0
 def setUp(self):
     setup_testing_env.setup()
     self.passenger = create_passenger()
     self.order = create_test_order()
     self.station = Station.objects.get(name='test_station_1')
     self.work_station = WorkStation.objects.filter(station=self.station)[0]
     self.assignment = OrderAssignment(order=self.order,
                                       station=self.station,
                                       work_station=self.work_station)
     self.assignment.save()
     # TODO_WB: remove when we have new fixtures
     phone1 = Phone(local_phone=u'1234567', station=self.station)
     phone1.save()
     phone2 = Phone(local_phone=u'0000000', station=self.station)
     phone2.save()
示例#7
0
 def setUp(self):
     setup_testing_env.setup()
     self.passenger = create_passenger()
     self.order = create_test_order()
     self.station = Station.objects.get(name='test_station_1')
     self.work_station = WorkStation.objects.filter(station=self.station)[0]
     self.assignment = OrderAssignment(order=self.order, station=self.station, work_station=self.work_station)
     self.assignment.save()
     # TODO_WB: remove when we have new fixtures
     phone1 = Phone(local_phone=u'1234567', station=self.station)
     phone1.save()
     phone2 = Phone(local_phone=u'0000000', station=self.station)
     phone2.save()
示例#8
0
    def register(self, request, **kwargs):
        """
        Given a username, email address and password, register a new
        user account, which will initially be inactive.

        Along with the new ``User`` object, a new
        ``registration.models.RegistrationProfile`` will be created,
        tied to that ``User``, containing the activation key which
        will be used for this account.

        An email will be sent to the supplied email address; this
        email should contain an activation link. The email will be
        rendered using two templates. See the documentation for
        ``RegistrationProfile.send_activation_email()`` for
        information about these templates and the contexts provided to
        them.

        After the ``User`` and ``RegistrationProfile`` are created and
        the activation email is sent, the signal
        ``registration.signals.user_registered`` will be sent, with
        the new ``User`` as the keyword argument ``user`` and the
        class of this backend as the sender.

        """
        username, email, password, first_name, last_name = kwargs[
            'username'], kwargs['email'], kwargs['password1'], kwargs[
                'first_name'], kwargs['last_name']
        if Site._meta.installed:
            site = Site.objects.get_current()
        else:
            site = RequestSite(request)

        try:
            new_user = RegistrationProfile.objects.create_inactive_user(
                username, email, password, site, first_name, last_name)
        except:
            new_user = User.objects.get(username=username)
            logging.error("user creation failed, probably email related")

        new_station = Station()
        new_station.user = new_user
        new_station.address = kwargs['address']
        new_station.city = kwargs['city']
        new_station.country = kwargs['country']
        new_station.name = kwargs['name']
        new_station.license_number = kwargs['license_number']
        new_station.website_url = kwargs['website_url']
        new_station.number_of_taxis = kwargs['number_of_taxis']
        new_station.description = kwargs['description']
        new_station.logo = kwargs['logo']
        new_station.language = kwargs['language']
        new_station.save()

        phone = Phone()
        phone.station = new_station
        phone.local_phone = kwargs['local_phone']
        phone.save()

        signals.user_registered.send(sender=self.__class__,
                                     user=new_user,
                                     request=request)
        return new_user