Beispiel #1
0
 def setUp(self):
     b = Band(name='Aerosmith', bio='', rank=3)
     b.save()
     self.b = b
     s1 = Song(band=b, name='Pink', duration=235)
     s1.save()
     s2 = Song(band=b, name='Dude (Looks Like a Lady)', duration=264)
     s2.save()
     s3 = Song(band=b, name='Jaded', duration=214)
     s3.save()
Beispiel #2
0
 def setUp(self):
     b = Band(name='Aerosmith', bio='', rank=3)
     b.save()
     self.b = b
     s1 = Song(band=b, name='Pink', duration=235)
     s1.save()
     s2 = Song(band=b, name='Dude (Looks Like a Lady)', duration=264)
     s2.save()
     s3 = Song(band=b, name='Jaded', duration=214)
     s3.save()
Beispiel #3
0
 def setUp(self):
     b1 = Band(name='Aerosmith', bio='', rank=3)
     b1.save()
     b2 = Band(name='Radiohead', bio='', rank=1)
     b2.save()
     b3 = Band(name='Van Halen', bio='', rank=2)
     b3.save()
Beispiel #4
0
 def setUp(self):
     self.request_factory = RequestFactory()
     b1 = Band(name='Aerosmith', bio='', rank=3)
     b1.save()
     b2 = Band(name='Radiohead', bio='', rank=1)
     b2.save()
     b3 = Band(name='Van Halen', bio='', rank=2)
     b3.save()
Beispiel #5
0
    def test_delete_band_success(self):
        new_band = Band(name=self.test_band['name'],
                        city=self.test_band['city'],
                        state=self.test_band['state'])
        new_band.insert()

        res = self.client().delete(
            '/bands/{}'.format(new_band.id),
            headers={"Authorization": "Bearer {}".format(self.manager)})
        data = json.loads(res.data)
        self.assertEqual(res.status_code, 200)
        self.assertTrue(data['success'])
Beispiel #6
0
    def testBandOncePerNight(self):
        """
        TODO
        """
        band = Band(name="Test band 1")
        band.save()
        BandByNight(night=self.night, band=band,
                    price=Decimal("10.00")).save()

        with self.assertRaises(IntegrityError):
            BandByNight(night=self.night, band=band,
                        price=Decimal("10.00")).save()
Beispiel #7
0
def process_data():
    f = open("raw_data.csv.xls", "r")
    line = f.readline()  # header line, which contain no meaningful data
    line = f.readline()[:-1]  # read from 2nd line onwards, real data
    while line:
        row_data = line.split(";")

        venue_name, addr, postal, booking_id, date, band_name, no_of_members, headlining = row_data
        print(headlining)
        if headlining == "Y":
            headlining = 1
        else:
            headlining = 0
        print(headlining)


        b = Band(band_name, no_of_members)
        v = Venue(venue_name, addr, postal)
        c = ConcertBooking(booking_id, date, venue_name)
        bb = BandBooking(booking_id, band_name, headlining)

        list_of_objs = [b, v, c, bb]

        for ob in list_of_objs:
            execute_sql(ob.create_new_record())

        line = f.readline()[:-1]

    f.close()
Beispiel #8
0
def create_tables():
    # method 1
    execute_sql(Band.create_table())
    execute_sql(Venue.create_table())
    execute_sql(ConcertBooking.create_table())
    execute_sql(BandBooking.create_table())

    # method 2
    create_table_sql = [
        Band.create_table(),
        Venue.create_table(),
        ConcertBooking.create_table(),
        BandBooking.create_table()
    ]

    for sql in create_table_sql:
        execute_sql(sql)
Beispiel #9
0
    def test_queryset_override(self):
        # If we need to override the queryset of a ModelChoiceField in our custom form
        # make sure that RelatedFieldWidgetWrapper doesn't mess that up.

        band2 = Band(name="The Beatles", bio="", sign_date=date(1962, 1, 1))
        band2.save()

        class ConcertAdmin(ModelAdmin):
            pass

        ma = ConcertAdmin(Concert, self.site)
        form = ma.get_form(request)()

        self.assertEqual(
            str(form["main_band"]),
            '<select name="main_band" id="id_main_band">\n'
            '<option value="" selected="selected">---------</option>\n'
            '<option value="%d">The Beatles</option>\n'
            '<option value="%d">The Doors</option>\n'
            "</select>" % (band2.id, self.band.id),
        )

        class AdminConcertForm(forms.ModelForm):
            class Meta:
                model = Concert

            def __init__(self, *args, **kwargs):
                super(AdminConcertForm, self).__init__(*args, **kwargs)
                self.fields["main_band"].queryset = Band.objects.filter(name="The Doors")

        class ConcertAdmin(ModelAdmin):
            form = AdminConcertForm

        ma = ConcertAdmin(Concert, self.site)
        form = ma.get_form(request)()

        self.assertEqual(
            str(form["main_band"]),
            '<select name="main_band" id="id_main_band">\n'
            '<option value="" selected="selected">---------</option>\n'
            '<option value="%d">The Doors</option>\n'
            "</select>" % self.band.id,
        )
Beispiel #10
0
    def setUp(self):
        """
        TODO
        """
        self.stadium = Stadium(name="test stadium")
        self.stadium.save()

        self.festival = Festival(stadium=self.stadium, name="test festival",
                                 base_price=Decimal("10.00"))
        self.festival.save()

        self.night = Night(festival=self.festival, datetime=datetime.now())
        self.night.save()

        for i in range(2):
            band = Band(name="Test band %d" % i)
            band.save()
            BandByNight(night=self.night, band=band,
                        price=Decimal("10.00")).save()
Beispiel #11
0
    def test_queryset_override(self):
        # If we need to override the queryset of a ModelChoiceField in our custom form
        # make sure that RelatedFieldWidgetWrapper doesn't mess that up.

        band2 = Band(name='The Beatles', bio='', sign_date=date(1962, 1, 1))
        band2.save()

        class ConcertAdmin(ModelAdmin):
            pass

        ma = ConcertAdmin(Concert, self.site)
        form = ma.get_form(request)()

        self.assertEqual(
            str(form["main_band"]),
            '<select name="main_band" id="id_main_band">\n'
            '<option value="" selected="selected">---------</option>\n'
            '<option value="%d">The Beatles</option>\n'
            '<option value="%d">The Doors</option>\n'
            '</select>' % (band2.id, self.band.id))

        class AdminConcertForm(forms.ModelForm):
            class Meta:
                model = Concert

            def __init__(self, *args, **kwargs):
                super(AdminConcertForm, self).__init__(*args, **kwargs)
                self.fields["main_band"].queryset = Band.objects.filter(
                    name='The Doors')

        class ConcertAdmin(ModelAdmin):
            form = AdminConcertForm

        ma = ConcertAdmin(Concert, self.site)
        form = ma.get_form(request)()

        self.assertEqual(
            str(form["main_band"]),
            '<select name="main_band" id="id_main_band">\n'
            '<option value="" selected="selected">---------</option>\n'
            '<option value="%d">The Doors</option>\n'
            '</select>' % self.band.id)
Beispiel #12
0
    def post_newbands(payload):
        # takes a JSON object with new artist to add to database
        body = request.get_json()

        name = body.get('name', None)
        city = body.get('city', None)
        state = body.get('state', None)

        if name is None:
            abort(400)
        if city is None:
            abort(400)
        if state is None:
            abort(400)

        band = Band(name=name, city=city, state=state)
        band.insert()
        new_band = Band.query.get(band.id).format()

        return jsonify({
            'success': True,
            'band': new_band
        })
Beispiel #13
0
def new_band(request):
    if request.method == 'POST':
        #create the band
        bandName = request.POST.get('bandName', False)
        newBand = Band(name=bandName, owner=request.user)
        newBand.save()
        newBandId = newBand.id
        #add user as member
        newMemberName = request.user.first_name + " " + request.user.last_name
        newMemberPhone = request.POST.get('phoneNumber', False)
        newMemberRole = request.POST.get('role', False)
        newMember = Member(
            band=newBand, 
            name=newMemberName, 
            userName=request.user, 
            role=newMemberRole, 
            phone=newMemberPhone, 
            email=request.user.email,
            status=Member.MANAGER
            )
        newMember.save()
        return HttpResponseRedirect('/app/' + str(newBandId))
    return HttpResponseRedirect('/')
Beispiel #14
0
 def test_get_bands_success(self):
     test_band = Band(name=self.test_band['name'],
                      city=self.test_band['city'],
                      state=self.test_band['state'])
     test_band.insert()
     res = self.client().get(
         '/bands',
         headers={"Authorization": "Bearer {}".format(self.manager)})
     self.assertEqual(res.status_code, 200)
     test_band.delete()
def bandForm():
    if not session.get('logged_in'):
        return redirect(url_for('login'))
    if request.method == 'GET':
        return render_template('bandForm.html')
    elif request.method == 'POST':
        title = request.form['title']
        img = request.form['img']
        bio = request.form['bio']
        band_mem = request.form['band_mem']
        year = request.form['year']
        origin = request.form['origin']
        label = request.form['label']
        genre = request.form['genre']
        manager = request.form['manager']
        website = request.form['website']
        facebook = request.form['facebook']
        twitter = request.form['twitter']
        youtube = request.form['youtube']
        soundcloud = request.form['soundcloud']

        newBand = Band(title, img, bio, band_mem, year, origin, label, genre,
                       manager, website, facebook, twitter, youtube,
                       soundcloud)
        db.session.add(newBand)
        db.session.commit()
        #After Adding the new band; Go to it's page.
        try:
            band = Band.query.filter_by(title=title).first()
        except:
            band = None
        if band:
            return render_template('bandPage.html',
                                   title=band.title,
                                   band=band)
        else:
            return "No Data"
Beispiel #16
0
def newBand(genre_id):
    session = DBSession()
    if 'username' not in login_session:
        return redirect('/login')
    genre = session.query(Genre).filter_by(id=genre_id).one()
    if login_session['user_id'] != genre.user_id:
        returnurl = ""
        returnurl += "<script>function myFunction() {alert('You are not "
        returnurl += "authorized to add bands to this genre. Please"
        returnurl += "create your own genre in order to add bands.');"
        returnurl += " }</script><body onload='myFunction()''>"
        return returnurl
    if request.method == 'POST':
        newBand = Band(
                        name=request.form['name'],
                        description=request.form['description'],
                        genre_id=genre_id,
                        user_id=genre.user_id
                        )
        session.add(newBand)
        session.commit()
        return redirect(url_for('showBands', genre_id=genre_id))
    else:
        return render_template('genre/newBand.html', genre=genre)
Beispiel #17
0
 def setUp(self):
     b1 = Band(name='Aerosmith', bio='', rank=3)
     b1.save()
     b2 = Band(name='Radiohead', bio='', rank=1)
     b2.save()
     b3 = Band(name='Van Halen', bio='', rank=2)
     b3.save()
Beispiel #18
0
def upgrade():
    db.session.add(Band(name="630m", zone="iaru1", lower=472000, upper=476000))
    db.session.add(Band(name="60m", zone="iaru1", lower=5351500, upper=5366500))
    db.session.commit()
Beispiel #19
0
# Create dummy user
User1 = User(name="Robo Barista",
             email="*****@*****.**",
             picture='https://pbs.twx400.png')
session.add(User1)
session.commit()

# bands for pop
genre1 = Genre(user_id=1, name="Pop")

session.add(genre1)
session.commit()

band1 = Band(user_id=1,
             name="Michael Jackson",
             description="king of pop",
             genre=genre1)

session.add(band1)
session.commit()

band2 = Band(user_id=1,
             name="Nsycn",
             description="famous boy band",
             genre=genre1)

session.add(band2)
session.commit()

# bands for rock
genre2 = Genre(user_id=1, name="Rock")
Beispiel #20
0
def seed_bands(db):
    db.session.add(Band(name="2222m", zone="iaru1", lower=135700,
                        upper=137800))
    db.session.add(Band(name="630m", zone="iaru1", lower=472000, upper=476000))
    db.session.add(
        Band(name="160m", zone="iaru1", lower=1810000, upper=1850000))
    db.session.add(Band(name="80m", zone="iaru1", lower=3500000,
                        upper=3800000))
    db.session.add(Band(name="60m", zone="iaru1", lower=5351500,
                        upper=5366500))
    db.session.add(Band(name="40m", zone="iaru1", lower=7000000,
                        upper=7200000))
    db.session.add(
        Band(name="30m", zone="iaru1", lower=10100000, upper=10150000))
    db.session.add(
        Band(name="20m", zone="iaru1", lower=14000000, upper=14350000))
    db.session.add(
        Band(name="17m", zone="iaru1", lower=18068000, upper=18168000))
    db.session.add(
        Band(name="15m", zone="iaru1", lower=21000000, upper=21450000))
    db.session.add(
        Band(name="12m", zone="iaru1", lower=24890000, upper=24990000))
    db.session.add(
        Band(name="10m", zone="iaru1", lower=28000000, upper=29700000))
    db.session.add(
        Band(name="6m", zone="iaru1", lower=50000000, upper=52000000))
    db.session.add(
        Band(name="2m", zone="iaru1", lower=144000000, upper=146000000))
    db.session.add(
        Band(name="70cm", zone="iaru1", lower=430000000, upper=440000000))
    db.session.add(
        Band(name="23cm", zone="iaru1", lower=1240000000, upper=1300000000))
    db.session.add(
        Band(name="13cm", zone="iaru1", lower=2300000000, upper=2450000000))
    db.session.add(
        Band(name="5cm", zone="iaru1", lower=5650000000, upper=5850000000))
    db.session.add(
        Band(name="3cm", zone="iaru1", lower=10000000000, upper=10500000000))
    db.session.add(
        Band(name="1,2cm", zone="iaru1", lower=24000000000, upper=24250000000))
    db.session.add(
        Band(name="6mm", zone="iaru1", lower=47000000000, upper=47200000000))
    db.session.add(
        Band(name="4mm", zone="iaru1", lower=76000000000, upper=81500000000))
    db.session.add(
        Band(name="2,4mm",
             zone="iaru1",
             lower=122250000000,
             upper=123000000000))
    db.session.add(
        Band(name="2mm", zone="iaru1", lower=134000000000, upper=141000000000))
    db.session.add(
        Band(name="1,2mm",
             zone="iaru1",
             lower=241000000000,
             upper=250000000000))

    # Modes plans for IARU1
    # Only CW on 2222m
    db.session.add(Band(name="2222m", zone="iaru1", modes=None, start=135700))

    db.session.add(Band(name="160m", zone="iaru1", modes="CW", start=1810000))
    db.session.add(
        Band(name="160m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63,SSTV",
             start=1838000))
    db.session.add(
        Band(name="160m", zone="iaru1", modes="SSB,AM", start=1838000))
    db.session.add(Band(name="160m", zone="iaru1", modes=None, start=1810000))

    db.session.add(Band(name="80m", zone="iaru1", modes="CW", start=3500000))
    db.session.add(
        Band(name="80m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63,SSTV",
             start=3580000))
    db.session.add(
        Band(name="80m", zone="iaru1", modes="SSB,AM", start=3600000))
    db.session.add(Band(name="80m", zone="iaru1", modes=None, start=3500000))

    db.session.add(Band(name="40m", zone="iaru1", modes="CW", start=7000000))
    db.session.add(
        Band(name="40m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63,SSTV",
             start=7040000))
    db.session.add(
        Band(name="40m", zone="iaru1", modes="SSB,AM", start=7060000))
    db.session.add(Band(name="40m", zone="iaru1", modes=None, start=7000000))

    db.session.add(Band(name="30m", zone="iaru1", modes="CW", start=10100000))
    db.session.add(
        Band(name="30m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=10140000))
    db.session.add(Band(name="30m", zone="iaru1", modes=None, start=10100000))

    db.session.add(Band(name="20m", zone="iaru1", modes="CW", start=14000000))
    db.session.add(
        Band(name="20m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=14070000))
    db.session.add(
        Band(name="20m", zone="iaru1", modes="SSB,AM", start=14101000))
    db.session.add(Band(name="20m", zone="iaru1", modes=None, start=14000000))

    db.session.add(Band(name="17m", zone="iaru1", modes="CW", start=18068000))
    db.session.add(
        Band(name="17m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=18095000))
    db.session.add(
        Band(name="17m", zone="iaru1", modes="SSB,AM", start=18111000))
    db.session.add(Band(name="17m", zone="iaru1", modes=None, start=18068000))

    db.session.add(Band(name="15m", zone="iaru1", modes="CW", start=21000000))
    db.session.add(
        Band(name="15m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=21070000))
    db.session.add(
        Band(name="15m", zone="iaru1", modes="SSB,AM,SSTV", start=21151000))
    db.session.add(Band(name="15m", zone="iaru1", modes=None, start=21000000))

    db.session.add(Band(name="12m", zone="iaru1", modes="CW", start=24890000))
    db.session.add(
        Band(name="12m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=24915000))
    db.session.add(
        Band(name="12m", zone="iaru1", modes="SSB,AM,SSTV", start=24931000))
    db.session.add(Band(name="12m", zone="iaru1", modes=None, start=24890000))

    db.session.add(Band(name="10m", zone="iaru1", modes="CW", start=28000000))
    db.session.add(
        Band(name="10m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=28070000))
    db.session.add(
        Band(name="10m", zone="iaru1", modes="SSB,AM,SSTV", start=28225000))
    db.session.add(
        Band(name="10m", zone="iaru1", modes="FM,PKT", start=29200000))
    db.session.add(Band(name="10m", zone="iaru1", modes=None, start=28000000))

    db.session.add(Band(name="6m", zone="iaru1", modes="CW", start=50000000))
    db.session.add(Band(name="6m", zone="iaru1", modes="SSB", start=50110000))
    db.session.add(Band(name="6m", zone="iaru1", modes="SSTV", start=50510000))
    db.session.add(Band(name="6m", zone="iaru1", modes="FM", start=50520000))
    db.session.add(Band(name="6m", zone="iaru1", modes="RTTY", start=50600000))
    db.session.add(Band(name="6m", zone="iaru1", modes=None, start=50000000))

    db.session.add(
        Band(name="2m", zone="iaru1", modes="CW,SSB", start=144025000))
    db.session.add(Band(name="2m", zone="iaru1", modes="FM", start=145000000))
    db.session.add(Band(name="2m", zone="iaru1", modes=None, start=144000000))

    db.session.add(Band(name="70cm", zone="iaru1", modes="FM",
                        start=430250000))
    db.session.add(
        Band(name="70cm", zone="iaru1", modes="CW,SSB", start=432000000))
    db.session.add(
        Band(name="70cm", zone="iaru1", modes="PSK31", start=432088000))
    db.session.add(
        Band(name="70cm", zone="iaru1", modes="SSTV", start=432500000))
    db.session.add(
        Band(name="70cm", zone="iaru1", modes="RTTY", start=432562500))
    db.session.add(Band(name="70cm", zone="iaru1", modes=None,
                        start=430000000))

    db.session.add(
        Band(name="23cm", zone="iaru1", modes="FM,SSB,CW", start=1260000000))
    db.session.add(
        Band(name="23cm", zone="iaru1", modes="RTTY", start=1270000000))
    db.session.add(
        Band(name="23cm", zone="iaru1", modes="PSK31", start=1296138000))
    db.session.add(
        Band(name="23cm", zone="iaru1", modes=None, start=1240000000))

    db.session.add(
        Band(name="13cm", zone="iaru1", modes="CW", start=2320025000))
    db.session.add(
        Band(name="13cm", zone="iaru1", modes="PSK31", start=2320138000))
    db.session.add(
        Band(name="13cm", zone="iaru1", modes="LSB", start=2320150000))
    db.session.add(
        Band(name="13cm", zone="iaru1", modes="FM", start=2321000000))
    db.session.add(
        Band(name="13cm", zone="iaru1", modes=None, start=2300000000))

    db.session.add(Band(name="5cm", zone="iaru1", modes=None,
                        start=5650000000))

    db.session.add(
        Band(name="3cm", zone="iaru1", modes="CW,SSB", start=10368000000))
    db.session.add(
        Band(name="3cm", zone="iaru1", modes=None, start=10000000000))

    db.session.add(
        Band(name="1,2cm", zone="iaru1", modes=None, start=24000000000))

    db.session.add(
        Band(name="6mm", zone="iaru1", modes=None, start=47000000000))

    db.session.add(
        Band(name="4mm", zone="iaru1", modes=None, start=76000000000))

    db.session.add(
        Band(name="2,4mm", zone="iaru1", modes=None, start=122250000000))

    db.session.add(
        Band(name="2mm", zone="iaru1", modes=None, start=134000000000))

    db.session.add(
        Band(name="1,2mm", zone="iaru1", modes=None, start=241000000000))

    db.session.commit()
Beispiel #21
0
 def setUp(self):
     self.request_factory = RequestFactory()
     b1 = Band(name='Aerosmith', bio='', rank=3)
     b1.save()
     b2 = Band(name='Radiohead', bio='', rank=1)
     b2.save()
     b3 = Band(name='Van Halen', bio='', rank=2)
     b3.save()
Beispiel #22
0
def upgrade():
    cleaned = Band.query.delete()
    print("-- Cleaned {0} records".format(cleaned))

    # All IARU1 datas extracted from http://f4eed.wordpress.com/ "Petit Memento Radioamateur et SWL"
    # And wikipedia articles synthetizing IARU Band Plans

    # Add band plan for IARU1
    db.session.add(Band(name="2222m", zone="iaru1", lower=135700,
                        upper=137800))
    db.session.add(
        Band(name="160m", zone="iaru1", lower=1810000, upper=1850000))
    db.session.add(Band(name="80m", zone="iaru1", lower=3500000,
                        upper=3800000))
    db.session.add(Band(name="40m", zone="iaru1", lower=7000000,
                        upper=7200000))
    db.session.add(
        Band(name="30m", zone="iaru1", lower=10100000, upper=10150000))
    db.session.add(
        Band(name="20m", zone="iaru1", lower=14000000, upper=14350000))
    db.session.add(
        Band(name="17m", zone="iaru1", lower=18068000, upper=18168000))
    db.session.add(
        Band(name="15m", zone="iaru1", lower=21000000, upper=21450000))
    db.session.add(
        Band(name="12m", zone="iaru1", lower=24890000, upper=24990000))
    db.session.add(
        Band(name="10m", zone="iaru1", lower=28000000, upper=29700000))
    db.session.add(
        Band(name="6m", zone="iaru1", lower=50000000, upper=52000000))
    db.session.add(
        Band(name="2m", zone="iaru1", lower=144000000, upper=146000000))
    db.session.add(
        Band(name="70cm", zone="iaru1", lower=430000000, upper=440000000))
    db.session.add(
        Band(name="23cm", zone="iaru1", lower=1240000000, upper=1300000000))
    db.session.add(
        Band(name="13cm", zone="iaru1", lower=2300000000, upper=2450000000))
    db.session.add(
        Band(name="5cm", zone="iaru1", lower=5650000000, upper=5850000000))
    db.session.add(
        Band(name="3cm", zone="iaru1", lower=10000000000, upper=10500000000))
    db.session.add(
        Band(name="1,2cm", zone="iaru1", lower=24000000000, upper=24250000000))
    db.session.add(
        Band(name="6mm", zone="iaru1", lower=47000000000, upper=47200000000))
    db.session.add(
        Band(name="4mm", zone="iaru1", lower=76000000000, upper=81500000000))
    db.session.add(
        Band(name="2,4mm", zone="iaru1", lower=122250000000,
             upper=12300000000))
    db.session.add(
        Band(name="2mm", zone="iaru1", lower=134000000000, upper=14100000000))
    db.session.add(
        Band(name="1,2mm", zone="iaru1", lower=241000000000,
             upper=25000000000))

    # Modes plans for IARU1
    # Only CW on 2222m
    db.session.add(Band(name="2222m", zone="iaru1", modes=None, start=135700))

    db.session.add(Band(name="160m", zone="iaru1", modes="CW", start=1810000))
    db.session.add(
        Band(name="160m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63,SSTV",
             start=1838000))
    db.session.add(
        Band(name="160m", zone="iaru1", modes="SSB,AM", start=1838000))
    db.session.add(Band(name="160m", zone="iaru1", modes=None, start=1810000))

    db.session.add(Band(name="80m", zone="iaru1", modes="CW", start=3500000))
    db.session.add(
        Band(name="80m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63,SSTV",
             start=3580000))
    db.session.add(
        Band(name="80m", zone="iaru1", modes="SSB,AM", start=3600000))
    db.session.add(Band(name="80m", zone="iaru1", modes=None, start=3500000))

    db.session.add(Band(name="40m", zone="iaru1", modes="CW", start=7000000))
    db.session.add(
        Band(name="40m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63,SSTV",
             start=7040000))
    db.session.add(
        Band(name="40m", zone="iaru1", modes="SSB,AM", start=7060000))
    db.session.add(Band(name="40m", zone="iaru1", modes=None, start=7000000))

    db.session.add(Band(name="30m", zone="iaru1", modes="CW", start=10100000))
    db.session.add(
        Band(name="30m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=10140000))
    db.session.add(Band(name="30m", zone="iaru1", modes=None, start=10100000))

    db.session.add(Band(name="20m", zone="iaru1", modes="CW", start=14000000))
    db.session.add(
        Band(name="20m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=14070000))
    db.session.add(
        Band(name="20m", zone="iaru1", modes="SSB,AM", start=14101000))
    db.session.add(Band(name="20m", zone="iaru1", modes=None, start=14000000))

    db.session.add(Band(name="17m", zone="iaru1", modes="CW", start=18068000))
    db.session.add(
        Band(name="17m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=18095000))
    db.session.add(
        Band(name="17m", zone="iaru1", modes="SSB,AM", start=18111000))
    db.session.add(Band(name="17m", zone="iaru1", modes=None, start=18068000))

    db.session.add(Band(name="15m", zone="iaru1", modes="CW", start=21000000))
    db.session.add(
        Band(name="15m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=21070000))
    db.session.add(
        Band(name="15m", zone="iaru1", modes="SSB,AM,SSTV", start=21151000))
    db.session.add(Band(name="15m", zone="iaru1", modes=None, start=21000000))

    db.session.add(Band(name="12m", zone="iaru1", modes="CW", start=24890000))
    db.session.add(
        Band(name="12m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=24915000))
    db.session.add(
        Band(name="12m", zone="iaru1", modes="SSB,AM,SSTV", start=24931000))
    db.session.add(Band(name="12m", zone="iaru1", modes=None, start=24890000))

    db.session.add(Band(name="10m", zone="iaru1", modes="CW", start=28000000))
    db.session.add(
        Band(name="10m",
             zone="iaru1",
             modes="RTTY,PSK31,PSK63",
             start=28070000))
    db.session.add(
        Band(name="10m", zone="iaru1", modes="SSB,AM,SSTV", start=28225000))
    db.session.add(
        Band(name="10m", zone="iaru1", modes="FM,PKT", start=29200000))
    db.session.add(Band(name="10m", zone="iaru1", modes=None, start=28000000))

    db.session.add(Band(name="6m", zone="iaru1", modes="CW", start=50000000))
    db.session.add(Band(name="6m", zone="iaru1", modes="SSB", start=50110000))
    db.session.add(Band(name="6m", zone="iaru1", modes="SSTV", start=50510000))
    db.session.add(Band(name="6m", zone="iaru1", modes="FM", start=50520000))
    db.session.add(Band(name="6m", zone="iaru1", modes="RTTY", start=50600000))
    db.session.add(Band(name="6m", zone="iaru1", modes=None, start=50000000))

    db.session.add(
        Band(name="2m", zone="iaru1", modes="CW,SSB", start=144025000))
    db.session.add(Band(name="2m", zone="iaru1", modes="FM", start=145000000))
    db.session.add(Band(name="2m", zone="iaru1", modes=None, start=144000000))

    db.session.add(Band(name="70cm", zone="iaru1", modes="FM",
                        start=430250000))
    db.session.add(
        Band(name="70cm", zone="iaru1", modes="CW,SSB", start=432000000))
    db.session.add(
        Band(name="70cm", zone="iaru1", modes="PSK31", start=432088000))
    db.session.add(
        Band(name="70cm", zone="iaru1", modes="SSTV", start=432500000))
    db.session.add(
        Band(name="70cm", zone="iaru1", modes="RTTY", start=432562500))
    db.session.add(Band(name="70cm", zone="iaru1", modes=None,
                        start=430000000))

    db.session.add(
        Band(name="23cm", zone="iaru1", modes="FM,SSB,CW", start=1260000000))
    db.session.add(
        Band(name="23cm", zone="iaru1", modes="RTTY", start=1270000000))
    db.session.add(
        Band(name="23cm", zone="iaru1", modes="PSK31", start=1296138000))
    db.session.add(
        Band(name="23cm", zone="iaru1", modes=None, start=1240000000))

    db.session.add(
        Band(name="13cm", zone="iaru1", modes="CW", start=2320025000))
    db.session.add(
        Band(name="13cm", zone="iaru1", modes="PSK31", start=2320138000))
    db.session.add(
        Band(name="13cm", zone="iaru1", modes="LSB", start=2320150000))
    db.session.add(
        Band(name="13cm", zone="iaru1", modes="FM", start=2321000000))
    db.session.add(
        Band(name="13cm", zone="iaru1", modes=None, start=2300000000))

    db.session.add(Band(name="5cm", zone="iaru1", modes=None,
                        start=5650000000))

    db.session.add(
        Band(name="3cm", zone="iaru1", modes="CW,SSB", start=10368000000))
    db.session.add(
        Band(name="3cm", zone="iaru1", modes=None, start=10000000000))

    db.session.add(
        Band(name="1,2cm", zone="iaru1", modes=None, start=24000000000))

    db.session.add(
        Band(name="6mm", zone="iaru1", modes=None, start=47000000000))

    db.session.add(
        Band(name="4mm", zone="iaru1", modes=None, start=76000000000))

    db.session.add(
        Band(name="2,4mm", zone="iaru1", modes=None, start=122250000000))

    db.session.add(
        Band(name="2mm", zone="iaru1", modes=None, start=134000000000))

    db.session.add(
        Band(name="1,2mm", zone="iaru1", modes=None, start=241000000000))

    db.session.commit()

    # Now re-create relations for Logs
    updated = 0
    for log in db.session.query(Log.id, Log.freq, Log.band_id):
        band = Band.query.filter(Band.start.is_(None), Band.lower <= log.freq,
                                 Band.upper >= log.freq).all()
        if not band or len(band) <= 0:
            print(
                "!! Could not get band for QSO ID {0} and frequency {1}. Please check !"
                .format(log.id, log.freq))
            continue
        log.band_id = band[0].id
        updated += 1
    db.session.commit()
    print("-- Updated {0} logs".format(updated))
Beispiel #23
0
def add(name, url):
    """ Add a band record with given name and url """
    global session
    band = Band(name=name, url=url)
    session.add(band)