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()
Beispiel #3
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
Beispiel #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