mirror of https://github.com/zulip/zulip.git
Add a management command to populate the database.
It will drop the relevant account and zephyr tables and populate them with canned data. Run the command with: python manage.py populate_db (imported from commit 69ddea0a405c3a34c83cbae2f65373e12142c9fb)
This commit is contained in:
parent
e509cc8a85
commit
342b2a13ac
|
@ -0,0 +1,47 @@
|
||||||
|
from django.core.management.base import NoArgsCommand
|
||||||
|
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from zephyr.models import Zephyr, UserProfile, ZephyrClass
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import random
|
||||||
|
|
||||||
|
class Command(NoArgsCommand):
|
||||||
|
help = "Populate a test database"
|
||||||
|
|
||||||
|
def handle_noargs(self, **options):
|
||||||
|
for klass in [Zephyr, ZephyrClass, UserProfile, User]:
|
||||||
|
klass.objects.all().delete()
|
||||||
|
|
||||||
|
# Create test Users (UserProfiles are automatically created).
|
||||||
|
for username in ["othello", "iago", "prospero", "cordelia", "hamlet"]:
|
||||||
|
u = User.objects.create_user(username=username, password=username)
|
||||||
|
u.save()
|
||||||
|
|
||||||
|
# Create classes.
|
||||||
|
for name in ["Verona", "Denmark", "Scotland", "Venice", "Rome"]:
|
||||||
|
new_class = ZephyrClass()
|
||||||
|
new_class.name = name
|
||||||
|
new_class.save()
|
||||||
|
|
||||||
|
# Create some test zephyrs, including:
|
||||||
|
# - multiple classes
|
||||||
|
# - multiple instances per class
|
||||||
|
# - multiple zephyrs per instance
|
||||||
|
# - both single and multi-line content
|
||||||
|
users = [user.id for user in User.objects.all()]
|
||||||
|
zephyr_classes = [klass.id for klass in ZephyrClass.objects.all()]
|
||||||
|
texts = file("zephyr/management/commands/test_zephyrs.txt", "r").readlines()
|
||||||
|
offset = 0
|
||||||
|
while offset < len(texts):
|
||||||
|
new_zephyr = Zephyr()
|
||||||
|
new_zephyr.sender = UserProfile.objects.get(id=random.choice(users))
|
||||||
|
length = random.randint(1, 5)
|
||||||
|
new_zephyr.content = "".join(texts[offset: offset + length])
|
||||||
|
offset += length
|
||||||
|
new_zephyr.zephyr_class = ZephyrClass.objects.get(id=random.choice(zephyr_classes))
|
||||||
|
new_zephyr.instance = new_zephyr.zephyr_class.name + str(random.randint(1, 3))
|
||||||
|
new_zephyr.pub_date = datetime.datetime.utcnow()
|
||||||
|
new_zephyr.save()
|
||||||
|
|
||||||
|
self.stdout.write("Successfully populated test database.")
|
|
@ -0,0 +1,329 @@
|
||||||
|
From off a hill whose concave womb reworded
|
||||||
|
A plaintful story from a sist'ring vale,
|
||||||
|
My spirits t'attend this double voice accorded,
|
||||||
|
And down I laid to list the sad-tuned tale,
|
||||||
|
Ere long espied a fickle maid full pale,
|
||||||
|
Tearing of papers, breaking rings atwain,
|
||||||
|
Storming her world with sorrow's wind and rain.
|
||||||
|
Upon her head a platted hive of straw,
|
||||||
|
Which fortified her visage from the sun,
|
||||||
|
Whereon the thought might think sometime it saw
|
||||||
|
The carcase of a beauty spent and done.
|
||||||
|
Time had not scythed all that youth begun,
|
||||||
|
Nor youth all quit, but spite of heaven's fell rage
|
||||||
|
Some beauty peeped through lattice of seared age.
|
||||||
|
Oft did she heave her napkin to her eyne,
|
||||||
|
Which on it had conceited characters,
|
||||||
|
Laund'ring the silken figures in the brine
|
||||||
|
That seasoned woe had pelleted in tears,
|
||||||
|
And often reading what contents it bears;
|
||||||
|
As often shrieking undistinguished woe,
|
||||||
|
In clamours of all size, both high and low.
|
||||||
|
Sometimes her levelled eyes their carriage ride,
|
||||||
|
As they did batt'ry to the spheres intend;
|
||||||
|
Sometime diverted their poor balls are tied
|
||||||
|
To th' orbed earth; sometimes they do extend
|
||||||
|
Their view right on; anon their gazes lend
|
||||||
|
To every place at once, and nowhere fixed,
|
||||||
|
The mind and sight distractedly commixed.
|
||||||
|
Her hair, nor loose nor tied in formal plat,
|
||||||
|
Proclaimed in her a careless hand of pride;
|
||||||
|
For some, untucked, descended her sheaved hat,
|
||||||
|
Hanging her pale and pined cheek beside;
|
||||||
|
Some in her threaden fillet still did bide,
|
||||||
|
And, true to bondage, would not break from thence,
|
||||||
|
Though slackly braided in loose negligence.
|
||||||
|
A thousand favours from a maund she drew
|
||||||
|
Of amber, crystal, and of beaded jet,
|
||||||
|
Which one by one she in a river threw,
|
||||||
|
Upon whose weeping margent she was set;
|
||||||
|
Like usury applying wet to wet,
|
||||||
|
Or monarchs' hands that lets not bounty fall
|
||||||
|
Where want cries some, but where excess begs all.
|
||||||
|
Of folded schedules had she many a one,
|
||||||
|
Which she perused, sighed, tore, and gave the flood;
|
||||||
|
Cracked many a ring of posied gold and bone,
|
||||||
|
Bidding them find their sepulchres in mud;
|
||||||
|
Found yet moe letters sadly penned in blood,
|
||||||
|
With sleided silk feat and affectedly
|
||||||
|
Enswathed and sealed to curious secrecy.
|
||||||
|
These often bathed she in her fluxive eyes,
|
||||||
|
And often kissed, and often 'gan to tear;
|
||||||
|
Cried, 'O false blood, thou register of lies,
|
||||||
|
What unapproved witness dost thou bear!
|
||||||
|
Ink would have seemed more black and damned here!
|
||||||
|
This said, in top of rage the lines she rents,
|
||||||
|
Big discontents so breaking their contents.
|
||||||
|
A reverend man that grazed his cattle nigh,
|
||||||
|
Sometime a blusterer that the ruffle knew
|
||||||
|
Of court, of city, and had let go by
|
||||||
|
The swiftest hours observed as they flew,
|
||||||
|
Towards this afflicted fancy fastly drew;
|
||||||
|
And, privileged by age, desires to know
|
||||||
|
In brief the grounds and motives of her woe.
|
||||||
|
So slides he down upon his grained bat,
|
||||||
|
And comely distant sits he by her side;
|
||||||
|
When he again desires her, being sat,
|
||||||
|
Her grievance with his hearing to divide.
|
||||||
|
If that from him there may be aught applied
|
||||||
|
Which may her suffering ecstasy assuage,
|
||||||
|
'Tis promised in the charity of age.
|
||||||
|
'Father,' she says, 'though in me you behold
|
||||||
|
The injury of many a blasting hour,
|
||||||
|
Let it not tell your judgement I am old:
|
||||||
|
Not age, but sorrow, over me hath power.
|
||||||
|
I might as yet have been a spreading flower,
|
||||||
|
Fresh to myself, if I had self-applied
|
||||||
|
Love to myself, and to no love beside.
|
||||||
|
'But woe is me! too early I attended
|
||||||
|
A youthful suit- it was to gain my grace-
|
||||||
|
O, one by nature's outwards so commended
|
||||||
|
That maidens' eyes stuck over all his face.
|
||||||
|
Love lacked a dwelling and made him her place;
|
||||||
|
And when in his fair parts she did abide,
|
||||||
|
She was new lodged and newly deified.
|
||||||
|
'His browny locks did hang in crooked curls;
|
||||||
|
And every light occasion of the wind
|
||||||
|
Upon his lips their silken parcels hurls.
|
||||||
|
What's sweet to do, to do will aptly find:
|
||||||
|
Each eye that saw him did enchant the mind;
|
||||||
|
For on his visage was in little drawn
|
||||||
|
What largeness thinks in Paradise was sawn.
|
||||||
|
'Small show of man was yet upon his chin;
|
||||||
|
His phoenix down began but to appear,
|
||||||
|
Like unshorn velvet, on that termless skin,
|
||||||
|
Whose bare out-bragged the web it seemed to wear:
|
||||||
|
Yet showed his visage by that cost more dear;
|
||||||
|
And nice affections wavering stood in doubt
|
||||||
|
If best were as it was, or best without.
|
||||||
|
'His qualities were beauteous as his form,
|
||||||
|
For maiden-tongued he was, and thereof free;
|
||||||
|
Yet if men moved him, was he such a storm
|
||||||
|
As oft 'twixt May and April is to see,
|
||||||
|
When winds breathe sweet, unruly though they be.
|
||||||
|
His rudeness so with his authorized youth
|
||||||
|
Did livery falseness in a pride of truth.
|
||||||
|
'Well could he ride, and often men would say,
|
||||||
|
"That horse his mettle from his rider takes:
|
||||||
|
Proud of subjection, noble by the sway,
|
||||||
|
What rounds, what bounds, what course, what stop he makes!"
|
||||||
|
And controversy hence a question takes
|
||||||
|
Whether the horse by him became his deed,
|
||||||
|
Or he his manage by th' well-doing steed.
|
||||||
|
'But quickly on this side the verdict went:
|
||||||
|
His real habitude gave life and grace
|
||||||
|
To appertainings and to ornament,
|
||||||
|
Accomplished in himself, not in his case,
|
||||||
|
All aids, themselves made fairer by their place,
|
||||||
|
Came for additions; yet their purposed trim
|
||||||
|
Pierced not his grace, but were all graced by him.
|
||||||
|
'So on the tip of his subduing tongue
|
||||||
|
All kind of arguments and question deep,
|
||||||
|
All replication prompt, and reason strong,
|
||||||
|
For his advantage still did wake and sleep.
|
||||||
|
To make the weeper laugh, the laugher weep,
|
||||||
|
He had the dialect and different skill,
|
||||||
|
Catching all passions in his craft of will,
|
||||||
|
'That he did in the general bosom reign
|
||||||
|
Of young, of old, and sexes both enchanted,
|
||||||
|
To dwell with him in thoughts, or to remain
|
||||||
|
In personal duty, following where he haunted.
|
||||||
|
Consents bewitched, ere he desire, have granted,
|
||||||
|
And dialogued for him what he would say,
|
||||||
|
Asked their own wills, and made their wills obey.
|
||||||
|
'Many there were that did his picture get,
|
||||||
|
To serve their eyes, and in it put their mind;
|
||||||
|
Like fools that in th' imagination set
|
||||||
|
The goodly objects which abroad they find
|
||||||
|
Of lands and mansions, theirs in thought assigned;
|
||||||
|
And labouring in moe pleasures to bestow them
|
||||||
|
Than the true gouty landlord which doth owe them.
|
||||||
|
'So many have, that never touched his hand,
|
||||||
|
Sweetly supposed them mistress of his heart.
|
||||||
|
My woeful self, that did in freedom stand,
|
||||||
|
And was my own fee-simple, not in part,
|
||||||
|
What with his art in youth, and youth in art,
|
||||||
|
Threw my affections in his charmed power
|
||||||
|
Reserved the stalk and gave him all my flower.
|
||||||
|
'Yet did I not, as some my equals did,
|
||||||
|
Demand of him, nor being desired yielded;
|
||||||
|
Finding myself in honour so forbid,
|
||||||
|
With safest distance I mine honour shielded.
|
||||||
|
Experience for me many bulwarks builded
|
||||||
|
Of proofs new-bleeding, which remained the foil
|
||||||
|
Of this false jewel, and his amorous spoil.
|
||||||
|
'But ah, who ever shunned by precedent
|
||||||
|
The destined ill she must herself assay?
|
||||||
|
Or forced examples, 'gainst her own content,
|
||||||
|
To put the by-past perils in her way?
|
||||||
|
Counsel may stop awhile what will not stay;
|
||||||
|
For when we rage, advice is often seen
|
||||||
|
By blunting us to make our wills more keen.
|
||||||
|
'Nor gives it satisfaction to our blood
|
||||||
|
That we must curb it upon others' proof,
|
||||||
|
To be forbod the sweets that seems so good
|
||||||
|
For fear of harms that preach in our behoof.
|
||||||
|
O appetite, from judgement stand aloof!
|
||||||
|
The one a palate hath that needs will taste,
|
||||||
|
Though Reason weep, and cry it is thy last.
|
||||||
|
'For further I could say this man's untrue,
|
||||||
|
And knew the patterns of his foul beguiling;
|
||||||
|
Heard where his plants in others' orchards grew;
|
||||||
|
Saw how deceits were gilded in his smiling;
|
||||||
|
Knew vows were ever brokers to defiling;
|
||||||
|
Thought characters and words merely but art,
|
||||||
|
And bastards of his foul adulterate heart.
|
||||||
|
'And long upon these terms I held my city,
|
||||||
|
Till thus he 'gan besiege me: "Gentle maid,
|
||||||
|
Have of my suffering youth some feeling pity,
|
||||||
|
And be not of my holy vows afraid.
|
||||||
|
That's to ye sworn to none was ever said;
|
||||||
|
For feasts of love I have been called unto,
|
||||||
|
Till now did ne'er invite nor never woo.
|
||||||
|
'"All my offences that abroad you see
|
||||||
|
Are errors of the blood, none of the mind;
|
||||||
|
Love made them not; with acture they may be,
|
||||||
|
Where neither party is nor true nor kind.
|
||||||
|
They sought their shame that so their shame did find;
|
||||||
|
And so much less of shame in me remains
|
||||||
|
By how much of me their reproach contains.
|
||||||
|
'"Among the many that mine eyes have seen,
|
||||||
|
Not one whose flame my heart so much as warmed,
|
||||||
|
Or my affection put to th' smallest teen,
|
||||||
|
Or any of my leisures ever charmed.
|
||||||
|
Harm have I done to them, but ne'er was harmed;
|
||||||
|
Kept hearts in liveries, but mine own was free,
|
||||||
|
And reigned commanding in his monarchy.
|
||||||
|
'"Look here what tributes wounded fancies sent me,
|
||||||
|
Of paled pearls and rubies red as blood;
|
||||||
|
Figuring that they their passions likewise lent me
|
||||||
|
Of grief and blushes, aptly understood
|
||||||
|
In bloodless white and the encrimsoned mood-
|
||||||
|
Effects of terror and dear modesty,
|
||||||
|
Encamped in hearts, but fighting outwardly.
|
||||||
|
'"And, lo, behold these talents of their hair,
|
||||||
|
With twisted metal amorously empleached,
|
||||||
|
I have receiv'd from many a several fair,
|
||||||
|
Their kind acceptance weepingly beseeched,
|
||||||
|
With the annexions of fair gems enriched,
|
||||||
|
And deep-brained sonnets that did amplify
|
||||||
|
Each stone's dear nature, worth, and quality.
|
||||||
|
'"The diamond? why, 'twas beautiful and hard,
|
||||||
|
Whereto his invised properties did tend;
|
||||||
|
The deep-green em'rald, in whose fresh regard
|
||||||
|
Weak sights their sickly radiance do amend;
|
||||||
|
The heaven-hued sapphire and the opal blend
|
||||||
|
With objects manifold; each several stone,
|
||||||
|
With wit well blazoned, smiled, or made some moan.
|
||||||
|
'"Lo, all these trophies of affections hot,
|
||||||
|
Of pensived and subdued desires the tender,
|
||||||
|
Nature hath charged me that I hoard them not,
|
||||||
|
But yield them up where I myself must render-
|
||||||
|
That is, to you, my origin and ender;
|
||||||
|
For these, of force, must your oblations be,
|
||||||
|
Since I their altar, you enpatron me.
|
||||||
|
'"O then advance of yours that phraseless hand
|
||||||
|
Whose white weighs down the airy scale of praise;
|
||||||
|
Take all these similes to your own command,
|
||||||
|
Hallowed with sighs that burning lungs did raise;
|
||||||
|
What me your minister for you obeys
|
||||||
|
Works under you; and to your audit comes
|
||||||
|
Their distract parcels in combined sums.
|
||||||
|
'"Lo, this device was sent me from a nun,
|
||||||
|
Or sister sanctified, of holiest note,
|
||||||
|
Which late her noble suit in court did shun,
|
||||||
|
Whose rarest havings made the blossoms dote;
|
||||||
|
For she was sought by spirits of richest coat,
|
||||||
|
But kept cold distance, and did thence remove
|
||||||
|
To spend her living in eternal love.
|
||||||
|
'"But, O my sweet, what labour is't to leave
|
||||||
|
The thing we have not, mast'ring what not strives,
|
||||||
|
Playing the place which did no form receive,
|
||||||
|
Playing patient sports in unconstrained gyves!
|
||||||
|
She that her fame so to herself contrives,
|
||||||
|
The scars of battle scapeth by the flight,
|
||||||
|
And makes her absence valiant, not her might.
|
||||||
|
'"O pardon me in that my boast is true!
|
||||||
|
The accident which brought me to her eye
|
||||||
|
Upon the moment did her force subdue,
|
||||||
|
And now she would the caged cloister fly.
|
||||||
|
Religious love put out religion's eye.
|
||||||
|
Not to be tempted, would she be immured,
|
||||||
|
And now to tempt all liberty procured.
|
||||||
|
'"How mighty then you are, O hear me tell!
|
||||||
|
The broken bosoms that to me belong
|
||||||
|
Have emptied all their fountains in my well,
|
||||||
|
And mine I pour your ocean all among.
|
||||||
|
I strong o'er them, and you o'er me being strong,
|
||||||
|
Must for your victory us all congest,
|
||||||
|
As compound love to physic your cold breast.
|
||||||
|
'"My parts had pow'r to charm a sacred nun,
|
||||||
|
Who, disciplined, ay, dieted in grace,
|
||||||
|
Believed her eyes when they t'assail begun,
|
||||||
|
All vows and consecrations giving place,
|
||||||
|
O most potential love, vow, bond, nor space,
|
||||||
|
In thee hath neither sting, knot, nor confine,
|
||||||
|
For thou art all, and all things else are thine.
|
||||||
|
'"When thou impressest, what are precepts worth
|
||||||
|
Of stale example? When thou wilt inflame,
|
||||||
|
How coldly those impediments stand forth,
|
||||||
|
Of wealth, of filial fear, law, kindred, fame!
|
||||||
|
Love's arms are peace, 'gainst rule, 'gainst sense, 'gainst ame.
|
||||||
|
And sweetens, in the suff'ring pangs it bears,
|
||||||
|
The aloes of all forces, shocks and fears.
|
||||||
|
'"Now all these hearts that do on mine depend,
|
||||||
|
Feeling it break, with bleeding groans they pine,
|
||||||
|
And supplicant their sighs to your extend,
|
||||||
|
To leave the batt'ry that you make 'gainst mine,
|
||||||
|
Lending soft audience to my sweet design,
|
||||||
|
And credent soul to that strong-bonded oath,
|
||||||
|
That shall prefer and undertake my troth."
|
||||||
|
'This said, his wat'ry eyes he did dismount,
|
||||||
|
Whose sights till then were levelled on my face;
|
||||||
|
Each cheek a river running from a fount
|
||||||
|
With brinish current downward flowed apace.
|
||||||
|
O, how the channel to the stream gave grace!
|
||||||
|
Who glazed with crystal gate the glowing roses
|
||||||
|
That flame through water which their hue encloses.
|
||||||
|
'O father, what a hell of witchcraft lies
|
||||||
|
In the small orb of one particular tear!
|
||||||
|
But with the inundation of the eyes
|
||||||
|
What rocky heart to water will not wear?
|
||||||
|
What breast so cold that is not warmed here?
|
||||||
|
O cleft effect! cold modesty, hot wrath,
|
||||||
|
Both fire from hence and chill extincture hath.
|
||||||
|
'For lo, his passion, but an art of craft,
|
||||||
|
Even there resolved my reason into tears;
|
||||||
|
There my white stole of chastity I daffed,
|
||||||
|
Shook off my sober guards and civil fears;
|
||||||
|
Appear to him as he to me appears,
|
||||||
|
All melting; though our drops this diff'rence bore:
|
||||||
|
His poisoned me, and mine did him restore.
|
||||||
|
'In him a plenitude of subtle matter,
|
||||||
|
Applied to cautels, all strange forms receives,
|
||||||
|
Of burning blushes or of weeping water,
|
||||||
|
Or swooning paleness; and he takes and leaves,
|
||||||
|
In either's aptness, as it best deceives,
|
||||||
|
To blush at speeches rank, to weep at woes,
|
||||||
|
Or to turn white and swoon at tragic shows;
|
||||||
|
'That not a heart which in his level came
|
||||||
|
Could scape the hail of his all-hurting aim,
|
||||||
|
Showing fair nature is both kind and tame;
|
||||||
|
And, veiled in them, did win whom he would maim.
|
||||||
|
Against the thing he sought he would exclaim;
|
||||||
|
When he most burned in heart-wished luxury,
|
||||||
|
He preached pure maid and praised cold chastity.
|
||||||
|
'Thus merely with the garment of a Grace
|
||||||
|
The naked and concealed fiend he covered,
|
||||||
|
That th' unexperient gave the tempter place,
|
||||||
|
Which, like a cherubin, above them hovered.
|
||||||
|
Who, young and simple, would not be so lovered?
|
||||||
|
Ay me, I fell, and yet do question make
|
||||||
|
What I should do again for such a sake.
|
||||||
|
'O, that infected moisture of his eye,
|
||||||
|
O, that false fire which in his cheek so glowed,
|
||||||
|
O, that forced thunder from his heart did fly,
|
||||||
|
O, that sad breath his spongy lungs bestowed,
|
||||||
|
O, all that borrowed motion, seeming owed,
|
||||||
|
Would yet again betray the fore-betrayed,
|
||||||
|
And new pervert a reconciled maid.'
|
Loading…
Reference in New Issue