Skip to content

Commit

Permalink
DB support for PendingBlog
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaitlyn Parkhurst committed Nov 5, 2021
1 parent c8551f1 commit f71eaf8
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 2 deletions.
27 changes: 27 additions & 0 deletions DB/etc/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,33 @@ CREATE TABLE blog (
created_at timestamptz not null default current_timestamp
);

-- Root table for the blog listing.
CREATE TABLE pending_blog (
id serial PRIMARY KEY,
url text not null unique,
img_url text ,
rss_url text ,
title text ,
tagline text ,
about text ,
last_updated timestamptz ,
is_published boolean not null default true,
is_adult boolean not null default false,

-- If a registered user submitted the blog, they will be set as the
-- submitter and can edit the blog data until it's approved.
--
-- If an anonymous user submitted the blog, they will have an edit
-- token set in their cookies, and that token will be set here, they
-- can edit the blog until their session expires.
submitter_id int references person(id),
edit_token text not null,

state text not null,

created_at timestamptz not null default current_timestamp
);

-- RSS Reader will create these for the blogs.
CREATE TABLE blog_entry (
id serial PRIMARY KEY,
Expand Down
212 changes: 212 additions & 0 deletions DB/lib/BlogDB/DB/Result/PendingBlog.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
use utf8;
package BlogDB::DB::Result::PendingBlog;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

=head1 NAME
BlogDB::DB::Result::PendingBlog
=cut

use strict;
use warnings;

use base 'DBIx::Class::Core';

=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=item * L<DBIx::Class::InflateColumn::Serializer>
=back
=cut

__PACKAGE__->load_components("InflateColumn::DateTime", "InflateColumn::Serializer");

=head1 TABLE: C<pending_blog>
=cut

__PACKAGE__->table("pending_blog");

=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
sequence: 'pending_blog_id_seq'
=head2 url
data_type: 'text'
is_nullable: 0
=head2 img_url
data_type: 'text'
is_nullable: 1
=head2 rss_url
data_type: 'text'
is_nullable: 1
=head2 title
data_type: 'text'
is_nullable: 1
=head2 tagline
data_type: 'text'
is_nullable: 1
=head2 about
data_type: 'text'
is_nullable: 1
=head2 last_updated
data_type: 'timestamp with time zone'
is_nullable: 1
=head2 is_published
data_type: 'boolean'
default_value: true
is_nullable: 0
=head2 is_adult
data_type: 'boolean'
default_value: false
is_nullable: 0
=head2 submitter_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 edit_token
data_type: 'text'
is_nullable: 0
=head2 state
data_type: 'text'
is_nullable: 0
=head2 created_at
data_type: 'timestamp with time zone'
default_value: current_timestamp
is_nullable: 0
=cut

__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
is_auto_increment => 1,
is_nullable => 0,
sequence => "pending_blog_id_seq",
},
"url",
{ data_type => "text", is_nullable => 0 },
"img_url",
{ data_type => "text", is_nullable => 1 },
"rss_url",
{ data_type => "text", is_nullable => 1 },
"title",
{ data_type => "text", is_nullable => 1 },
"tagline",
{ data_type => "text", is_nullable => 1 },
"about",
{ data_type => "text", is_nullable => 1 },
"last_updated",
{ data_type => "timestamp with time zone", is_nullable => 1 },
"is_published",
{ data_type => "boolean", default_value => \"true", is_nullable => 0 },
"is_adult",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
"submitter_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"edit_token",
{ data_type => "text", is_nullable => 0 },
"state",
{ data_type => "text", is_nullable => 0 },
"created_at",
{
data_type => "timestamp with time zone",
default_value => \"current_timestamp",
is_nullable => 0,
},
);

=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut

__PACKAGE__->set_primary_key("id");

=head1 UNIQUE CONSTRAINTS
=head2 C<pending_blog_url_key>
=over 4
=item * L</url>
=back
=cut

__PACKAGE__->add_unique_constraint("pending_blog_url_key", ["url"]);

=head1 RELATIONS
=head2 submitter
Type: belongs_to
Related object: L<BlogDB::DB::Result::Person>
=cut

__PACKAGE__->belongs_to(
"submitter",
"BlogDB::DB::Result::Person",
{ id => "submitter_id" },
{
is_deferrable => 0,
join_type => "LEFT",
on_delete => "NO ACTION",
on_update => "NO ACTION",
},
);


# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-05 14:49:36
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4Ms5W+IBBcccbKjRTi1z8A


# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
19 changes: 17 additions & 2 deletions DB/lib/BlogDB/DB/Result/Person.pm
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 pending_blogs
Type: has_many
Related object: L<BlogDB::DB::Result::PendingBlog>
=cut

__PACKAGE__->has_many(
"pending_blogs",
"BlogDB::DB::Result::PendingBlog",
{ "foreign.submitter_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 person_follow_blog_maps
Type: has_many
Expand Down Expand Up @@ -265,8 +280,8 @@ __PACKAGE__->has_many(
);


# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-10-06 18:19:48
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pH+QD6dGCkPfgVuSzSHdGg
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-04 01:11:09
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uamr/+RThTQZLjXkv6wcxQ

sub setting {
my ( $self, $setting, $value ) = @_;
Expand Down

0 comments on commit f71eaf8

Please sign in to comment.