Code Duplication    Length = 30-32 lines in 4 locations

pyfreebill/models.py 4 locations

@@ 1185-1216 (lines=32) @@
1182
                                  max_length=15)
1183
    date_added = models.DateTimeField(_(u'date added'),
1184
                                      auto_now_add=True)
1185
    date_modified = models.DateTimeField(_(u'date modified'),
1186
                                         auto_now=True)
1187
1188
    class Meta:
1189
        db_table = 'customer_cid_norm_rules'
1190
        ordering = ('company', )
1191
        verbose_name = _(u'Customer CallerID Normalization Rule')
1192
        verbose_name_plural = _(u'Customer CallerID Normalization Rules')
1193
1194
    def __unicode__(self):
1195
        return u"%s -> -%s +%s" % (self.company,
1196
                                   self.remove_prefix,
1197
                                   self.add_prefix)
1198
1199
1200
class CarrierCIDNormalizationRules(models.Model):
1201
    """ Carrier Caller ID Number Normalization Rules """
1202
    company = models.ForeignKey(Company,
1203
                                verbose_name=_(u"provider"))
1204
    prefix = models.CharField(_(u'rule title'),
1205
                              max_length=30)
1206
    description = models.TextField(_(u'description'),
1207
                                   blank=True)
1208
    remove_prefix = models.CharField(_(u"remove prefix"),
1209
                                     blank=True,
1210
                                     default='',
1211
                                     max_length=15)
1212
    add_prefix = models.CharField(_(u"add prefix"),
1213
                                  blank=True,
1214
                                  default='',
1215
                                  max_length=15)
1216
    date_added = models.DateTimeField(_(u'date added'),
1217
                                      auto_now_add=True)
1218
    date_modified = models.DateTimeField(_(u'date modified'),
1219
                                         auto_now=True)
@@ 1252-1282 (lines=31) @@
1249
    date_modified = models.DateTimeField(_(u'date modified'),
1250
                                         auto_now=True)
1251
1252
    class Meta:
1253
        db_table = 'acl_lists'
1254
        ordering = ('acl_name',)
1255
        verbose_name = _(u'ACL list')
1256
        verbose_name_plural = _(u'ACL lists')
1257
1258
    def __unicode__(self):
1259
        return u"%s" % self.acl_name
1260
1261
1262
class AclNodes(models.Model):
1263
    """ ACL NODES model """
1264
    company = models.ForeignKey(Company,
1265
                                verbose_name=_(u"company"))
1266
    cidr = models.CharField(_(u"ip/cidr Address"),
1267
                            max_length=100,
1268
                            help_text=_(u"Customer IP or cidr address."))
1269
    POLICY_CHOICES = (
1270
        ('deny', _('deny')),
1271
        ('allow', _('allow')),
1272
    )
1273
    policy = models.CharField(_(u"policy"),
1274
                              max_length=10,
1275
                              choices=POLICY_CHOICES,
1276
                              default='allow')
1277
    acllist = models.ForeignKey(AclLists,
1278
                                verbose_name=_(u"acl list"))
1279
    date_added = models.DateTimeField(_(u'date added'),
1280
                                      auto_now_add=True)
1281
    date_modified = models.DateTimeField(_(u'date modified'),
1282
                                         auto_now=True)
1283
1284
    class Meta:
1285
        db_table = 'acl_nodes'
@@ 264-294 (lines=31) @@
261
                            unique=True)
262
    about = models.TextField(_(u'about'),
263
                             blank=True)
264
    people = models.ManyToManyField(Person,
265
                                    verbose_name=_(u'people'),
266
                                    blank=True,
267
                                    null=True)
268
    companies = models.ManyToManyField(Company,
269
                                       verbose_name=_(u'companies'),
270
                                       blank=True,
271
                                       null=True)
272
    date_added = models.DateTimeField(_(u'date added'),
273
                                      auto_now_add=True)
274
    date_modified = models.DateTimeField(_(u'date modified'),
275
                                         auto_now=True)
276
277
    class Meta:
278
        db_table = 'contacts_groups'
279
        ordering = ('name',)
280
        verbose_name = _(u'group')
281
        verbose_name_plural = _(u'groups')
282
283
    def __unicode__(self):
284
        return u"%s" % self.name
285
286
287
PHONE_LOCATION_CHOICES = (
288
    ('work', _(u'Work')),
289
    ('mobile', _(u'Mobile')),
290
    ('fax', _(u'Fax')),
291
    ('pager', _(u'Pager')),
292
    ('home', _(u'Home')),
293
    ('other', _(u'Other')),
294
)
295
296
297
class PhoneNumber(models.Model):
@@ 1747-1776 (lines=30) @@
1744
    billsec = models.IntegerField(_(u"billed duration"), null=True, help_text=_(u"billed call duration in s."))
1745
    read_codec = models.CharField(_(u"read codec"), max_length=20, null=True)
1746
    write_codec = models.CharField(_(u"write codec"), max_length=20, null=True)
1747
    hangup_cause = models.CharField(_(u"hangup cause"), max_length=50, null=True, db_index=True)
1748
    hangup_cause_q850 = models.IntegerField(_(u"q.850"), null=True)
1749
    gateway = models.ForeignKey(SofiaGateway, verbose_name=_(u"gateway"), null=True)
1750
    cost_rate = models.DecimalField(_(u'buy rate'), max_digits=11, decimal_places=5, default="0", null=True)
1751
    total_sell = models.DecimalField(_(u'total sell'), max_digits=11, decimal_places=5, default="0", null=True)
1752
    total_cost = models.DecimalField(_(u'total cost'), max_digits=11, decimal_places=5, default="0", null=True)
1753
    prefix = models.CharField(_(u'Prefix'), max_length=30, null=True)
1754
    country = models.CharField(_(u'Country'), max_length=100, null=True)
1755
    rate = models.DecimalField(_(u'sell rate'), max_digits=11, decimal_places=5, null=True)
1756
    init_block = models.DecimalField(_(u'Connection fee'), max_digits=11, decimal_places=5, null=True)
1757
    block_min_duration = models.IntegerField(_(u'increment'), null=True)
1758
    lcr_carrier_id = models.ForeignKey(Company, verbose_name=_(u"provider"), null=True, related_name="carrier_related")
1759
    ratecard_id = models.ForeignKey(RateCard, null=True, verbose_name=_(u"ratecard"))
1760
    lcr_group_id = models.ForeignKey(LCRGroup, null=True, verbose_name=_(u"lcr group"))
1761
    sip_user_agent = models.CharField(_(u'sip user agent'), null=True, max_length=100)
1762
    sip_rtp_rxstat = models.CharField(_(u'sip rtp rx stat'), null=True, max_length=30)
1763
    sip_rtp_txstat = models.CharField(_(u'sip rtp tx stat'), null=True, max_length=30)
1764
    switchname = models.CharField(_(u"switchname"), null=True, default="", max_length=100)
1765
    switch_ipv4 = models.CharField(_(u"switch ipv4"), null=True, default="", max_length=100)
1766
    hangup_disposition = models.CharField(_(u"hangup disposition"), null=True, default="", max_length=100)
1767
    sip_hangup_cause = models.CharField(_(u"SIP hangup cause"), null=True, default="", max_length=100)
1768
    sell_destination = models.CharField(_(u'sell destination'), blank=True, default='', null=True, max_length=128, db_index=True)
1769
    cost_destination = models.CharField(_(u'cost destination'), blank=True, default='', null=True, max_length=128, db_index=True)
1770
1771
    class Meta:
1772
        db_table = 'cdr'
1773
        ordering = ('start_stamp', 'customer')
1774
        verbose_name = _(u"CDR")
1775
        verbose_name_plural = _(u"CDRs")
1776
1777
    def __unicode__(self):
1778
        if self.start_stamp:
1779
            return self.start_stamp