~divmod-dev/divmod.org/lsbranch-1195

« back to all changes in this revision

Viewing changes to Mantissa/xmantissa/people.py

  • Committer: glyph
  • Date: 2007-12-01 14:49:00 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:14428
Create EmailAddress items for newly signed up users when UserInfoSignup is being used.

Author: glyph

Reviewer: moe

Fixes #2305

This remembers the email address entered by the user as an `EmailAddress` contact info item as well as a `LoginMethod`, so that the addressbook can see it as well as the login system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from axiom.upgrade import (
28
28
    registerUpgrader, registerAttributeCopyingUpgrader,
29
29
    registerDeletionUpgrader)
 
30
from axiom.userbase import LoginAccount, LoginMethod
30
31
 
31
32
from xmantissa.ixmantissa import IPersonFragment
32
33
from xmantissa import ixmantissa, webnav, webtheme, liveform, signup
426
427
 
427
428
 
428
429
class Person(item.Item):
 
430
    """
 
431
    Person Per"son (p[~e]r"s'n; 277), n.
 
432
 
 
433
        1. A character or part, as in a play; a specific kind or manifestation
 
434
        of individual character, whether in real life, or in literary or
 
435
        dramatic representation; an assumed character. [Archaic] [1913 Webster]
 
436
 
 
437
    This is Mantissa's simulation of a person, which has attached contact
 
438
    information.  It is highly pluggable, mostly via the L{Organizer} object.
 
439
 
 
440
    Do not create this item directly, as functionality of L{IOrganizerPlugin}
 
441
    powerups will be broken if you do.  Instead, use L{Organizer.createPerson}.
 
442
    """
 
443
 
429
444
    typeName = 'mantissa_person'
430
445
    schemaVersion = 3
431
446
 
447
462
        """, default=False, allowNone=False)
448
463
 
449
464
 
450
 
    def __init__(self, **kw):
451
 
        super(Person, self).__init__(**kw)
452
 
 
453
 
 
454
465
    def getDisplayName(self):
455
466
        return self.name
456
467
 
697
708
        name = u''
698
709
        if userInfo is not None:
699
710
            name = userInfo.realName
700
 
        return Person(store=self.store, organizer=self, name=name)
 
711
        account = self.store.findUnique(LoginAccount,
 
712
                                        LoginAccount.avatars == self.store, None)
 
713
        ownerPerson = self.createPerson(name)
 
714
        if account is not None:
 
715
            for method in (self.store.query(
 
716
                    LoginMethod,
 
717
                    attributes.AND(LoginMethod.account == account,
 
718
                                   LoginMethod.internal == False))):
 
719
                self.createContactItem(
 
720
                    EmailContactType(self.store),
 
721
                    ownerPerson, dict(
 
722
                        email=method.localpart + u'@' + method.domain))
 
723
        return ownerPerson
701
724
 
702
725
 
703
726
    def getOrganizerPlugins(self):
827
850
 
828
851
        @rtype: L{Person}
829
852
        """
830
 
        for person in self.store.query(Person, Person.name == nickname):
 
853
        for person in (self.store.query(
 
854
                Person, attributes.AND(
 
855
                    Person.name == nickname,
 
856
                    Person.organizer == self))):
831
857
            raise ValueError("Person with name %r exists already." % (nickname,))
832
858
        person = Person(
833
859
            store=self.store,
1426
1452
 
1427
1453
 
1428
1454
class RealName(item.Item):
 
1455
    """
 
1456
    This is a legacy item left over from a previous schema.  Do not create it.
 
1457
    """
1429
1458
    typeName = 'mantissa_organizer_addressbook_realname'
1430
1459
    schemaVersion = 2
1431
1460
 
1448
1477
 
1449
1478
 
1450
1479
class EmailAddress(item.Item):
 
1480
    """
 
1481
    An email address contact info item associated with a L{Person}.
 
1482
 
 
1483
    Do not create this item directly, as functionality of L{IOrganizerPlugin}
 
1484
    powerups will be broken if you do.  Instead, use
 
1485
    L{Organizer.createContactItem} with L{EmailContactType}.
 
1486
    """
1451
1487
    typeName = 'mantissa_organizer_addressbook_emailaddress'
1452
1488
    schemaVersion = 3
1453
1489
 
1484
1520
 
1485
1521
 
1486
1522
class PhoneNumber(item.Item):
 
1523
    """
 
1524
    A contact information item representing a L{Person}'s phone number.
 
1525
 
 
1526
    Do not create this item directly, as functionality of L{IOrganizerPlugin}
 
1527
    powerups will be broken if you do.  Instead, use
 
1528
    L{Organizer.createContactItem} with L{PhoneNumberContactType}.
 
1529
    """
1487
1530
    typeName = 'mantissa_organizer_addressbook_phonenumber'
1488
1531
    schemaVersion = 3
1489
1532