Align with latest ncclient
[flowspy] / accounts / models.py
1 # -*- coding: utf-8 -*- vim:fileencoding=utf-8:
2 # vim: tabstop=4:shiftwidth=4:softtabstop=4:expandtab
3
4 # Copyright © 2011-2014 Greek Research and Technology Network (GRNET S.A.)
5 # Copyright © 2011-2014 Leonidas Poulopoulos (@leopoul)
6
7 # Permission to use, copy, modify, and/or distribute this software for any
8 # purpose with or without fee is hereby granted, provided that the above
9 # copyright notice and this permission notice appear in all copies.
10
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
12 # TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
13 # FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
14 # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
15 # DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
16 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
17 # SOFTWARE.
18
19 from django.db import models
20 from django.contrib.auth.models import User
21 from peers.models import *
22
23
24 class UserProfile(models.Model):
25     user = models.OneToOneField(User)
26     peer = models.ForeignKey(Peer)
27     
28     class Meta:
29         permissions = (
30                 ("overview", "Can see registered users and rules"),
31             )
32
33     
34     def __unicode__(self):
35         return "%s:%s" %(self.user.username, self.peer.peer_name)
36
37     def get_address_space(self):
38         networks = self.domain.networks.all()
39         if not networks:
40             return False
41         return networks