Exemplo n.º 1
0
def create_another_TLV_station(num_of_ws=1):
    # create another station in TLV
    tel_aviv = City.objects.get(name=u'תל אביב יפו')
    station_name = 'tel_aviv_%d' % (
        Station.objects.filter(city=tel_aviv).count() + 1)
    ws_names = []
    for i in range(num_of_ws):
        ws_names.append("%s_%s%d" % (station_name, "ws", i + 1))

    station = None
    for user_name in [station_name] + ws_names:
        user = User(username=user_name)
        user.set_password(user_name)
        user.save()

        if user_name == station_name:
            station = Station(name=station_name,
                              user=user,
                              number_of_taxis=5,
                              country=Country.objects.filter(code="IL").get(),
                              city=City.objects.get(name="תל אביב יפו"),
                              address='גאולה 12',
                              lat=32.071838,
                              lon=34.766906)
            station.save()
        else:
            ws = WorkStation(user=user,
                             station=station,
                             was_installed=True,
                             accept_orders=True)
            ws.save()

    return 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()
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()
Exemplo n.º 4
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
Exemplo n.º 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
Exemplo n.º 6
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
Exemplo n.º 7
0
def create_another_TLV_station(num_of_ws=1):
    # create another station in TLV
    tel_aviv = City.objects.get(name=u'תל אביב יפו')
    station_name = 'tel_aviv_%d' % (Station.objects.filter(city=tel_aviv).count()+1)
    ws_names = []
    for i in range(num_of_ws):
        ws_names.append("%s_%s%d" % (station_name, "ws", i+1))

    station = None
    for user_name in [station_name] + ws_names:
        user = User(username=user_name)
        user.set_password(user_name)
        user.save()

        if user_name == station_name:
            station = Station(name=station_name, user=user, number_of_taxis=5,
                                    country=Country.objects.filter(code="IL").get(), city=City.objects.get(name="תל אביב יפו"), address='גאולה 12', lat=32.071838, lon=34.766906)
            station.save()
        else:
            ws = WorkStation(user=user, station=station, was_installed = True, accept_orders = True)
            ws.save()

    return station
Exemplo n.º 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