Example #1
0
class ChangePasswordForm(Form):
    password = PasswordField(l_('Password'), validators=[
        Length(min=6, message=l_('Your password must have at least 6 characters.')),
    ])
    verify_password = PasswordField(l_('Verify Password'), validators=[
        EqualTo('password', message=l_('Your passwords do not match.')),
    ])
Example #2
0
class UploadForm(Form):
    file = MultiFileField(
        l_(u'IGC or ZIP file(s)'),
        validators=(FileRequired(
            l_('Please add one or more IGC or ZIP files')), ))
    pilot = ClubPilotsSelectField(l_(u'Pilot'))
    pilot_name = TextField(l_(u'Pilot name'))
Example #3
0
class LiveTrackingSettingsForm(Form):
    tracking_delay = TrackingDelaySelectField(l_('Tracking Delay'))
    tracking_callsign = TextField(
        l_('Tracking Callsign'),
        validators=[
            Length(max=5,
                   message=l_(
                       'Your callsign must not have more than 5 characters.')),
        ])
Example #4
0
class LoginForm(Form):
    email_address = EmailField(l_('Email Address'), validators=[
        InputRequired(message=l_('Please enter your email address.')),
        Email(),
    ])
    password = PasswordField(l_('Password'), validators=[
        InputRequired(message=l_('Please enter your password.')),
    ])
    remember_me = BooleanField(l_('Remember me'))
Example #5
0
class RecoverStep1Form(Form):
    email_address = EmailField(l_('Email Address'), validators=[
        InputRequired(message=l_('Please enter your email address.')),
        Email(),
    ])

    def validate_email_address(form, field):
        if not User.exists(email_address=field.data):
            raise ValidationError(l_('There is no pilot with this email address.'))
Example #6
0
class EditClubForm(Form):
    name = TextField(l_('Name'), validators=[InputRequired()])
    website = TextField(l_('Website'), validators=[Optional(), URL()])

    def validate_name(form, field):
        if field.data == field.object_data:
            return

        if Club.exists(name=field.data):
            raise ValidationError(l_('A club with this name exists already.'))
Example #7
0
class ChangeAircraftForm(FlightForm):
    model_id = AircraftModelSelectField(l_('Aircraft Model'))
    registration = TextField(l_('Aircraft Registration'),
                             validators=[
                                 Length(max=32),
                             ])
    competition_id = TextField(l_('Competition Number'),
                               validators=[
                                   Length(max=5),
                               ])
Example #8
0
class ChangePilotsForm(Form):
    pilot_id = ClubPilotsSelectField(l_('Pilot'))
    pilot_name = TextField(l_(u'Pilot name'))
    co_pilot_id = ClubPilotsSelectField(
        l_('Co-Pilot'),
        validators=[
            CompareTo(
                'pilot_id',
                cmp=(lambda x, y: x == 0 or x != y),
                message=l_('Pilot and co-pilot can not be the same person.')),
        ])
    co_pilot_name = TextField(l_(u'Co-Pilot name'))
Example #9
0
    def validate_email_address(form, field):
        if field.data == field.object_data:
            return

        if User.exists(email_address=field.data):
            raise ValidationError(
                l_('A pilot with this email address exists already.'))
Example #10
0
    def __init__(self, *args, **kwargs):
        super(TrackingDelaySelectField, self).__init__(*args, **kwargs)

        self.coerce = int
        self.choices = [(0, l_('None'))]
        for x in range(1, 10) + range(10, 30, 5) + range(30, 61, 15):
            self.choices.append((x, ngettext(u'%(num)u minute', u'%(num)u minutes', x)))
Example #11
0
    def process(self, *args, **kwargs):
        self.choices = [
            (0, '[' + l_('Unknown or other person') + ']'),
            (g.current_user.id, g.current_user.name),
        ]

        club = g.current_user.club
        if club:
            members = User.query(club_id=club.id) \
                .order_by(User.name) \
                .filter(User.id != g.current_user.id)

            members = [(member.id, member.name) for member in members]

            self.choices.append((club.name, members))

        super(ClubPilotsSelectField, self).process(*args, **kwargs)
Example #12
0
class UploadUpdateForm(ChangeAircraftForm, ChangePilotsForm):
    takeoff_time = DateTimeField(l_('Takeoff'), format='%Y-%m-%d %H:%M:%S')

    scoring_start_time = DateTimeField(
        l_('Scoring Start Time'),
        validators=[
            CompareTo('takeoff_time',
                      cmp=(lambda x, y: x >= y),
                      message=l_('Scoring Start Time must be after takeoff'))
        ],
        format='%Y-%m-%d %H:%M:%S')

    scoring_end_time = DateTimeField(
        l_('Scoring End Time'),
        validators=[
            CompareTo('scoring_start_time',
                      cmp=(lambda x, y: x >= y),
                      message=l_(
                          'Scoring End Time must be after scoring start time'))
        ],
        format='%Y-%m-%d %H:%M:%S')

    landing_time = DateTimeField(
        l_('Landing Time'),
        validators=[
            CompareTo(
                'scoring_end_time',
                cmp=(lambda x, y: x >= y),
                message=l_('Landing Time must be after scoring end time'))
        ],
        format='%Y-%m-%d %H:%M:%S')

    airspace_usage = BooleanField(
        l_('Confirm airspace usage'),
        validators=[
            Required(message=l_(
                'Please confirm you were allowed to use those airspaces'))
        ])
Example #13
0
class CreateClubPilotForm(Form):
    email_address = EmailField(l_('Email Address'), validators=[
        InputRequired(message=l_('Please enter your email address.')),
        Email(),
    ])
    first_name = TextField(l_('First Name'), validators=[
        InputRequired(message=l_('Please enter your first name.')),
    ])
    last_name = TextField(l_('Last Name'), validators=[
        InputRequired(message=l_('Please enter your last name.')),
    ])

    def validate_email_address(form, field):
        if User.exists(email_address=field.data):
            raise ValidationError(l_('A pilot with this email address exists already.'))
Example #14
0
class ChangePilotsForm(FlightForm):
    pilot_id = ClubPilotsSelectField(
        l_('Pilot'),
        validators=[
            CheckPilot(
                'id',
                message=l_('Pilot is already airborne in another flight.')),
        ])
    pilot_name = TextField(l_(u'Pilot name'))
    co_pilot_id = ClubPilotsSelectField(
        l_('Co-Pilot'),
        validators=[
            CompareTo(
                'pilot_id',
                cmp=(lambda x, y: x == 0 or x != y),
                message=l_('Pilot and co-pilot can not be the same person.')),
            CheckPilot(
                'id',
                message=l_('Co-Pilot is already airborne in another flight.')),
        ])
    co_pilot_name = TextField(l_(u'Co-Pilot name'))
Example #15
0
    Unit(u'm/s', 1, u'{0:.{1}f}', 1),
    Unit(u'kt', 1.94384449, u'{0:.{1}f}', 1),
    Unit(u'ft/min', 1 * 196.850394, u'{0:.{1}f}', 0),
)

DEFAULT_LIFT_UNIT = 0

ALTITUDE_UNITS = (
    Unit(u'm', 1, u'{0:.{1}f}', 0),
    Unit(u'ft', 3.280839895, u'{0:.{1}f}', 0)
)

DEFAULT_ALTITUDE_UNIT = 0

UNIT_PRESETS = (
    (l_("Custom"), {}),

    (l_("European (metric)"),
     {'distance_unit': u'km',
      'speed_unit': u'km/h',
      'lift_unit': u'm/s',
      'altitude_unit': u'm'
      }),

    (l_("British (imperial, distance in km)"),
     {'distance_unit': u'km',
      'speed_unit': u'kt',
      'lift_unit': u'kt',
      'altitude_unit': u'ft'
      }),
Example #16
0
            f.write(upload.encode('UTF-8'))
            f.seek(0)
            yield 'direct.igc', f

    elif isinstance(upload, list):
        for x in upload:
            for name, f in IterateUploadFiles(x):
                yield name, f

    else:
        for x in IterateFiles(upload.filename, upload):
            yield x


@upload_blueprint.route('/', methods=('GET', 'POST'))
@login_required(l_("You have to login to upload flights."))
def index():

    form = UploadForm(pilot=g.current_user.id)

    if form.validate_on_submit():
        return index_post(form)

    return render_template('upload/form.jinja', form=form)


def index_post(form):
    user = g.current_user

    pilot_id = form.pilot.data if form.pilot.data != 0 else None
    pilot = pilot_id and User.get(int(pilot_id))
Example #17
0
    def process(self, *args, **kwargs):
        users = Club.query().order_by(Club.name)
        self.choices = [(0, '[' + l_('No club') + ']')]
        self.choices.extend([(user.id, user) for user in users])

        super(ClubsSelectField, self).process(*args, **kwargs)
Example #18
0
    def validate_name(form, field):
        if field.data == field.object_data:
            return

        if Club.exists(name=field.data):
            raise ValidationError(l_('A club with this name exists already.'))
Example #19
0
    def process(self, *args, **kwargs):
        users = Club.query().order_by(Club.name)
        self.choices = [(0, "[" + l_("No club") + "]")]
        self.choices.extend([(user.id, user) for user in users])

        super(ClubsSelectField, self).process(*args, **kwargs)
Example #20
0
    def validate_name(form, field):
        if field.data == field.object_data:
            return

        if Club.exists(name=field.data):
            raise ValidationError(l_("A club with this name exists already."))
Example #21
0
LIFT_UNITS = (
    Unit(u'm/s', 1, u'{0:.{1}f}', 1),
    Unit(u'kt', 1.94384449, u'{0:.{1}f}', 1),
    Unit(u'ft/min', 1 * 196.850394, u'{0:.{1}f}', 0),
)

DEFAULT_LIFT_UNIT = 0

ALTITUDE_UNITS = (Unit(u'm', 1, u'{0:.{1}f}',
                       0), Unit(u'ft', 3.280839895, u'{0:.{1}f}', 0))

DEFAULT_ALTITUDE_UNIT = 0

UNIT_PRESETS = (
    (l_("Custom"), {}),
    (l_("European (metric)"), {
        'distance_unit': u'km',
        'speed_unit': u'km/h',
        'lift_unit': u'm/s',
        'altitude_unit': u'm'
    }),
    (l_("British (imperial, distance in km)"), {
        'distance_unit': u'km',
        'speed_unit': u'kt',
        'lift_unit': u'kt',
        'altitude_unit': u'ft'
    }),
    (l_("Australian (metric, imperial height)"), {
        'distance_unit': u'km',
        'speed_unit': u'km/h',
Example #22
0
class ChangePilotsForm(Form):
    pilot_id = ClubPilotsSelectField(l_('Pilot'))
    co_pilot_id = ClubPilotsSelectField(l_('Co-Pilot'))
Example #23
0
            f.write(upload.encode('UTF-8'))
            f.seek(0)
            yield 'direct.igc', f

    elif isinstance(upload, list):
        for x in upload:
            for name, f in IterateUploadFiles(x):
                yield name, f

    else:
        for x in IterateFiles(upload.filename, upload):
            yield x


@upload_blueprint.route('/', methods=('GET', 'POST'))
@login_required(l_("You have to login to upload flights."))
def index():
    if request.values.get('stage', type=int) == 1:
        # Parse update form
        num_flights = request.values.get('num_flights', 0, type=int)

        flights = []
        flight_id_list = []
        form_error = False

        for prefix in range(1, num_flights + 1):
            flight_id = request.values.get('{}-sfid'.format(prefix), None, type=int)
            name = request.values.get('{}-name'.format(prefix))

            try:
                status = UploadStatus(request.values.get('{}-status'.format(prefix), type=int))
Example #24
0
 def validate_email_address(form, field):
     if User.exists(email_address=field.data):
         raise ValidationError(l_('A pilot with this email address exists already.'))
Example #25
0
class CreateClubForm(Form):
    name = TextField(l_('Name'), validators=[InputRequired()])

    def validate_name(form, field):
        if Club.exists(name=field.data):
            raise ValidationError(l_('A club with this name exists already.'))
Example #26
0
class ChangeClubForm(Form):
    club = ClubsSelectField(l_('Club'))
Example #27
0
 def validate_email_address(form, field):
     if not User.exists(email_address=field.data):
         raise ValidationError(l_('There is no pilot with this email address.'))
Example #28
0
                         flight.takeoff_time.minute * 60 +
                         flight.takeoff_time.second +
                         (time - flight.takeoff_time).days * 86400 +
                         (time - flight.takeoff_time).seconds)

        contest_traces.append(
            dict(name=contest['contest_type'] + " " + contest['trace_type'],
                 turnpoints=xcsoar.encode(fixes, floor=1e5, method="double"),
                 times=xcsoar.encode(times, method="signed")))

    return contest_traces


CIRCDIR_NAMES = {
    None: "",
    FlightPhase.CD_LEFT: l_("Left"),
    FlightPhase.CD_MIXED: l_("Mixed"),
    FlightPhase.CD_RIGHT: l_("Right"),
    FlightPhase.CD_TOTAL: l_("Total")
}

PHASETYPE_NAMES = {
    None: "",
    FlightPhase.PT_POWERED: l_("Powered"),
    FlightPhase.PT_CIRCLING: l_("Circling"),
    FlightPhase.PT_CRUISE: l_("Cruise")
}


def format_phase(phase):
    """Format phase properties to human readable format
Example #29
0
class EditPilotForm(Form):
    email_address = EmailField(l_('Email Address'), validators=[
        InputRequired(message=l_('Please enter your email address.')),
        Email(),
    ])
    first_name = TextField(l_('First Name'), validators=[
        InputRequired(message=l_('Please enter your first name.')),
    ])
    last_name = TextField(l_('Last Name'), validators=[
        InputRequired(message=l_('Please enter your last name.')),
    ])
    unit_preset = UnitsPresetSelectField(l_('Unit Preset'))
    distance_unit = DistanceUnitSelectField(l_('Distance Unit'))
    speed_unit = SpeedUnitSelectField(l_('Speed Unit'))
    lift_unit = LiftUnitSelectField(l_('Lift Unit'))
    altitude_unit = AltitudeUnitSelectField(l_('Altitude Unit'))

    def validate_email_address(form, field):
        if field.data == field.object_data:
            return

        if User.exists(email_address=field.data):
            raise ValidationError(l_('A pilot with this email address exists already.'))
Example #30
0
        fixes = map(lambda x: (x.latitude, x.longitude), contest_trace.locations)
        times = []
        for time in contest_trace.times:
            times.append(flight.takeoff_time.hour * 3600 + flight.takeoff_time.minute * 60 + flight.takeoff_time.second +
                         (time - flight.takeoff_time).days * 86400 + (time - flight.takeoff_time).seconds)

        contest_traces.append(dict(name=contest['contest_type'] + " " + contest['trace_type'],
                                   turnpoints=xcsoar.encode(fixes, floor=1e5, method="double"),
                                   times=xcsoar.encode(times, method="signed")))

    return contest_traces


CIRCDIR_NAMES = {None: "",
                 FlightPhase.CD_LEFT: l_("Left"),
                 FlightPhase.CD_MIXED: l_("Mixed"),
                 FlightPhase.CD_RIGHT: l_("Right"),
                 FlightPhase.CD_TOTAL: l_("Total")}

PHASETYPE_NAMES = {None: "",
                   FlightPhase.PT_POWERED: l_("Powered"),
                   FlightPhase.PT_CIRCLING: l_("Circling"),
                   FlightPhase.PT_CRUISE: l_("Cruise")}


def format_phase(phase):
    """Format phase properties to human readable format
    """
    is_circling = phase.phase_type == FlightPhase.PT_CIRCLING
    r = dict(start="%s" % format_time(phase.start_time),
Example #31
0
class CreatePilotForm(CreateClubPilotForm, ChangePasswordForm):
    # email_address, name from CreateClubPilotForm
    # password, verify_password from ChangePasswordForm
    club_id = ClubsSelectField(l_('Club'))