示例#1
0
 def setUp(self):
     # can't make a Location without a LocationType
     loctype = LocationType(name='testloctype',
                            plural_name='xs',
                            slug='x',
                            is_browsable=False,
                            is_significant=False)
     loctype.save()
     self.loctype = loctype
示例#2
0
def main():
    """ add a type of location to database """
    
    parser = OptionParser(usage="""
%prog name plural_name scope slug
    
Arguments: 
  name                 e.g., "Ward" or "Congressional District"
  plural_name          e.g., "Wards"
  scope                e.g., "Chicago" or "U.S.A."
  slug                 e.g., "chicago", "usa" """)

    parser.add_option("-b", "--browsable", #action="store_false", 
        dest="browsable", default=True, 
        help="whether this is displayed on location_type_list")
    parser.add_option("-s", "--significant", #action="store_false", 
        dest="significant", default=True, 
        help="whether this is used to display aggregates, etc.")
        
    (options, args) = parser.parse_args()
    if len(args) != 4: 
        return parser.error('must provide 4 arguments, see usage')
    
    location_type = LocationType()
    location_type.name = args[0]
    location_type.plural_name = args[1]
    location_type.scope = args[2]
    location_type.slug = args[3]
    location_type.is_browsable = options.browsable
    location_type.is_significant = options.significant
    location_type.save()
示例#3
0
def main():
    """ add a type of location to database """

    parser = OptionParser(usage="""
%prog name plural_name scope slug
    
Arguments: 
  name                 e.g., "Ward" or "Congressional District"
  plural_name          e.g., "Wards"
  scope                e.g., "Chicago" or "U.S.A."
  slug                 e.g., "chicago", "usa" """)

    parser.add_option(
        "-b",
        "--browsable",  #action="store_false", 
        dest="browsable",
        default=True,
        help="whether this is displayed on location_type_list")
    parser.add_option(
        "-s",
        "--significant",  #action="store_false", 
        dest="significant",
        default=True,
        help="whether this is used to display aggregates, etc.")

    (options, args) = parser.parse_args()
    if len(args) != 4:
        return parser.error('must provide 4 arguments, see usage')

    location_type = LocationType()
    location_type.name = args[0]
    location_type.plural_name = args[1]
    location_type.scope = args[2]
    location_type.slug = args[3]
    location_type.is_browsable = options.browsable
    location_type.is_significant = options.significant
    location_type.save()
示例#4
0
 def setUp(self):
     # can't make a Location without a LocationType
     loctype = LocationType(name='testloctype', plural_name='xs', slug='x',
                            is_browsable=False, is_significant=False)
     loctype.save()
     self.loctype = loctype